Skip to content

Commit

Permalink
fix: nil pointer in kfdef list (red-hat-data-services#126)
Browse files Browse the repository at this point in the history
* fix: nil pointer for not getting kfdef


Signed-off-by: Wen Zhou <wenzhou@redhat.com>
  • Loading branch information
zdtsw authored Nov 20, 2023
1 parent 57c4b82 commit 6471658
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,11 +379,11 @@ func getClusterServiceVersion(cfg *rest.Config, watchNameSpace string) (*ofapi.C
func getKfDefInstances(c client.Client) (*kfdefv1.KfDefList, error) {
// If KfDef CRD is not found, we see it as a cluster not pre-installed v1 operator // Check if kfdef are deployed
kfdefCrd := &apiextv1.CustomResourceDefinition{}
err := c.Get(context.TODO(), client.ObjectKey{Name: "kfdefs.kfdef.apps.kubeflow.org"}, kfdefCrd)
if err != nil {
if err := c.Get(context.TODO(), client.ObjectKey{Name: "kfdefs.kfdef.apps.kubeflow.org"}, kfdefCrd); err != nil {
if apierrs.IsNotFound(err) {
// If no Crd found, return, since its a new Installation
return nil, nil
// return empty list
return &kfdefv1.KfDefList{}, nil
} else {
return nil, fmt.Errorf("error retrieving kfdef CRD : %v", err)
}
Expand All @@ -392,7 +392,7 @@ func getKfDefInstances(c client.Client) (*kfdefv1.KfDefList, error) {
// If KfDef Instances found, and no DSC instances are found in Self-managed, that means this is an upgrade path from
// legacy version. Create a default DSC instance
kfDefList := &kfdefv1.KfDefList{}
err = c.List(context.TODO(), kfDefList)
err := c.List(context.TODO(), kfDefList)
if err != nil {
if apierrs.IsNotFound(err) {
// If no KfDefs, do nothing and return
Expand Down

0 comments on commit 6471658

Please sign in to comment.