Skip to content

Commit

Permalink
fix(platform): change helmrelease naming rule (tkestack#2293)
Browse files Browse the repository at this point in the history
Clusternet v0.15.3 has changed naming rule for new helmrelease
This patch provided a compatible way to get helmrelease name.

For existing helmrelease, use old nameing rule
For newly created helmrelease, use new namimg rule

Co-authored-by: willzgli <[email protected]>
  • Loading branch information
willzgli and willzgli authored May 23, 2023
1 parent 6da07c5 commit 4eca8b2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/platform/provider/baremetal/cluster/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -1678,7 +1678,7 @@ func (p *Provider) EnsureCheckAnywhereSubscription(ctx context.Context, c *v1.Cl
_ = wait.PollImmediate(15*time.Second, 10*time.Minute, func() (bool, error) {
for i, feed := range sub.Spec.Feeds {
var helmrelease *appsv1alpha1.HelmRelease
helmrelease, err = extenderapi.GetHelmRelease(hubClient, extenderapi.GenerateHelmReleaseName(sub.Name, feed.Namespace, feed.Name), mcls.Namespace)
helmrelease, err = extenderapi.GetHelmRelease(hubClient, extenderapi.GenerateHelmReleaseName(sub.Namespace, sub.Name, feed.Namespace, feed.Name), mcls.Namespace)
if err != nil {
if apierrors.IsNotFound(err) {
return false, nil
Expand Down
7 changes: 6 additions & 1 deletion pkg/util/extenderapi/extenderapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"

appsv1alpha1 "github.com/clusternet/apis/apps/v1alpha1"
clustersv1beta1 "github.com/clusternet/apis/clusters/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -83,7 +84,11 @@ func GetSubscription(clientSet client.Client, name, namespace string) (*appsv1al
return sub, nil
}

func GenerateHelmReleaseName(subName, componentNamespace, componentName string) string {
func GenerateHelmReleaseName(subNamespace, subName, componentNamespace, componentName string) string {
// clusternet v0.15 changed helmreleaes name rule, ref https://github.com/clusternet/clusternet/pull/681
if len(subNamespace) != 0 {
return fmt.Sprintf("%s-%s-helm-%s-%s", subNamespace, subName, componentNamespace, componentName)
}
return fmt.Sprintf("%s-helm-%s-%s", subName, componentNamespace, componentName)
}

Expand Down

0 comments on commit 4eca8b2

Please sign in to comment.