Skip to content

Commit

Permalink
Merge pull request #494 from zeeke/log-on-node-update
Browse files Browse the repository at this point in the history
config-daemon: Improve logging of draining state
  • Loading branch information
adrianchiris authored Sep 5, 2023
2 parents 73e7564 + 3e16640 commit 14c6765
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions pkg/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ func (dn *Daemon) tryCreateUdevRuleWrapper() error {

// Run the config daemon
func (dn *Daemon) Run(stopCh <-chan struct{}, exitCh <-chan error) error {
glog.V(0).Infof("Run(): node: %s", dn.name)

if utils.ClusterType == utils.ClusterTypeOpenshift {
glog.V(0).Infof("Run(): start daemon. openshiftFlavor: %s", dn.openshiftContext.OpenshiftFlavor)
} else {
Expand Down Expand Up @@ -400,16 +402,31 @@ func (dn *Daemon) nodeUpdateHandler(old, new interface{}) {
return
}
dn.node = node.DeepCopy()

nodes, err := dn.nodeLister.List(labels.Everything())
if err != nil {
glog.Errorf("nodeUpdateHandler(): failed to list nodes: %v", err)
return
}
for _, node := range nodes {
if node.GetName() != dn.name && (node.Annotations[annoKey] == annoDraining || node.Annotations[annoKey] == annoMcpPaused) {

// Checking if other nodes are draining
for _, otherNode := range nodes {
if otherNode.GetName() == dn.name {
continue
}

drainingAnnotationValue := otherNode.Annotations[annoKey]
if drainingAnnotationValue == annoDraining || drainingAnnotationValue == annoMcpPaused {
glog.V(2).Infof("nodeUpdateHandler(): node is not drainable as [%s] has [%s == %s] ", otherNode.Name, annoKey, drainingAnnotationValue)
dn.drainable = false
return
}
}

if !dn.drainable {
glog.V(2).Infof("nodeUpdateHandler(): node is now drainable")
}

dn.drainable = true
}

Expand Down

0 comments on commit 14c6765

Please sign in to comment.