Skip to content
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

Enhancement freeze logic #180

Merged
merged 5 commits into from
Oct 31, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ start:
--machine-set-scale-timeout=20 \
--machine-safety-orphan-vms-period=30 \
--machine-safety-overshooting-period=1 \
--machine-safety-apiserver-period=1m \
prashanth26 marked this conversation as resolved.
Show resolved Hide resolved
--machine-safety-apiserver-timeout=30s \
--v=2

#################################################################
Expand Down
19 changes: 12 additions & 7 deletions cmd/machine-controller-manager/app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,15 @@ func NewMCMServer() *MCMServer {
LeaderElection: leaderelectionconfig.DefaultLeaderElectionConfiguration(),
ControllerStartInterval: metav1.Duration{Duration: 0 * time.Second},
SafetyOptions: machineconfig.SafetyOptions{
SafetyUp: 2,
SafetyDown: 1,
MachineHealthTimeout: 10,
MachineDrainTimeout: 5,
MachineSetScaleTimeout: 20,
MachineSafetyOrphanVMsPeriod: 30,
MachineSafetyOvershootingPeriod: 1,
SafetyUp: 2,
SafetyDown: 1,
MachineHealthTimeout: 10,
MachineDrainTimeout: 5,
MachineSetScaleTimeout: 20,
MachineSafetyOrphanVMsPeriod: 30,
MachineSafetyOvershootingPeriod: 1,
MachineSafetyAPIServerStatusPeriod: metav1.Duration{Duration: 1 * time.Minute},
MachineSafetyAPIServerStatusTimeout: metav1.Duration{Duration: 30 * time.Second},
},
},
}
Expand Down Expand Up @@ -100,6 +102,9 @@ func (s *MCMServer) AddFlags(fs *pflag.FlagSet) {
fs.Int32Var(&s.SafetyOptions.MachineSafetyOrphanVMsPeriod, "machine-safety-orphan-vms-period", s.SafetyOptions.MachineSafetyOrphanVMsPeriod, "Time period (in minutes) used to poll for orphan VMs by safety controller.")
fs.Int32Var(&s.SafetyOptions.MachineSafetyOvershootingPeriod, "machine-safety-overshooting-period", s.SafetyOptions.MachineSafetyOvershootingPeriod, "Time period (in minutes) used to poll for overshooting of machine objects backing a machineSet by safety controller.")

fs.DurationVar(&s.SafetyOptions.MachineSafetyAPIServerStatusTimeout.Duration, "machine-safety-apiserver-timeout", s.SafetyOptions.MachineSafetyAPIServerStatusTimeout.Duration, "Timeout (in duration) for which the APIServer can be down before declare the machine controller frozen by safety controller")
fs.DurationVar(&s.SafetyOptions.MachineSafetyAPIServerStatusPeriod.Duration, "machine-safety-apiserver-period", s.SafetyOptions.MachineSafetyAPIServerStatusPeriod.Duration, "Period (in duration) used to poll for APIServer's health by safety controller")
prashanth26 marked this conversation as resolved.
Show resolved Hide resolved

leaderelectionconfig.BindFlags(&s.LeaderElection, fs)
// TODO: DefaultFeatureGate is global and it adds all k8s flags
// utilfeature.DefaultFeatureGate.AddFlag(fs)
Expand Down
5 changes: 5 additions & 0 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ func NewController(
machineDeploymentQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "machinedeployment"),
machineSafetyOrphanVMsQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "machinesafetyorphanvms"),
machineSafetyOvershootingQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "machinesafetyovershooting"),
machineSafetyAPIServerQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "machinesafetyapiserver"),
safetyOptions: safetyOptions,
}

Expand Down Expand Up @@ -334,6 +335,7 @@ func NewController(
// running of different safety loop on MCM startup.
controller.machineSafetyOrphanVMsQueue.Add("")
controller.machineSafetyOvershootingQueue.Add("")
controller.machineSafetyAPIServerQueue.Add("")

machineInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
// addMachineToSafety makes sure machine objects does not overshoot
Expand Down Expand Up @@ -397,6 +399,7 @@ type controller struct {
machineDeploymentQueue workqueue.RateLimitingInterface
machineSafetyOrphanVMsQueue workqueue.RateLimitingInterface
machineSafetyOvershootingQueue workqueue.RateLimitingInterface
machineSafetyAPIServerQueue workqueue.RateLimitingInterface
// syncs
secretSynced cache.InformerSynced
nodeSynced cache.InformerSynced
Expand Down Expand Up @@ -429,6 +432,7 @@ func (c *controller) Run(workers int, stopCh <-chan struct{}) {
defer c.machineDeploymentQueue.ShutDown()
defer c.machineSafetyOrphanVMsQueue.ShutDown()
defer c.machineSafetyOvershootingQueue.ShutDown()
defer c.machineSafetyAPIServerQueue.ShutDown()

if !cache.WaitForCacheSync(stopCh, c.secretSynced, c.nodeSynced, c.openStackMachineClassSynced, c.awsMachineClassSynced, c.azureMachineClassSynced, c.gcpMachineClassSynced, c.alicloudMachineClassSynced, c.machineSynced, c.machineSetSynced, c.machineDeploymentSynced) {
runtimeutil.HandleError(fmt.Errorf("Timed out waiting for caches to sync"))
Expand Down Expand Up @@ -457,6 +461,7 @@ func (c *controller) Run(workers int, stopCh <-chan struct{}) {
createWorker(c.machineDeploymentQueue, "ClusterMachineDeployment", maxRetries, true, c.reconcileClusterMachineDeployment, stopCh, &waitGroup)
createWorker(c.machineSafetyOrphanVMsQueue, "ClusterMachineSafetyOrphanVMs", maxRetries, true, c.reconcileClusterMachineSafetyOrphanVMs, stopCh, &waitGroup)
createWorker(c.machineSafetyOvershootingQueue, "ClusterMachineSafetyOvershooting", maxRetries, true, c.reconcileClusterMachineSafetyOvershooting, stopCh, &waitGroup)
createWorker(c.machineSafetyAPIServerQueue, "ClusterMachineAPIServer", maxRetries, true, c.reconcileClusterMachineSafetyAPIServer, stopCh, &waitGroup)
}

<-stopCh
Expand Down
Loading