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

Rephrasing the error message in case of continuous failure #1019

Closed
wants to merge 3 commits into from
Closed
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
12 changes: 9 additions & 3 deletions pkg/kapp/resourcesmisc/custom_waiting_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,16 @@ func (s CustomWaitingResource) IsDoneApplying() DoneApplyState {
}

if s.waitRule.Ytt != nil {
startTime, found := timeoutMap.Load(s.resource.Description())
if !found {
timeoutMap.Store(s.resource.Description(), time.Now().Unix())
}
configObj, err := WaitRuleContractV1{
ResourceMatcher: ctlres.AnyMatcher{
Matchers: ctlconf.ResourceMatchers(s.waitRule.ResourceMatchers).AsResourceMatchers()},
Starlark: s.waitRule.Ytt.FuncContractV1.Resource,
Starlark: s.waitRule.Ytt.FuncContractV1.Resource,
CurrentTime: time.Now().Unix(),
StartTime: startTime.(int64),
}.Apply(s.resource)
if err != nil {
return DoneApplyState{Done: true, Successful: false, Message: fmt.Sprintf(
Expand Down Expand Up @@ -99,8 +105,8 @@ func (s CustomWaitingResource) IsDoneApplying() DoneApplyState {
isTimeOutConditionPresent = true
if s.hasTimeoutOccurred(condMatcher.Timeout, s.resource.Description()) {
return DoneApplyState{Done: true, Successful: false, Message: fmt.Sprintf(
"Encountered failure condition %s == %s: %s (message: %s) continuously for %s duration",
cond.Type, condMatcher.Status, cond.Reason, cond.Message, condMatcher.Timeout)}
"continuously failed for %s with %s == %s: %s (message: %s)",
condMatcher.Timeout, cond.Type, condMatcher.Status, cond.Reason, cond.Message)}
}
return DoneApplyState{Done: false, Message: fmt.Sprintf(
"%s: %s (message: %s)",
Expand Down
3 changes: 3 additions & 0 deletions pkg/kapp/resourcesmisc/wait_rule_contract_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import (
type WaitRuleContractV1 struct {
ResourceMatcher ctlres.ResourceMatcher
Starlark string
CurrentTime int64
StartTime int64
}

type waitRuleContractV1Result struct {
Expand Down Expand Up @@ -48,6 +50,7 @@ func (t WaitRuleContractV1) evalYtt(res ctlres.Resource) (*WaitRuleContractV1Res
}
return yaml.Marshal(res.DeepCopyRaw())
}
opts.DataValuesFlags.KVsFromStrings = []string{fmt.Sprintf("startTime=%d", t.StartTime), fmt.Sprintf("currentTime=%d", t.CurrentTime)}

filesToProcess := []*files.File{
files.MustNewFileFromSource(files.NewBytesSource("resource.star", []byte(t.Starlark))),
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/wait_timeout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ waitRules:
RunOpts{IntoNs: true, AllowError: true, StdinReader: strings.NewReader(fmt.Sprintf(yaml2, "nginx:200"))})

require.Error(t, err)
require.Contains(t, err.Error(), "message: containers with unready status: [nginx]) continuously for 50s duration")
require.Contains(t, err.Error(), "Continuously failed for 50s with")
})

cleanUp()
Expand Down
Loading