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

chore(backport release-1.1): fix(controller): prevent unsuccessful promo from blocking next promo #3054

Merged
merged 1 commit into from
Dec 4, 2024
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
513 changes: 226 additions & 287 deletions api/v1alpha1/generated.pb.go

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions api/v1alpha1/generated.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions api/v1alpha1/stage_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,6 @@ type Health struct {
// Issues clarifies why a Stage in any state other than Healthy is in that
// state. This field will always be the empty when a Stage is Healthy.
Issues []string `json:"issues,omitempty" protobuf:"bytes,2,rep,name=issues"`
// ArgoCDApps describes the current state of any related ArgoCD Applications.
ArgoCDApps []ArgoCDAppStatus `json:"argoCDApps,omitempty" protobuf:"bytes,3,rep,name=argoCDApps"`
// Config is the opaque configuration of all health checks performed on this
// Stage.
Config *apiextensionsv1.JSON `json:"config,omitempty" protobuf:"bytes,4,opt,name=config"`
Expand Down
7 changes: 0 additions & 7 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 0 additions & 43 deletions charts/kargo/resources/crds/kargo.akuity.io_stages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1101,49 +1101,6 @@ spec:
health:
description: Health is the Stage's last observed health.
properties:
argoCDApps:
description: ArgoCDApps describes the current state of any related
ArgoCD Applications.
items:
description: ArgoCDAppStatus describes the current state of
a single ArgoCD Application.
properties:
healthStatus:
description: HealthStatus is the health of the ArgoCD Application.
properties:
message:
type: string
status:
type: string
required:
- status
type: object
name:
description: Name is the name of the ArgoCD Application.
type: string
namespace:
description: Namespace is the namespace of the ArgoCD Application.
type: string
syncStatus:
description: SyncStatus is the sync status of the ArgoCD
Application.
properties:
revision:
type: string
revisions:
items:
type: string
type: array
status:
type: string
required:
- status
type: object
required:
- name
- namespace
type: object
type: array
config:
description: |-
Config is the opaque configuration of all health checks performed on this
Expand Down
10 changes: 7 additions & 3 deletions internal/controller/stages/regular_stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -707,14 +707,18 @@ func (r *RegularStageReconciler) assessHealth(ctx context.Context, stage *kargoa
// even if the current Promotion did not succeed (e.g. because it was
// aborted).
if lastPromo.Status.Phase != kargoapi.PromotionPhaseSucceeded {
logger.Debug("Last promotion did not succeed: no health checks to perform")
logger.Debug("Last promotion did not succeed: defaulting Stage health to Unhealthy")
conditions.Set(&newStatus, &metav1.Condition{
Type: kargoapi.ConditionTypeHealthy,
Status: metav1.ConditionUnknown,
Status: metav1.ConditionFalse,
Reason: fmt.Sprintf("LastPromotion%s", lastPromo.Status.Phase),
Message: "No health checks to perform for unsuccessful Promotion",
Message: "Last Promotion did not succeed",
ObservedGeneration: stage.Generation,
})
newStatus.Health = &kargoapi.Health{
Status: kargoapi.HealthStateUnhealthy,
Issues: []string{"Last Promotion did not succeed"},
}
return newStatus
}

Expand Down
8 changes: 5 additions & 3 deletions internal/controller/stages/regular_stages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1220,13 +1220,15 @@ func TestRegularStageReconciler_assessHealth(t *testing.T) {
},
},
assertions: func(t *testing.T, status kargoapi.StageStatus) {
assert.Nil(t, status.Health)
assert.NotNil(t, status.Health)
assert.Equal(t, kargoapi.HealthStateUnhealthy, status.Health.Status)
assert.Equal(t, []string{"Last Promotion did not succeed"}, status.Health.Issues)

healthyCond := conditions.Get(&status, kargoapi.ConditionTypeHealthy)
require.NotNil(t, healthyCond)
assert.Equal(t, metav1.ConditionUnknown, healthyCond.Status)
assert.Equal(t, metav1.ConditionFalse, healthyCond.Status)
assert.Equal(t, "LastPromotionAborted", healthyCond.Reason)
assert.Equal(t, "No health checks to perform for unsuccessful Promotion", healthyCond.Message)
assert.Equal(t, "Last Promotion did not succeed", healthyCond.Message)
},
},
{
Expand Down
58 changes: 0 additions & 58 deletions ui/src/gen/schema/stages.kargo.akuity.io_v1alpha1.json
Original file line number Diff line number Diff line change
Expand Up @@ -998,64 +998,6 @@
"health": {
"description": "Health is the Stage's last observed health.",
"properties": {
"argoCDApps": {
"description": "ArgoCDApps describes the current state of any related ArgoCD Applications.",
"items": {
"description": "ArgoCDAppStatus describes the current state of a single ArgoCD Application.",
"properties": {
"healthStatus": {
"description": "HealthStatus is the health of the ArgoCD Application.",
"properties": {
"message": {
"type": "string"
},
"status": {
"type": "string"
}
},
"required": [
"status"
],
"type": "object"
},
"name": {
"description": "Name is the name of the ArgoCD Application.",
"type": "string"
},
"namespace": {
"description": "Namespace is the namespace of the ArgoCD Application.",
"type": "string"
},
"syncStatus": {
"description": "SyncStatus is the sync status of the ArgoCD Application.",
"properties": {
"revision": {
"type": "string"
},
"revisions": {
"items": {
"type": "string"
},
"type": "array"
},
"status": {
"type": "string"
}
},
"required": [
"status"
],
"type": "object"
}
},
"required": [
"name",
"namespace"
],
"type": "object"
},
"type": "array"
},
"config": {
"description": "Config is the opaque configuration of all health checks performed on this\nStage.",
"x-kubernetes-preserve-unknown-fields": true
Expand Down
8 changes: 0 additions & 8 deletions ui/src/gen/v1alpha1/generated_pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1758,13 +1758,6 @@ export class Health extends Message<Health> {
*/
issues: string[] = [];

/**
* ArgoCDApps describes the current state of any related ArgoCD Applications.
*
* @generated from field: repeated github.com.akuity.kargo.api.v1alpha1.ArgoCDAppStatus argoCDApps = 3;
*/
argoCDApps: ArgoCDAppStatus[] = [];

/**
* Config is the opaque configuration of all health checks performed on this
* Stage.
Expand All @@ -1790,7 +1783,6 @@ export class Health extends Message<Health> {
static readonly fields: FieldList = proto2.util.newFieldList(() => [
{ no: 1, name: "status", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
{ no: 2, name: "issues", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true },
{ no: 3, name: "argoCDApps", kind: "message", T: ArgoCDAppStatus, repeated: true },
{ no: 4, name: "config", kind: "message", T: JSON, opt: true },
{ no: 5, name: "output", kind: "message", T: JSON, opt: true },
]);
Expand Down
Loading