-
Notifications
You must be signed in to change notification settings - Fork 490
controller: Fix "changed" logic to account for nodeReady changes #718
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,8 @@ func (ctrl *Controller) syncStatusOnly(pool *mcfgv1.MachineConfigPool) error { | |
| } | ||
|
|
||
| func calculateStatus(pool *mcfgv1.MachineConfigPool, nodes []*corev1.Node) mcfgv1.MachineConfigPoolStatus { | ||
| previousUpdated := mcfgv1.IsMachineConfigPoolConditionTrue(pool.Status.Conditions, mcfgv1.MachineConfigPoolUpdated) | ||
|
|
||
| machineCount := int32(len(nodes)) | ||
|
|
||
| updatedMachines := getUpdatedMachines(pool.Status.Configuration.Name, nodes) | ||
|
|
@@ -75,8 +77,12 @@ func calculateStatus(pool *mcfgv1.MachineConfigPool, nodes []*corev1.Node) mcfgv | |
| readyMachineCount == machineCount && | ||
| unavailableMachineCount == 0 { | ||
| //TODO: update api to only have one condition regarding status of update. | ||
| supdated := mcfgv1.NewMachineConfigPoolCondition(mcfgv1.MachineConfigPoolUpdated, corev1.ConditionTrue, fmt.Sprintf("All nodes are updated with %s", pool.Status.Configuration.Name), "") | ||
| updatedMsg := fmt.Sprintf("All nodes are updated with %s", pool.Status.Configuration.Name) | ||
| supdated := mcfgv1.NewMachineConfigPoolCondition(mcfgv1.MachineConfigPoolUpdated, corev1.ConditionTrue, updatedMsg, "") | ||
|
cgwalters marked this conversation as resolved.
|
||
| mcfgv1.SetMachineConfigPoolCondition(&status, *supdated) | ||
| if !previousUpdated { | ||
| glog.Infof("Pool %s: %s", pool.Name, updatedMsg) | ||
| } | ||
| supdating := mcfgv1.NewMachineConfigPoolCondition(mcfgv1.MachineConfigPoolUpdating, corev1.ConditionFalse, "", "") | ||
| mcfgv1.SetMachineConfigPoolCondition(&status, *supdating) | ||
| } else { | ||
|
|
@@ -111,6 +117,18 @@ func calculateStatus(pool *mcfgv1.MachineConfigPool, nodes []*corev1.Node) mcfgv | |
| return status | ||
| } | ||
|
|
||
| // isNodeManaged checks whether the MCD has ever run on a node | ||
| func isNodeManaged(node *corev1.Node) bool { | ||
| if node.Annotations == nil { | ||
| return false | ||
| } | ||
| cconfig, ok := node.Annotations[daemonconsts.CurrentMachineConfigAnnotationKey] | ||
| if !ok || cconfig == "" { | ||
| return false | ||
| } | ||
| return true | ||
| } | ||
|
|
||
| // getUpdatedMachines filters the provided nodes to ones whose current == desired | ||
| // and the "done" flag is set. | ||
| func getUpdatedMachines(currentConfig string, nodes []*corev1.Node) []*corev1.Node { | ||
|
|
@@ -153,32 +171,32 @@ func getReadyMachines(currentConfig string, nodes []*corev1.Node) []*corev1.Node | |
| return ready | ||
| } | ||
|
|
||
| func isNodeReady(node *corev1.Node) bool { | ||
| func checkNodeReady(node *corev1.Node) error { | ||
| for i := range node.Status.Conditions { | ||
| cond := &node.Status.Conditions[i] | ||
| // We consider the node for scheduling only when its: | ||
| // - NodeReady condition status is ConditionTrue, | ||
| // - NodeOutOfDisk condition status is ConditionFalse, | ||
| // - NodeNetworkUnavailable condition status is ConditionFalse. | ||
| if cond.Type == corev1.NodeReady && cond.Status != corev1.ConditionTrue { | ||
| glog.Infof("Node %s is reporting NotReady", node.Name) | ||
| return false | ||
| return fmt.Errorf("Node %s is reporting NotReady", node.Name) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: these should be lowercase error messages. we can fix later. |
||
| } | ||
| if cond.Type == corev1.NodeOutOfDisk && cond.Status != corev1.ConditionFalse { | ||
| glog.Infof("Node %s is reporting OutOfDisk", node.Name) | ||
| return false | ||
| return fmt.Errorf("Node %s is reporting OutOfDisk", node.Name) | ||
| } | ||
| if cond.Type == corev1.NodeNetworkUnavailable && cond.Status != corev1.ConditionFalse { | ||
| glog.Infof("Node %s is reporting NetworkUnavailable", node.Name) | ||
| return false | ||
| return fmt.Errorf("Node %s is reporting NetworkUnavailable", node.Name) | ||
| } | ||
| } | ||
| // Ignore nodes that are marked unschedulable | ||
| if node.Spec.Unschedulable { | ||
| glog.Infof("Node %s is reporting Unschedulable", node.Name) | ||
| return false | ||
| return fmt.Errorf("Node %s is reporting Unschedulable", node.Name) | ||
| } | ||
| return true | ||
| return nil | ||
| } | ||
|
|
||
| func isNodeReady(node *corev1.Node) bool { | ||
|
cgwalters marked this conversation as resolved.
|
||
| return checkNodeReady(node) == nil | ||
| } | ||
|
|
||
| func getUnavailableMachines(currentConfig string, nodes []*corev1.Node) []*corev1.Node { | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
later: we could make this a small function instead of repeating code