Skip to content

Conversation

Abirdcfly
Copy link
Contributor

@Abirdcfly Abirdcfly commented Jul 21, 2022

log.Fatal(err) in line 63 will call

func (entry *Entry) Fatal(args ...interface{}) {
entry.Log(FatalLevel, args...)
entry.Logger.Exit(1)
}

and entry.Logger.Exit(1) in line 327 will call

func (logger *Logger) Exit(code int) {
runHandlers()
if logger.ExitFunc == nil {
logger.ExitFunc = os.Exit
}
logger.ExitFunc(code)
}

and we don't set logger.ExitFunc. So just call os.Exit(1).

In fact, the README of the log library already points this out:

// Calls os.Exit(1) after logging
log.Fatal("Bye.")

The line 65 of code will not be executed regardless of the exit code set.

func main() {
if err := RootCmd.Execute(); err != nil {
log.Fatal(err)
os.Exit(1)
}
}

Signed-off-by: Abirdcfly <fp544037857@gmail.com>
@Abirdcfly Abirdcfly requested a review from a team as a code owner July 21, 2022 06:43
@Abirdcfly Abirdcfly requested a review from tklauser July 21, 2022 06:43
@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Jul 21, 2022
@tklauser tklauser added the release-note/misc This PR makes changes that have no direct user impact. label Jul 21, 2022
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Jul 21, 2022
@tklauser
Copy link
Member

/test-runtime

@tklauser
Copy link
Member

The Cilium docker plugin is only exercised in runtime tests. These passed and the change LGTM. Marking as ready to merge.

@tklauser tklauser added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Jul 21, 2022
@gandro gandro merged commit ecf378b into cilium:master Jul 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/misc This PR makes changes that have no direct user impact.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants