Skip to content

Commit

Permalink
fix: fetching gvk from scheme requires error handling (#305)
Browse files Browse the repository at this point in the history
Signed-off-by: Tomer Figenblat <[email protected]>
(cherry picked from commit 545ac11)
  • Loading branch information
TomerFi authored Nov 15, 2024
1 parent f52fab2 commit 1d320b6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
7 changes: 6 additions & 1 deletion controllers/nim_account_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,13 @@ func (r *NimAccountReconciler) reconcileRuntimeTemplate(ctx context.Context, acc

template.Labels = labels

sr, srErr := utils.GetNimServingRuntimeTemplate(r.Scheme())
if srErr != nil {
return srErr
}

template.Objects = []runtime.RawExtension{
{Object: utils.GetNimServingRuntimeTemplate(r.Scheme())},
{Object: sr},
}
return nil
}); err != nil {
Expand Down
9 changes: 6 additions & 3 deletions controllers/utils/nim.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ func getModelData(runtime NimRuntime, tokenResp *NimTokenResponse) (*NimModel, s
}

// GetNimServingRuntimeTemplate returns the Template used by ODH for creating serving runtimes
func GetNimServingRuntimeTemplate(scheme *runtime.Scheme) *v1alpha1.ServingRuntime {
func GetNimServingRuntimeTemplate(scheme *runtime.Scheme) (*v1alpha1.ServingRuntime, error) {
multiModel := false
sr := &v1alpha1.ServingRuntime{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -378,8 +378,11 @@ func GetNimServingRuntimeTemplate(scheme *runtime.Scheme) *v1alpha1.ServingRunti
},
}

gvk, _ := apiutil.GVKForObject(sr, scheme)
gvk, err := apiutil.GVKForObject(sr, scheme)
if err != nil {
return nil, err
}
sr.SetGroupVersionKind(gvk)

return sr
return sr, nil
}

0 comments on commit 1d320b6

Please sign in to comment.