Skip to content

Commit

Permalink
ignore not found error for getting hosting cluster
Browse files Browse the repository at this point in the history
Signed-off-by: zhujian <[email protected]>
  • Loading branch information
zhujian7 committed Mar 18, 2024
1 parent f9f3ccd commit 1cff218
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/addonfactory/helm_agentaddon.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"helm.sh/helm/v3/pkg/chartutil"
"helm.sh/helm/v3/pkg/engine"
"helm.sh/helm/v3/pkg/releaseutil"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -271,11 +272,15 @@ func (a *HelmAgentAddon) getDefaultValues(
if len(hostingClusterName) > 0 {
hostingCluster, err := a.clusterClient.ClusterV1().ManagedClusters().
Get(context.TODO(), hostingClusterName, metav1.GetOptions{})
if err != nil {
if err == nil {
defaultValues.HostingClusterCapabilities = *a.capabilities(hostingCluster, addon)
} else if errors.IsNotFound(err) {
klog.Infof("hostingCluster %s not found, skip providing default value hostingClusterCapabilities",
hostingClusterName)
} else {
klog.Errorf("failed to get hostingCluster %s. err:%v", hostingClusterName, err)
return nil, err
}
defaultValues.HostingClusterCapabilities = *a.capabilities(hostingCluster, addon)
}
}

Expand Down

0 comments on commit 1cff218

Please sign in to comment.