Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(plugins): rename NoHelmChartTestFailuresCondition to HelmChartTestSucceededCondition #748

Merged
merged 16 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion docs/reference/api/openapi.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
openapi: 3.0.0
info:
title: Greenhouse
version: 89f438b
version: 60a2c5f
description: PlusOne operations platform
paths:
/TeamMembership:
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/greenhouse/v1alpha1/plugin_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ const (
// StatusUpToDateCondition reflects the failed reconciliation of the Plugin.
StatusUpToDateCondition ConditionType = "StatusUpToDate"

// NoHelmChartTestFailuresCondition reflects the status of the HelmChart tests.
NoHelmChartTestFailuresCondition ConditionType = "NoHelmChartTestFailures"
// HelmChartTestSucceededCondition reflects the status of the HelmChart tests.
HelmChartTestSucceededCondition ConditionType = "HelmChartTestSucceeded"

// PluginDefinitionNotFoundReason is set when the pluginDefinition is not found.
PluginDefinitionNotFoundReason ConditionReason = "PluginDefinitionNotFound"
Expand Down
16 changes: 8 additions & 8 deletions pkg/controllers/plugin/helm_chart_test_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ func (r *HelmChartTestReconciler) Reconcile(ctx context.Context, req ctrl.Reques

pluginStatus := initPluginStatus(plugin)

noHelmChartTestFailuresCondition := *pluginStatus.GetConditionByType(greenhousev1alpha1.NoHelmChartTestFailuresCondition)
HelmChartTestSucceededCondition := *pluginStatus.GetConditionByType(greenhousev1alpha1.HelmChartTestSucceededCondition)
ibakshay marked this conversation as resolved.
Show resolved Hide resolved

defer func() {
_, err := clientutil.PatchStatus(ctx, r.Client, plugin, func() error {
plugin.Status.StatusConditions.SetConditions(noHelmChartTestFailuresCondition)
plugin.Status.StatusConditions.SetConditions(HelmChartTestSucceededCondition)
return nil
})
if err != nil {
Expand Down Expand Up @@ -119,12 +119,12 @@ func (r *HelmChartTestReconciler) Reconcile(ctx context.Context, req ctrl.Reques
"namespace": plugin.Namespace,
}
if err != nil {
noHelmChartTestFailuresCondition.Status = metav1.ConditionFalse
HelmChartTestSucceededCondition.Status = metav1.ConditionFalse
errStr := fmt.Sprintf("Helm Chart testing failed: %s. To debug, please run `helm test %s`command in your remote cluster %s.", err.Error(), plugin.Name, plugin.Spec.ClusterName)
errStr = strings.ReplaceAll(errStr, "\n", "")
errStr = strings.ReplaceAll(errStr, "\t", " ")
errStr = strings.ReplaceAll(errStr, "*", "")
noHelmChartTestFailuresCondition.Message = errStr
HelmChartTestSucceededCondition.Message = errStr

prometheusLabels["result"] = "Error"
chartTestRunsTotal.With(prometheusLabels).Inc()
Expand All @@ -133,14 +133,14 @@ func (r *HelmChartTestReconciler) Reconcile(ctx context.Context, req ctrl.Reques
}

if !hasHelmChartTest {
noHelmChartTestFailuresCondition.Status = metav1.ConditionTrue
noHelmChartTestFailuresCondition.Message = "No Helm Chart Tests defined by the PluginDefinition"
HelmChartTestSucceededCondition.Status = metav1.ConditionTrue
HelmChartTestSucceededCondition.Message = "No Helm Chart Tests defined by the PluginDefinition"

prometheusLabels["result"] = "NoTests"
chartTestRunsTotal.With(prometheusLabels).Inc()
} else {
noHelmChartTestFailuresCondition.Status = metav1.ConditionTrue
noHelmChartTestFailuresCondition.Message = "Helm Chart Test is successful"
HelmChartTestSucceededCondition.Status = metav1.ConditionTrue
HelmChartTestSucceededCondition.Message = "Helm Chart Test is successful"

prometheusLabels["result"] = "Success"
chartTestRunsTotal.With(prometheusLabels).Inc()
Expand Down
4 changes: 2 additions & 2 deletions pkg/controllers/plugin/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var exposedConditions = []greenhousev1alpha1.ConditionType{
greenhousev1alpha1.HelmDriftDetectedCondition,
greenhousev1alpha1.HelmReconcileFailedCondition,
greenhousev1alpha1.StatusUpToDateCondition,
greenhousev1alpha1.NoHelmChartTestFailuresCondition,
greenhousev1alpha1.HelmChartTestSucceededCondition,
greenhousev1alpha1.WorkloadReadyCondition,
}

Expand Down Expand Up @@ -272,7 +272,7 @@ func computeReadyCondition(
readyCondition.Message = "Helm reconcile failed"
return readyCondition
}
if conditions.GetConditionByType(greenhousev1alpha1.NoHelmChartTestFailuresCondition).IsFalse() {
if conditions.GetConditionByType(greenhousev1alpha1.HelmChartTestSucceededCondition).IsFalse() {
readyCondition.Status = metav1.ConditionFalse
readyCondition.Message = "Helm Chart Test failed"
return readyCondition
Expand Down