This repository has been archived by the owner on Oct 22, 2021. It is now read-only.
Many Cloud Foundry drain scripts do not work in KubeCF due to no monit and no bpm #1728
Labels
Type: Bug
Something isn't working
Describe the bug
After recent fixes were completed in quarks to properly call drain scripts with the right lifecycle, it has now been discovered that many of these drain scripts do not work because their logic has dependencies upon monit or bpm.
For example some drain scripts are looking for the PID file for the job they're trying to drain, and that PID file is written by monit or bpm in a BOSH environment but is missing in KubeCF. Or some drain scripts are trying to use bpm commands to control the drain/stop of the jobs but the bpm command is missing.
Some specific examples are:
rep (Diego-cell):
https://github.com/cloudfoundry/diego-release/blob/master/jobs/rep/templates/drain.erb#L49-L53
The above code causes the rep drain script to immediately end with "rep process not running" because bpm is missing and therefore
/var/vcap/jobs/bpm/bin/bpm
is missing.GoRouter:
https://github.com/cloudfoundry/routing-release/blob/develop/jobs/gorouter/templates/drain.erb#L11-L20
The above code causes the gorouter drain script to immediately end because there is no pidfile at
/var/vcap/sys/run/bpm/gorouter/gorouter.pid
and so this logic immediately exits, causing significant disruption because all inflight gorouter requests are unable to complete through a graceful drain/quiesce.Perhaps on this example it would be a relatively simple thing to have a PID file written, so that this logic proceeds as it would do in BOSH.
Auctioneer:
https://github.com/cloudfoundry/diego-release/blob/develop/jobs/auctioneer/templates/drain.erb#L6
In this case it's a simple bpm stop, but even that doesn't work because bpm is missing. The bpm stop behavior is to send a SIGTERM and then wait 15 seconds (
https://github.com/cloudfoundry/bpm-release/blob/master/src/bpm/commands/stop.go#L27
) and the KILL the container. Although the Kubernetes container shutdown behaves similarly instead, it isn't identical. The Kubernetes container shutdown will also trigger SIGTERM but then it will wait for terminateGracePeriodSeconds which is set at the pod scope, not at an individual container. And in many case it will have to be a lot higher than 15 seconds. Nevertheless in most practical situations I think a simple bpm stop (like auctioneer has) will work in the same way in KubeCF if the terminationGracePeriodSeconds has been set to 15 or more seconds on the pod. https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-terminationCloud Controller:
https://github.com/cloudfoundry/capi-release/blob/develop/jobs/cloud_controller_ng/templates/drain.sh.erb
In this case it's partially similar to the auctioneer in that it's using bpm stop for the local worker processes. But the standard Kubernetes behavior will not be the same this time because this script is stopping different processes in a specific sequence that Kubernetes would not do. Specifically this drain script is stopping the local worker processes one by one in the for loop.
Then, also very importantly, it's triggering a custom drain script for the main cloud controller: https://github.com/cloudfoundry/capi-release/blob/develop/jobs/cloud_controller_ng/templates/shutdown_drain.rb.erb and this is critical for the Cloud Controller to gracefully quiesce its work.
It seems therefore that a replacement drain script will be needed here that accomplishes those key differences of (i) sequentially stopping the local workers first, (ii) running the custom drain script shutdown_drain
Cloud Controller Worker
https://github.com/cloudfoundry/capi-release/blob/develop/jobs/cloud_controller_worker/templates/drain.sh.erb
This one is a simpler equivalent to the Cloud Controller one in that it only has the sequential stop behavior that is needed, but no custom drain beyond that.
To Reproduce
Deploy KubeCF with terminationGracePeriodSeconds set sufficiently high that drains should have time to work. Then delete pods and watch the various drains fail. In flight workloads will see disruption as a result.
Expected behavior
Drains should behave the same as in BOSH
Environment
Additional context
Quarks Operator fix that corrected drain lifecycle cloudfoundry-incubator/quarks-operator#1302
The text was updated successfully, but these errors were encountered: