Skip to content

Commit

Permalink
Annotate node only if there is no existing annotation
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Kolodyazhny <[email protected]>
  • Loading branch information
e0ne committed Jan 25, 2022
1 parent 8f52b7c commit 031dcbc
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions pkg/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,9 +554,11 @@ func (dn *Daemon) nodeStateSyncHandler(generation int64) error {
return err
}
} else {
if err := dn.annotateNode(dn.name, annoIdle); err != nil {
glog.Errorf("nodeStateSyncHandler(): failed to annotate node: %v", err)
return err
if !dn.nodeHasAnnotation(annoKey, annoIdle) {
if err := dn.annotateNode(dn.name, annoIdle); err != nil {
glog.Errorf("nodeStateSyncHandler(): failed to annotate node: %v", err)
return err
}
}
}
glog.Info("nodeStateSyncHandler(): sync succeeded")
Expand All @@ -570,6 +572,14 @@ func (dn *Daemon) nodeStateSyncHandler(generation int64) error {
return nil
}

func (dn *Daemon) nodeHasAnnotation(annoKey string, value string) bool {
// Check if node already contains annotation
if anno, ok := dn.node.Annotations[annoKey]; ok && (anno == value) {
return true
}
return false
}

func (dn *Daemon) isNodeDraining() bool {
if anno, ok := dn.node.Annotations[annoKey]; ok && (anno == annoDraining || anno == annoMcpPaused) {
return true
Expand Down

0 comments on commit 031dcbc

Please sign in to comment.