Skip to content

Commit 201e62d

Browse files
committed
🌱 Remove status.currentHook from the cluster addon
Remove status.currentHook from the cluster addon Signed-off-by: janiskemper <[email protected]>
1 parent 6d68147 commit 201e62d

File tree

4 files changed

+15
-18
lines changed

4 files changed

+15
-18
lines changed

api/v1alpha1/clusteraddon_types.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,6 @@ type ClusterAddonStatus struct {
6464
// +optional
6565
Resources []*Resource `json:"resources,omitempty"`
6666

67-
// CurrentHook specifies the current running Hook.
68-
// +optional
69-
CurrentHook string `json:"currentHook,omitempty"`
70-
7167
// HelmChartStatus defines the status of helm chart in the cluster addon.
7268
// +optional
7369
HelmChartStatus map[string]HelmChartStatusConditions `json:"helmChartStatus,omitempty"`
@@ -84,6 +80,7 @@ type ClusterAddonStatus struct {
8480
// +kubebuilder:object:root=true
8581
// +kubebuilder:subresource:status
8682
// +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".metadata.ownerReferences[?(@.kind==\"Cluster\")].name"
83+
// +kubebuilder:printcolumn:name="Hook",type="string",JSONPath=".spec.hook",description="Present running hook"
8784
// +kubebuilder:printcolumn:name="Ready",type="boolean",JSONPath=".status.ready"
8885
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of Cluster Addon"
8986
// +kubebuilder:printcolumn:name="Reason",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].reason"

config/crd/bases/clusterstack.x-k8s.io_clusteraddons.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ spec:
2020
- jsonPath: .metadata.ownerReferences[?(@.kind=="Cluster")].name
2121
name: Cluster
2222
type: string
23+
- description: Present running hook
24+
jsonPath: .spec.hook
25+
name: Hook
26+
type: string
2327
- jsonPath: .status.ready
2428
name: Ready
2529
type: boolean
@@ -168,9 +172,6 @@ spec:
168172
- type
169173
type: object
170174
type: array
171-
currentHook:
172-
description: CurrentHook specifies the current running Hook.
173-
type: string
174175
helmChartStatus:
175176
additionalProperties:
176177
description: HelmChartStatusConditions defines the status of helm

internal/controller/clusteraddon_controller.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,10 @@ func (r *ClusterAddonReconciler) Reconcile(ctx context.Context, req reconcile.Re
303303
}
304304
}
305305

306-
if clusterAddon.Spec.Hook != clusterAddon.Status.CurrentHook {
306+
// if a hook is specified, we cannot be ready yet
307+
// if a hook is set, it is expected that HelmChartAppliedCondition is removed
308+
if clusterAddon.Spec.Hook != "" {
307309
clusterAddon.Status.HelmChartStatus = make(map[string]csov1alpha1.HelmChartStatusConditions)
308-
clusterAddon.Status.CurrentHook = clusterAddon.Spec.Hook
309310
clusterAddon.Status.Ready = false
310311
}
311312

@@ -314,7 +315,6 @@ func (r *ClusterAddonReconciler) Reconcile(ctx context.Context, req reconcile.Re
314315
if clusterAddon.Spec.ClusterStack != cluster.Spec.Topology.Class && oldRelease.Meta.Versions.Kubernetes == releaseAsset.Meta.Versions.Kubernetes {
315316
if clusterAddon.Spec.Version != releaseAsset.Meta.Versions.Components.ClusterAddon {
316317
clusterAddon.Status.HelmChartStatus = make(map[string]csov1alpha1.HelmChartStatusConditions)
317-
clusterAddon.Status.CurrentHook = clusterAddon.Spec.Hook
318318
clusterAddon.Status.Ready = false
319319
conditions.Delete(clusterAddon, csov1alpha1.HelmChartAppliedCondition)
320320
} else {
@@ -396,8 +396,8 @@ func (r *ClusterAddonReconciler) Reconcile(ctx context.Context, req reconcile.Re
396396
// remove the status resource if hook is finished
397397
clusterAddon.Status.Resources = make([]*csov1alpha1.Resource, 0)
398398

399-
// set the current hook and make cluster addon ready
400-
clusterAddon.Status.CurrentHook = clusterAddon.Spec.Hook
399+
// unset spec hook and make cluster addon ready
400+
clusterAddon.Spec.Hook = ""
401401
clusterAddon.Status.Ready = true
402402
}
403403

@@ -718,11 +718,11 @@ func (r *ClusterAddonReconciler) templateAndApplyNewClusterStackAddonHelmChart(c
718718
if err != nil {
719719
return false, fmt.Errorf("failed to build template from old cluster addon values: %w", err)
720720
}
721-
}
722721

723-
oldHelmTemplate, err = helmTemplateClusterAddon(oldClusterStackSubDirPath, oldBuildTemplate)
724-
if err != nil {
725-
return false, fmt.Errorf("failed to template old helm chart: %w", err)
722+
oldHelmTemplate, err = helmTemplateClusterAddon(oldClusterStackSubDirPath, oldBuildTemplate)
723+
if err != nil {
724+
return false, fmt.Errorf("failed to template old helm chart: %w", err)
725+
}
726726
}
727727
}
728728

internal/test/integration/workloadcluster/cluster_addon_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,8 +493,7 @@ var _ = Describe("ClusterAddonReconcilerNewWay", func() {
493493
return false
494494
}
495495

496-
return utils.IsPresentAndTrue(ctx, testEnv.Client, key, &foundClusterAddon, clusterv1.ReadyCondition) &&
497-
foundClusterAddon.Status.CurrentHook == "AfterControlPlaneInitialized"
496+
return utils.IsPresentAndTrue(ctx, testEnv.Client, key, &foundClusterAddon, clusterv1.ReadyCondition)
498497
}, timeout, interval).Should(BeTrue())
499498
})
500499
})

0 commit comments

Comments
 (0)