-
Notifications
You must be signed in to change notification settings - Fork 648
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: ensure flux check
returns non-zero exit code on failure
#5267
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: h3nryc0ding <[email protected]>
for _, id := range identifiers { | ||
rs := coll.ResourceStatuses[id] | ||
switch rs.Status { | ||
case status.CurrentStatus: | ||
sc.logger.Successf("%s: %s ready", rs.Identifier.Name, strings.ToLower(rs.Identifier.GroupKind.Kind)) | ||
case status.NotFoundStatus: | ||
sc.logger.Failuref("%s: %s not found", rs.Identifier.Name, strings.ToLower(rs.Identifier.GroupKind.Kind)) | ||
errMsg := fmt.Sprintf("%s: %s not found", rs.Identifier.Name, strings.ToLower(rs.Identifier.GroupKind.Kind)) | ||
sc.logger.Failuref(errMsg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what's gonna happen now that we both log and return the error, would we see the error printed twice? Can you please test that? Maybe we need to remove the log.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StatusChecker.Assess
is used in three places with inconsistent error handling:
-
check.go
Lines 215 to 217 in f0fecf7
if err := statusChecker.Assess(ref...); err != nil { ok = false } - Does not use the error
-
install.go
Lines 279 to 281 in f0fecf7
if err := statusChecker.Assess(componentRefs...); err != nil { return fmt.Errorf("install failed") } - Uses the error
-
bootstrap_plain_git.go
flux2/pkg/bootstrap/bootstrap_plain_git.go
Lines 492 to 494 in f0fecf7
if err := checker.Assess(identifiers...); err != nil { return err } - Uses the error
This means either:
- At least one of the locations logs the error twice, or
check.go
is missing necessary logging or needs refactoring
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah maybe we need some refactoring here... We're busy preparing for KubeCon EU next week, can you please ping us again after KubeCon? Thanks 🙏
Fixes #5220 by returning a non-zero exist code for failed checks.