Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions api/v1alpha1/clusteraddon_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ type ClusterAddonStatus struct {
// +optional
Resources []*Resource `json:"resources,omitempty"`

// CurrentHook specifies the current running Hook.
// +optional
CurrentHook string `json:"currentHook,omitempty"`

// HelmChartStatus defines the status of helm chart in the cluster addon.
// +optional
HelmChartStatus map[string]HelmChartStatusConditions `json:"helmChartStatus,omitempty"`
Expand All @@ -84,6 +80,7 @@ type ClusterAddonStatus struct {
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".metadata.ownerReferences[?(@.kind==\"Cluster\")].name"
// +kubebuilder:printcolumn:name="Hook",type="string",JSONPath=".spec.hook",description="Present running hook"
// +kubebuilder:printcolumn:name="Ready",type="boolean",JSONPath=".status.ready"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of Cluster Addon"
// +kubebuilder:printcolumn:name="Reason",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].reason"
Expand Down
7 changes: 4 additions & 3 deletions config/crd/bases/clusterstack.x-k8s.io_clusteraddons.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ spec:
- jsonPath: .metadata.ownerReferences[?(@.kind=="Cluster")].name
name: Cluster
type: string
- description: Present running hook
jsonPath: .spec.hook
name: Hook
type: string
- jsonPath: .status.ready
name: Ready
type: boolean
Expand Down Expand Up @@ -155,9 +159,6 @@ spec:
- type
type: object
type: array
currentHook:
description: CurrentHook specifies the current running Hook.
type: string
helmChartStatus:
additionalProperties:
description: HelmChartStatusConditions defines the status of helm
Expand Down
20 changes: 10 additions & 10 deletions internal/controller/clusteraddon_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,10 @@ func (r *ClusterAddonReconciler) Reconcile(ctx context.Context, req reconcile.Re
}
}

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

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

// set the current hook and make cluster addon ready
clusterAddon.Status.CurrentHook = clusterAddon.Spec.Hook
// unset spec hook and make cluster addon ready
clusterAddon.Spec.Hook = ""
clusterAddon.Status.Ready = true
}

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

oldHelmTemplate, err = helmTemplateClusterAddon(oldClusterStackSubDirPath, oldBuildTemplate)
if err != nil {
return false, fmt.Errorf("failed to template old helm chart: %w", err)
oldHelmTemplate, err = helmTemplateClusterAddon(oldClusterStackSubDirPath, oldBuildTemplate)
if err != nil {
return false, fmt.Errorf("failed to template old helm chart: %w", err)
}
}
}

Expand Down Expand Up @@ -807,7 +807,7 @@ func helmTemplateAndDelete(ctx context.Context, in templateAndApplyClusterAddonI
}

func getDynamicResourceAndEvaluateCEL(ctx context.Context, dynamicClient *dynamic.DynamicClient, discoveryClient *discovery.DiscoveryClient, waitCondition clusteraddon.WaitForCondition) error {
var evalMap = make(map[string]interface{})
evalMap := make(map[string]interface{})

env, err := cel.NewEnv()
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,7 @@ var _ = Describe("ClusterAddonReconcilerNewWay", func() {
return false
}

return utils.IsPresentAndTrue(ctx, testEnv.Client, key, &foundClusterAddon, clusterv1.ReadyCondition) &&
foundClusterAddon.Status.CurrentHook == "AfterControlPlaneInitialized"
return utils.IsPresentAndTrue(ctx, testEnv.Client, key, &foundClusterAddon, clusterv1.ReadyCondition)
}, timeout, interval).Should(BeTrue())
})
})
Expand Down