Skip to content

Commit 50c8473

Browse files
committed
🌱 Use condition to mark false clusteraddon.yaml
Add a condition to mark an invalid clusteraddon.yaml. Also add an event. Signed-off-by: janiskemper <[email protected]>
1 parent 3dc37fb commit 50c8473

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

api/v1alpha1/conditions_const.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const (
3939

4040
const (
4141
// HelmChartFoundCondition reports when mentioned helm chart is present in the cluster addon tar archive.
42-
HelmChartFoundCondition = "HelmChartFound"
42+
HelmChartFoundCondition clusterv1.ConditionType = "HelmChartFound"
4343

4444
// HelmChartMissingReason is used when mentioned helm chart is missing in the cluster addon tar archive.
4545
HelmChartMissingReason = "HelmChartMissing"
@@ -62,6 +62,14 @@ const (
6262
TemplateNewClusterStackFailedReason = "TemplateNewClusterStackFailed"
6363
)
6464

65+
const (
66+
// ClusterAddonConfigValidatedCondition reports when there is a error parsing clusteraddon.yaml.
67+
ClusterAddonConfigValidatedCondition clusterv1.ConditionType = "ClusterAddonConfigValidated"
68+
69+
// ParsingClusterAddonConfigFailedReason is used when there's some error happen while parsing clusteraddon.yaml.
70+
ParsingClusterAddonConfigFailedReason = "ParsingClusterAddonConfigFailed"
71+
)
72+
6573
const (
6674
// HelmChartAppliedCondition reports on whether the relevant helm chart has been applied.
6775
HelmChartAppliedCondition clusterv1.ConditionType = "HelmChartApplied"
@@ -91,7 +99,7 @@ const (
9199

92100
const (
93101
// ProviderClusterStackReleasesSyncedCondition reports on whether the ProviderClusterStackReleases are ready.
94-
ProviderClusterStackReleasesSyncedCondition = "ProviderClusterStackReleasesSynced"
102+
ProviderClusterStackReleasesSyncedCondition clusterv1.ConditionType = "ProviderClusterStackReleasesSynced"
95103

96104
// ProviderTemplateNotFoundReason is used when providerTemplate is not found.
97105
ProviderTemplateNotFoundReason = "ProviderTemplateNotFound"
@@ -102,7 +110,7 @@ const (
102110

103111
const (
104112
// ClusterStackReleasesSyncedCondition reports on whether the ClusterStackReleases are ready.
105-
ClusterStackReleasesSyncedCondition = "ClusterStackReleasesSynced" //#nosec
113+
ClusterStackReleasesSyncedCondition clusterv1.ConditionType = "ClusterStackReleasesSynced" //#nosec
106114
)
107115

108116
const (

internal/controller/clusteraddon_controller.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,23 @@ func (r *ClusterAddonReconciler) Reconcile(ctx context.Context, req reconcile.Re
298298
// multi-stage cluster addon flow
299299
in.addonStagesInput, err = r.getAddonStagesInput(in.restConfig, in.clusterAddonChartPath)
300300
if err != nil {
301-
return reconcile.Result{}, fmt.Errorf("failed to get addon stages input: %w", err)
301+
conditions.MarkFalse(
302+
clusterAddon,
303+
csov1alpha1.ClusterAddonConfigValidatedCondition,
304+
csov1alpha1.ParsingClusterAddonConfigFailedReason,
305+
clusterv1.ConditionSeverityError,
306+
"cluster addon config (clusteraddon.yaml) is wrong: %s", err.Error(),
307+
)
308+
309+
record.Warnf(
310+
clusterAddon,
311+
csov1alpha1.ParsingClusterAddonConfigFailedReason,
312+
"cluster addon config (clusteraddon.yaml) is wrong: %s", err.Error(),
313+
)
314+
315+
return reconcile.Result{}, nil
302316
}
317+
conditions.MarkTrue(clusterAddon, csov1alpha1.ClusterAddonConfigValidatedCondition)
303318

304319
// clusteraddon.yaml in the release.
305320
clusterAddonConfig, err := clusteraddon.ParseConfig(in.clusterAddonConfigPath)

0 commit comments

Comments
 (0)