-
Notifications
You must be signed in to change notification settings - Fork 266
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
Refactor daemonset check #515
Conversation
cmd/daemonset-check-refactor/main.go
Outdated
// If there is a cancellation interrupt signal. | ||
log.Infoln("Canceling removing daemonset and daemonset pods and shutting down from interrupt.") | ||
return | ||
default: |
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.
wouldn't this always hit the default case? I think there are only three cases here -- your first three w/o default. Especially since you aren't using a for-loop over the select statement, it will just skip straight to the default case
cmd/daemonset-check-refactor/main.go
Outdated
log.Infoln("Worker: waitForPodRemoval started") | ||
defer close(outChan) | ||
outChan <- waitForPodRemoval() | ||
wg.Wait() |
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.
is wg.Done()
called?
cmd/daemonset-check-refactor/main.go
Outdated
log.Infoln("Received an interrupt signal from the signal channel.") | ||
log.Debugln("Signal received was:", sig.String()) | ||
|
||
go shutdown(doneChan) |
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 think it would be prudent to pass the context to this function and call the ctxCancel
func here -- most of your check run steps respect a ctx.Done()
which would return a result if the context was canceled
log.Infoln("Worker: waitForAllDaemonsetsToClear started") | ||
defer close(outChan) | ||
outChan <- waitForAllDaemonsetsToClear() | ||
wg.Wait() |
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.
same with the wg.Done()
here
go func() { | ||
defer close(outChanDS) | ||
outChanDS <- waitForDSRemoval() | ||
wg.Wait() |
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.
here too
Before we merge this to master, lets move the paths back to |
cmd/daemonset-check/run_check.go
Outdated
defer wg.Done() | ||
defer close(outChan) | ||
outChan <- waitForAllDaemonsetsToClear() | ||
wg.Wait() |
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 think this wg.Wait()
will always block here since you defer
d the wg.Done()
within the same function. wg.Wait()
is going to block until all wg.Done()
s are called, but since you defer it here, it would always be called after the wg.Wait()
I have the build as of ecf5d86 running locally without errors:
|
cmd/daemonset-check/main.go
Outdated
|
||
// daemonset does not exist, return false | ||
return false, nil | ||
os.Exit(0) |
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 think you might want to defer the os.Exit()
calls to allow shutdownCtxCancel()
to be called before the process exits since shutdownCtxCancel()
was deferred
} | ||
log.Infoln("Finished cleanup. No rogue daemonsets or daemonset pods exist") | ||
return nil | ||
} |
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.
instead of having a whole separate runCheckCleanup
function like before, we just use the remove
function to remove any daemonset created by the khcheck since there shouldn't be any left around. before there was a ton of logic to determine whether or not the daemonset was rogue but any daemonset left after a check run should be removed i believe
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.
this simplifies a LOT of the cleanUp stuff we were doing before
cmd/daemonset-check/main.go
Outdated
log.Infoln("Done running daemonset check") | ||
case <-signalChan: | ||
log.Infoln("Received shutdown signal. Canceling context and proceeding directly to cleanup.") | ||
reportOKToKuberhealthy() |
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.
added a reportOKToKuberhealthy
since if no report is made, kuberhealthy defaults the error to: Check execution error: kuberhealthy/daemonset: timed out waiting for checker pod to report in
. not sure if we want to report an error instead
No description provided.