Skip to content

Commit

Permalink
Merge pull request #7138 from pravisankar/unschedulable-event
Browse files Browse the repository at this point in the history
Record an event on node schedulable changes
  • Loading branch information
bgrant0607 committed Apr 22, 2015
2 parents ae3c83f + f1d88f6 commit 8dbbf3d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions pkg/kubelet/kubelet.go
Expand Up @@ -1769,6 +1769,21 @@ func (kl *Kubelet) recordNodeOnlineEvent() {
kl.recorder.Eventf(kl.nodeRef, "online", "Node %s is now online", kl.hostname)
}

func (kl *Kubelet) recordNodeSchedulableEvent() {
// TODO: This requires a transaction, either both node status is updated
// and event is recorded or neither should happen, see issue #6055.
kl.recorder.Eventf(kl.nodeRef, "schedulable", "Node %s is now schedulable", kl.hostname)
}

func (kl *Kubelet) recordNodeUnschedulableEvent() {
// TODO: This requires a transaction, either both node status is updated
// and event is recorded or neither should happen, see issue #6055.
kl.recorder.Eventf(kl.nodeRef, "unschedulable", "Node %s is now unschedulable", kl.hostname)
}

// Maintains Node.Spec.Unschedulable value from previous run of tryUpdateNodeStatus()
var oldNodeUnschedulable bool

// tryUpdateNodeStatus tries to update node status to master.
func (kl *Kubelet) tryUpdateNodeStatus() error {
node, err := kl.kubeClient.Nodes().Get(kl.hostname)
Expand Down Expand Up @@ -1835,6 +1850,14 @@ func (kl *Kubelet) tryUpdateNodeStatus() error {
kl.recordNodeOnlineEvent()
}

if oldNodeUnschedulable != node.Spec.Unschedulable {
if node.Spec.Unschedulable {
kl.recordNodeUnschedulableEvent()
} else {
kl.recordNodeSchedulableEvent()
}
oldNodeUnschedulable = node.Spec.Unschedulable
}
_, err = kl.kubeClient.Nodes().UpdateStatus(node)
return err
}
Expand Down

0 comments on commit 8dbbf3d

Please sign in to comment.