Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dynamo
Commits
8af8c82f
Unverified
Commit
8af8c82f
authored
May 06, 2025
by
julienmancuso
Committed by
GitHub
May 07, 2025
Browse files
fix: create k8s service for main component only (#953)
parent
c4213899
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
86 additions
and
2 deletions
+86
-2
deploy/cloud/operator/api/v1alpha1/dynamocomponentdeployment_types.go
.../operator/api/v1alpha1/dynamocomponentdeployment_types.go
+6
-0
deploy/cloud/operator/api/v1alpha1/dynamocomponentdeployment_types_test.go
...ator/api/v1alpha1/dynamocomponentdeployment_types_test.go
+78
-0
deploy/cloud/operator/internal/controller/dynamocomponentdeployment_controller.go
...ternal/controller/dynamocomponentdeployment_controller.go
+2
-2
No files found.
deploy/cloud/operator/api/v1alpha1/dynamocomponentdeployment_types.go
View file @
8af8c82f
...
...
@@ -20,6 +20,8 @@
package
v1alpha1
import
(
"strings"
dynamoCommon
"github.com/ai-dynamo/dynamo/deploy/cloud/operator/api/dynamo/common"
corev1
"k8s.io/api/core/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
...
...
@@ -160,3 +162,7 @@ func (s *DynamoComponentDeployment) GetSpec() any {
func
(
s
*
DynamoComponentDeployment
)
SetSpec
(
spec
any
)
{
s
.
Spec
=
spec
.
(
DynamoComponentDeploymentSpec
)
}
func
(
s
*
DynamoComponentDeployment
)
IsMainComponent
()
bool
{
return
strings
.
HasSuffix
(
s
.
Spec
.
DynamoTag
,
s
.
Spec
.
ServiceName
)
}
deploy/cloud/operator/api/v1alpha1/dynamocomponentdeployment_types_test.go
0 → 100644
View file @
8af8c82f
/*
* SPDX-FileCopyrightText: Copyright (c) 2022 Atalaya Tech. Inc
* SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Modifications Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES
*/
package
v1alpha1
import
(
"testing"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
)
func
TestDynamoComponentDeployment_IsMainComponent
(
t
*
testing
.
T
)
{
type
fields
struct
{
TypeMeta
metav1
.
TypeMeta
ObjectMeta
metav1
.
ObjectMeta
Spec
DynamoComponentDeploymentSpec
Status
DynamoComponentDeploymentStatus
}
tests
:=
[]
struct
{
name
string
fields
fields
want
bool
}{
{
name
:
"main component"
,
fields
:
fields
{
Spec
:
DynamoComponentDeploymentSpec
{
DynamoTag
:
"dynamo-component:main"
,
DynamoComponentDeploymentSharedSpec
:
DynamoComponentDeploymentSharedSpec
{
ServiceName
:
"main"
,
},
},
},
want
:
true
,
},
{
name
:
"not main component"
,
fields
:
fields
{
Spec
:
DynamoComponentDeploymentSpec
{
DynamoTag
:
"dynamo-component:main"
,
DynamoComponentDeploymentSharedSpec
:
DynamoComponentDeploymentSharedSpec
{
ServiceName
:
"not-main"
,
},
},
},
want
:
false
,
},
}
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
s
:=
&
DynamoComponentDeployment
{
TypeMeta
:
tt
.
fields
.
TypeMeta
,
ObjectMeta
:
tt
.
fields
.
ObjectMeta
,
Spec
:
tt
.
fields
.
Spec
,
Status
:
tt
.
fields
.
Status
,
}
if
got
:=
s
.
IsMainComponent
();
got
!=
tt
.
want
{
t
.
Errorf
(
"DynamoComponentDeployment.IsMainComponent() = %v, want %v"
,
got
,
tt
.
want
)
}
})
}
}
deploy/cloud/operator/internal/controller/dynamocomponentdeployment_controller.go
View file @
8af8c82f
...
...
@@ -1522,8 +1522,8 @@ func (r *DynamoComponentDeploymentReconciler) generateService(ctx context.Contex
},
}
if
!
opt
.
isGenericService
&&
!
opt
.
containsStealingTrafficDebugModeEnabled
{
// if it's not a generic service and not contains stealing traffic debug mode enabled, we don't need to create the service
if
!
opt
.
dynamoComponentDeployment
.
IsMainComponent
()
||
(
!
opt
.
isGenericService
&&
!
opt
.
containsStealingTrafficDebugModeEnabled
)
{
// if it's not
the main component or if it's not
a generic service and not contains stealing traffic debug mode enabled, we don't need to create the service
return
kubeService
,
true
,
nil
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment