Skip to content

Commit dadd20b

Browse files
Addressing review comments
Signed-off-by: Vishesh Tanksale <vtanksale@nvidia.com>
1 parent 06e60e8 commit dadd20b

File tree

6 files changed

+80
-35
lines changed

6 files changed

+80
-35
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
Copyright 2025.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
type Mongodb struct {
20+
Endpoint string `json:"endpoint"`
21+
}
22+
23+
type ArgoWorkFlows struct {
24+
Endpoint string `json:"endpoint"`
25+
ServiceAccount string `json:"serviceAccount"`
26+
}
27+
28+
type Milvus struct {
29+
Endpoint string `json:"endpoint"`
30+
}
31+
32+
type DataStore struct {
33+
Endpoint string `json:"endpoint"`
34+
}

api/apps/v1alpha1/nemo_evaluator_types.go

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ type NemoEvaluatorSpec struct {
7474
GroupID *int64 `json:"groupID,omitempty"`
7575
RuntimeClass string `json:"runtimeClass,omitempty"`
7676

77-
Mongodb Mongodb `json:"mongodb"`
78-
ArgoWorkFlows ArgoWorkFlows `json:"argoWorkFlows"`
79-
Milvus Milvus `json:"milvus"`
80-
DataStore DataStore `json:"dataStore"`
77+
Mongodb *Mongodb `json:"mongodb,omitempty"`
78+
ArgoWorkFlows *ArgoWorkFlows `json:"argoWorkFlows,omitempty"`
79+
Milvus *Milvus `json:"milvus,omitempty"`
80+
DataStore *DataStore `json:"dataStore,omitempty"`
8181
}
8282

8383
// NemoEvaluatorStatus defines the observed state of NemoEvaluator
@@ -111,23 +111,6 @@ type NemoEvaluatorList struct {
111111
Items []NemoEvaluator `json:"items"`
112112
}
113113

114-
type Mongodb struct {
115-
Endpoint string `json:"endpoint"`
116-
}
117-
118-
type ArgoWorkFlows struct {
119-
Endpoint string `json:"endpoint"`
120-
ServiceAccount string `json:"serviceAccount"`
121-
}
122-
123-
type Milvus struct {
124-
Endpoint string `json:"endpoint"`
125-
}
126-
127-
type DataStore struct {
128-
Endpoint string `json:"endpoint"`
129-
}
130-
131114
// GetStandardSelectorLabels returns the standard selector labels for the NemoEvaluator deployment
132115
func (n *NemoEvaluator) GetStandardSelectorLabels() map[string]string {
133116
return map[string]string{
@@ -149,6 +132,7 @@ func (n *NemoEvaluator) GetStandardLabels() map[string]string {
149132
// GetStandardEnv returns the standard set of env variables for the NemoEvaluator container
150133
func (n *NemoEvaluator) GetStandardEnv() []corev1.EnvVar {
151134
// add standard env required for NIM service
135+
152136
envVars := []corev1.EnvVar{
153137
{
154138
Name: "NAMESPACE",
@@ -195,9 +179,6 @@ func (n *NemoEvaluator) GetStandardEnv() []corev1.EnvVar {
195179
Name: "DATA_STORE_HOST",
196180
Value: n.Spec.DataStore.Endpoint,
197181
},
198-
{
199-
Name: "INFERENCE_URL",
200-
},
201182
{
202183
Name: "DATABASE_USERNAME",
203184
Value: "root",

api/apps/v1alpha1/zz_generated.deepcopy.go

Lines changed: 20 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ func main() {
206206
render.NewRenderer("/manifests"),
207207
ctrl.Log.WithName("controllers").WithName("NemoEvaluator"),
208208
).SetupWithManager(mgr); err != nil {
209-
setupLog.Error(err, "unable to create controller", "controller", "NemoDatastore")
209+
setupLog.Error(err, "unable to create controller", "controller", "NemoEvaluator")
210210
os.Exit(1)
211211
}
212212

config/crd/bases/apps.nvidia.com_nemoevaluators.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2126,11 +2126,6 @@ spec:
21262126
userID:
21272127
format: int64
21282128
type: integer
2129-
required:
2130-
- argoWorkFlows
2131-
- dataStore
2132-
- milvus
2133-
- mongodb
21342129
type: object
21352130
status:
21362131
description: NemoEvaluatorStatus defines the observed state of NemoEvaluator

internal/controller/nemo_evaluator_controller.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,10 @@ func (r *NemoEvaluatorReconciler) reconcileNemoEvaluator(ctx context.Context, Ne
275275
// Generate annotation for the current operator-version and apply to all resources
276276
// Get generic name for all resources
277277
namespacedName := types.NamespacedName{Name: NemoEvaluator.GetName(), Namespace: NemoEvaluator.GetNamespace()}
278-
278+
err = validateNemoEvaluator(ctx, NemoEvaluator)
279+
if err != nil {
280+
return ctrl.Result{}, err
281+
}
279282
renderer := r.GetRenderer()
280283

281284
// Sync serviceaccount
@@ -346,6 +349,22 @@ func (r *NemoEvaluatorReconciler) reconcileNemoEvaluator(ctx context.Context, Ne
346349
return ctrl.Result{}, nil
347350
}
348351

352+
func validateNemoEvaluator(ctx context.Context, NemoEvaluator *appsv1alpha1.NemoEvaluator) error {
353+
if NemoEvaluator.Spec.Mongodb == nil {
354+
return fmt.Errorf(" Required field 'Spec.Mongodb' cannot be empty")
355+
}
356+
if NemoEvaluator.Spec.ArgoWorkFlows == nil {
357+
return fmt.Errorf(" Required field 'Spec.ArgoWorkFlows' cannot be empty")
358+
}
359+
if NemoEvaluator.Spec.Milvus == nil {
360+
return fmt.Errorf(" Required field 'Spec.Milvus' cannot be empty")
361+
}
362+
if NemoEvaluator.Spec.DataStore == nil {
363+
return fmt.Errorf(" Required field 'Spec.DataStore' cannot be empty")
364+
}
365+
return nil
366+
}
367+
349368
func (r *NemoEvaluatorReconciler) renderAndSyncResource(ctx context.Context, NemoEvaluator client.Object, renderer *render.Renderer, obj client.Object, renderFunc func() (client.Object, error), conditionType string, reason string) error {
350369
logger := log.FromContext(ctx)
351370

0 commit comments

Comments
 (0)