Skip to content

Commit faac093

Browse files
committed
fixup! fix: Properly specify release name for CA addon
1 parent 69a1780 commit faac093

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

pkg/handlers/generic/lifecycle/addons/helmaddon.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ func NewHelmAddonApplier(
7676
}
7777

7878
type applyOptions struct {
79-
valueTemplater func(cluster *clusterv1.Cluster, valuesTemplate string) (string, error)
80-
targetCluster *clusterv1.Cluster
79+
valueTemplater func(cluster *clusterv1.Cluster, valuesTemplate string) (string, error)
80+
targetCluster *clusterv1.Cluster
81+
helmReleaseName string
8182
}
8283

8384
type applyOption func(*applyOptions)
@@ -100,6 +101,14 @@ func (a *helmAddonApplier) WithTargetCluster(cluster *clusterv1.Cluster) *helmAd
100101
return a
101102
}
102103

104+
func (a *helmAddonApplier) WithHelmReleaseName(name string) *helmAddonApplier {
105+
a.opts = append(a.opts, func(o *applyOptions) {
106+
o.helmReleaseName = name
107+
})
108+
109+
return a
110+
}
111+
103112
func (a *helmAddonApplier) Apply(
104113
ctx context.Context,
105114
cluster *clusterv1.Cluster,
@@ -145,6 +154,11 @@ func (a *helmAddonApplier) Apply(
145154
targetCluster = applyOpts.targetCluster
146155
}
147156

157+
helmReleaseName := a.config.defaultHelmReleaseName
158+
if applyOpts.helmReleaseName != "" {
159+
helmReleaseName = applyOpts.helmReleaseName
160+
}
161+
148162
chartProxy := &caaphv1.HelmChartProxy{
149163
TypeMeta: metav1.TypeMeta{
150164
APIVersion: caaphv1.GroupVersion.String(),
@@ -161,7 +175,7 @@ func (a *helmAddonApplier) Apply(
161175
MatchLabels: map[string]string{clusterv1.ClusterNameLabel: targetCluster.Name},
162176
},
163177
ReleaseNamespace: a.config.defaultHelmReleaseNamespace,
164-
ReleaseName: a.config.defaultHelmReleaseName,
178+
ReleaseName: helmReleaseName,
165179
Version: a.helmChart.Version,
166180
ValuesTemplate: values,
167181
},

pkg/handlers/generic/lifecycle/clusterautoscaler/handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
)
2525

2626
const (
27-
addonName = "cluster-autoscaler"
27+
addonName = "ca"
2828
)
2929

3030
type addonStrategy interface {

pkg/handlers/generic/lifecycle/clusterautoscaler/strategy_helmaddon.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ func (s helmAddonStrategy) apply(
6060
),
6161
s.client,
6262
s.helmChart,
63-
).WithTargetCluster(targetCluster).WithValueTemplater(templateValues)
63+
).
64+
WithTargetCluster(targetCluster).
65+
WithValueTemplater(templateValues).
66+
WithHelmReleaseName(addonResourceNameForCluster(cluster))
6467

6568
if err = applier.Apply(ctx, cluster, defaultsNamespace, log); err != nil {
6669
return fmt.Errorf("failed to apply cluster-autoscaler installation HelmChartProxy: %w", err)

test/e2e/clusterautoscaler_helpers.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/capi/utils"
2424
)
2525

26-
const clusterAutoscalerReleaseName = "cluster-autoscaler"
26+
const clusterAutoscalerReleaseName = "ca"
2727

2828
type WaitForClusterAutoscalerToBeReadyForWorkloadClusterInput struct {
2929
ClusterAutoscaler *v1alpha1.ClusterAutoscaler
@@ -110,8 +110,7 @@ func WaitForClusterAutoscalerToBeReadyForWorkloadCluster(
110110
ObjectMeta: metav1.ObjectMeta{
111111
Namespace: input.WorkloadCluster.Namespace,
112112
Name: fmt.Sprintf(
113-
"%s-%s",
114-
clusterAutoscalerReleaseName,
113+
"cluster-autoscaler-%s",
115114
input.WorkloadCluster.Annotations[v1alpha1.ClusterUUIDAnnotationKey],
116115
),
117116
},

0 commit comments

Comments
 (0)