@@ -123,7 +123,16 @@ func (k *Klocksmith) process(stop <-chan struct{}) error {
123123 return err
124124 }
125125 } else {
126- glog .Info ("Skipping marking node as schedulable -- node was unschedulable prior to update reboot" )
126+ glog .Info ("Skipping marking node as schedulable -- node was marked unschedulable by an external source" )
127+ }
128+
129+ anno = map [string ]string {
130+ constants .AnnotationAgentMadeUnschedulable : constants .False ,
131+ }
132+
133+ glog .Infof ("Setting annotations %#v" , anno )
134+ if err := k8sutil .SetNodeAnnotations (k .nc , k .node , anno ); err != nil {
135+ return err
127136 }
128137
129138 // watch update engine for status updates
@@ -140,22 +149,26 @@ func (k *Klocksmith) process(stop <-chan struct{}) error {
140149 glog .Warningf ("error waiting for an ok-to-reboot: %v" , err )
141150 }
142151
152+ glog .Info ("Checking if node is already unschedulable" )
153+ node , err = k8sutil .GetNodeRetry (k .nc , k .node )
154+ if err != nil {
155+ return err
156+ }
157+ alreadyUnschedulable := node .Spec .Unschedulable
158+
143159 // set constants.AnnotationRebootInProgress and drain self
144160 anno = map [string ]string {
145161 constants .AnnotationRebootInProgress : constants .True ,
146162 }
147163
148- glog .Infof ("Setting annotations %#v" , anno )
149- if err := k8sutil .SetNodeAnnotations (k .nc , k .node , anno ); err != nil {
150- return err
164+ if ! alreadyUnschedulable {
165+ anno [constants .AnnotationAgentMadeUnschedulable ] = constants .True
151166 }
152167
153- glog .Info ("Checking if node is already unschedulable" )
154- node , err = k8sutil .GetNodeRetry (k .nc , k .node )
155- if err != nil {
168+ glog .Infof ("Setting annotations %#v" , anno )
169+ if err := k8sutil .SetNodeAnnotations (k .nc , k .node , anno ); err != nil {
156170 return err
157171 }
158- alreadyUnschedulable := node .Spec .Unschedulable
159172
160173 // drain self equates to:
161174 // 1. set Unschedulable if necessary
@@ -164,20 +177,11 @@ func (k *Klocksmith) process(stop <-chan struct{}) error {
164177 // ('any pods that are neither mirror pods nor managed by
165178 // ReplicationController, ReplicaSet, DaemonSet or Job')
166179
167- if alreadyUnschedulable == false {
180+ if ! alreadyUnschedulable {
168181 glog .Info ("Marking node as unschedulable" )
169182 if err := k8sutil .Unschedulable (k .nc , k .node , true ); err != nil {
170183 return err
171184 }
172-
173- // set constants.AnnotationRebootInProgress and drain self
174- anno = map [string ]string {
175- constants .AnnotationAgentMadeUnschedulable : constants .True ,
176- }
177-
178- if err := k8sutil .SetNodeAnnotations (k .nc , k .node , anno ); err != nil {
179- return err
180- }
181185 } else {
182186 glog .Info ("Node already marked as unschedulable" )
183187 }
0 commit comments