From 9bd3f56cfc5e2f5820660425b9c8430d42e96ec7 Mon Sep 17 00:00:00 2001 From: Edmund Ochieng Date: Tue, 19 Sep 2023 16:19:39 -0500 Subject: [PATCH 1/2] Clean up the slice of conditions Signed-off-by: Edmund Ochieng --- .../ansible/controller/status/utils_test.go | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/ansible/controller/status/utils_test.go b/internal/ansible/controller/status/utils_test.go index 1671dc1..334f086 100644 --- a/internal/ansible/controller/status/utils_test.go +++ b/internal/ansible/controller/status/utils_test.go @@ -96,7 +96,7 @@ func TestGetCondition(t *testing.T) { condType: RunningConditionType, status: Status{ Conditions: []Condition{ - Condition{ + { Type: RunningConditionType, }, }, @@ -110,7 +110,7 @@ func TestGetCondition(t *testing.T) { condType: RunningConditionType, status: Status{ Conditions: []Condition{ - Condition{ + { Type: FailureConditionType, }, }, @@ -122,7 +122,7 @@ func TestGetCondition(t *testing.T) { condType: FailureConditionType, status: Status{ Conditions: []Condition{ - Condition{ + { Type: FailureConditionType, }, }, @@ -136,7 +136,7 @@ func TestGetCondition(t *testing.T) { condType: FailureConditionType, status: Status{ Conditions: []Condition{ - Condition{ + { Type: RunningConditionType, }, }, @@ -167,7 +167,7 @@ func TestRemoveCondition(t *testing.T) { condType: RunningConditionType, status: Status{ Conditions: []Condition{ - Condition{ + { Type: RunningConditionType, }, }, @@ -179,7 +179,7 @@ func TestRemoveCondition(t *testing.T) { condType: RunningConditionType, status: Status{ Conditions: []Condition{ - Condition{ + { Type: FailureConditionType, }, }, @@ -191,7 +191,7 @@ func TestRemoveCondition(t *testing.T) { condType: FailureConditionType, status: Status{ Conditions: []Condition{ - Condition{ + { Type: FailureConditionType, }, }, @@ -203,7 +203,7 @@ func TestRemoveCondition(t *testing.T) { condType: FailureConditionType, status: Status{ Conditions: []Condition{ - Condition{ + { Type: RunningConditionType, }, }, @@ -247,7 +247,7 @@ func TestSetCondition(t *testing.T) { name: "update running condition", status: &Status{ Conditions: []Condition{ - Condition{ + { Type: RunningConditionType, Status: v1.ConditionTrue, Reason: SuccessfulReason, @@ -264,7 +264,7 @@ func TestSetCondition(t *testing.T) { name: "do not update running condition", status: &Status{ Conditions: []Condition{ - Condition{ + { Type: RunningConditionType, Status: v1.ConditionTrue, Reason: RunningReason, From b2735c84c2fde07c2905f0b5d8eb510e23a6a8db Mon Sep 17 00:00:00 2001 From: Edmund Ochieng Date: Thu, 21 Sep 2023 13:27:47 -0500 Subject: [PATCH 2/2] Remove code to reset previous error while reconciling custom resource Previous failure condition status is set to false when subsequent reconcile begins. This is unnecessary since the conditions are true at the time of reporting. The failure condition can however, be reset when reconcile completes successfully. Signed-off-by: Edmund Ochieng --- internal/ansible/controller/reconcile.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/internal/ansible/controller/reconcile.go b/internal/ansible/controller/reconcile.go index 0919f33..9052c2a 100644 --- a/internal/ansible/controller/reconcile.go +++ b/internal/ansible/controller/reconcile.go @@ -302,11 +302,6 @@ func (r *AnsibleOperatorReconciler) markRunning(ctx context.Context, nn types.Na crStatus := getStatus(u) // If there is no current status add that we are working on this resource. - errCond := ansiblestatus.GetCondition(crStatus, ansiblestatus.FailureConditionType) - if errCond != nil { - errCond.Status = v1.ConditionFalse - ansiblestatus.SetCondition(&crStatus, *errCond) - } successCond := ansiblestatus.GetCondition(crStatus, ansiblestatus.SuccessfulConditionType) if successCond != nil { successCond.Status = v1.ConditionFalse