Skip to content

Commit

Permalink
Merge pull request #252 from SovereignCloudStack/clusteraddonyaml-par…
Browse files Browse the repository at this point in the history
…sing-condition

🌱 Use condition to mark false clusteraddon.yaml
  • Loading branch information
janiskemper authored Sep 4, 2024
2 parents a45cc0d + ff1a51f commit e982769
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
14 changes: 11 additions & 3 deletions api/v1alpha1/conditions_const.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const (

const (
// HelmChartFoundCondition reports when mentioned helm chart is present in the cluster addon tar archive.
HelmChartFoundCondition = "HelmChartFound"
HelmChartFoundCondition clusterv1.ConditionType = "HelmChartFound"

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

const (
// ClusterAddonConfigValidatedCondition reports when there is a error parsing clusteraddon.yaml.
ClusterAddonConfigValidatedCondition clusterv1.ConditionType = "ClusterAddonConfigValidated"

// ParsingClusterAddonConfigFailedReason is used when there's some error happen while parsing clusteraddon.yaml.
ParsingClusterAddonConfigFailedReason = "ParsingClusterAddonConfigFailed"
)

const (
// HelmChartAppliedCondition reports on whether the relevant helm chart has been applied.
HelmChartAppliedCondition clusterv1.ConditionType = "HelmChartApplied"
Expand Down Expand Up @@ -91,7 +99,7 @@ const (

const (
// ProviderClusterStackReleasesSyncedCondition reports on whether the ProviderClusterStackReleases are ready.
ProviderClusterStackReleasesSyncedCondition = "ProviderClusterStackReleasesSynced"
ProviderClusterStackReleasesSyncedCondition clusterv1.ConditionType = "ProviderClusterStackReleasesSynced"

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

const (
// ClusterStackReleasesSyncedCondition reports on whether the ClusterStackReleases are ready.
ClusterStackReleasesSyncedCondition = "ClusterStackReleasesSynced" //#nosec
ClusterStackReleasesSyncedCondition clusterv1.ConditionType = "ClusterStackReleasesSynced" //#nosec
)

const (
Expand Down
17 changes: 16 additions & 1 deletion internal/controller/clusteraddon_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,23 @@ func (r *ClusterAddonReconciler) Reconcile(ctx context.Context, req reconcile.Re
// multi-stage cluster addon flow
in.addonStagesInput, err = r.getAddonStagesInput(in.restConfig, in.clusterAddonChartPath)
if err != nil {
return reconcile.Result{}, fmt.Errorf("failed to get addon stages input: %w", err)
conditions.MarkFalse(
clusterAddon,
csov1alpha1.ClusterAddonConfigValidatedCondition,
csov1alpha1.ParsingClusterAddonConfigFailedReason,
clusterv1.ConditionSeverityError,
"cluster addon config (clusteraddon.yaml) is wrong: %s", err.Error(),
)

record.Warnf(
clusterAddon,
csov1alpha1.ParsingClusterAddonConfigFailedReason,
"cluster addon config (clusteraddon.yaml) is wrong: %s", err.Error(),
)

return reconcile.Result{}, nil
}
conditions.MarkTrue(clusterAddon, csov1alpha1.ClusterAddonConfigValidatedCondition)

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

0 comments on commit e982769

Please sign in to comment.