Skip to content

Commit acf7594

Browse files
in case of failure, we want to update the error to latest run (#62)
* in case of failure, we want to update the error to latest run * add a test to validate the message update
1 parent 9871a1e commit acf7594

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

internal/ansible/controller/status/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func GetCondition(status Status, condType ConditionType) *Condition {
6767
// we are about to add already exists and has the same status and reason then we are not going to update.
6868
func SetCondition(status *Status, condition Condition) {
6969
currentCond := GetCondition(*status, condition.Type)
70-
if currentCond != nil && currentCond.Status == condition.Status && currentCond.Reason == condition.Reason {
70+
if currentCond != nil && condition.Type != FailureConditionType && currentCond.Status == condition.Status && currentCond.Reason == condition.Reason {
7171
return
7272
}
7373
// Do not update lastTransitionTime if the status of the condition doesn't change.

internal/ansible/controller/status/utils_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,24 @@ func TestSetCondition(t *testing.T) {
278278
keepLastTransitionTime: true,
279279
keepMessage: true,
280280
},
281+
{
282+
name: "on failure, always update error message",
283+
status: &Status{
284+
Conditions: []Condition{
285+
{
286+
Type: FailureConditionType,
287+
Status: v1.ConditionTrue,
288+
Reason: FailedReason,
289+
Message: "Previous failure",
290+
LastTransitionTime: lastTransitionTime,
291+
},
292+
},
293+
},
294+
condition: NewCondition(FailureConditionType, v1.ConditionTrue, nil, FailedReason, "New failure"),
295+
expectedNewSize: 1,
296+
keepLastTransitionTime: true,
297+
keepMessage: false,
298+
},
281299
}
282300

283301
for _, tc := range testCases {

0 commit comments

Comments
 (0)