Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Commit

Permalink
Merge pull request #173 from suhanime/logToStdOut
Browse files Browse the repository at this point in the history
Bug 1818026: Redirect WMCB info logs to stdout
  • Loading branch information
openshift-merge-robot authored May 8, 2020
2 parents 6597be5 + e3407c5 commit 2c6f007
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion cmd/bootstrapper/configure_cni.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ func runConfigureCNICmd(cmd *cobra.Command, args []string) {
log.Error(err, "could not configure CNI")
os.Exit(1)
}
log.Info("CNI configuration completed successfully")
// Send success message to StdOut for WSU to ascertain that CNI configuration was successful
os.Stdout.WriteString("CNI configuration completed successfully")

err = wmcb.Disconnect()
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion cmd/bootstrapper/initialize_kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ func runInitializeKubeletCmd(cmd *cobra.Command, args []string) {
log.Error(err, "could not run bootstrapper")
os.Exit(1)
} else {
log.Info("Bootstrapping completed successfully")
// Send success message to StdOut for WSU to ascertain that bootstrapping was successful
os.Stdout.WriteString("Bootstrapping completed successfully")
}

err = wmcb.Disconnect()
Expand Down
5 changes: 5 additions & 0 deletions cmd/bootstrapper/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ var (

func init() {
rootCmd.PersistentFlags().AddGoFlagSet(flag.CommandLine)
// Controller-runtime's zap package redirects logs to StdErr by default. Functionality to set up the destination of
// logs would require bumping up the version of controller-runtime to at least 0.4.0, which is dependent on
// https://issues.redhat.com/browse/WINC-347
// Here we set up the logger that sends logs to StdErr. Info level logs should be bubbled up to StdOut instead
// WMCO interprets logs in StdErr as an indication that bootstrapping failed
logger.SetLogger(zap.New())
}

Expand Down
4 changes: 2 additions & 2 deletions tools/ansible/tasks/wsu/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@
- name: Check if bootstrap was successful
fail:
msg: "Bootstrapper error"
when: '"Bootstrapping completed successfully" not in bootstrap_out.stderr'
when: '"Bootstrapping completed successfully" not in bootstrap_out.stdout'

# Making a best effort to approve CSRs. Not failing until the actual `get node` call, in case the CSRs were approved elsewhere
- name: Approve CSRs
Expand Down Expand Up @@ -428,7 +428,7 @@
- name: Check if CNI configuration was successful
fail:
msg: "CNI Configuration error"
when: '"CNI configuration completed successfully" not in bootstrap_out.stderr'
when: '"CNI configuration completed successfully" not in bootstrap_out.stdout'

- name: Ensure kube-proxy Windows Service is not running
win_service:
Expand Down

0 comments on commit 2c6f007

Please sign in to comment.