-
Notifications
You must be signed in to change notification settings - Fork 462
Watch scheduler CR and make masters schedulable accordingly #937
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
Merged
openshift-merge-robot
merged 1 commit into
openshift:master
from
ravisantoshgudimetla:add-scheduler-watcher
Jul 13, 2019
Merged
Changes from all commits
Commits
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| package internal | ||
|
|
||
| import ( | ||
| "encoding/json" | ||
| "fmt" | ||
|
|
||
| corev1 "k8s.io/api/core/v1" | ||
| "k8s.io/apimachinery/pkg/types" | ||
| "k8s.io/apimachinery/pkg/util/strategicpatch" | ||
| corev1client "k8s.io/client-go/kubernetes/typed/core/v1" | ||
| corev1lister "k8s.io/client-go/listers/core/v1" | ||
| "k8s.io/client-go/util/retry" | ||
| ) | ||
|
|
||
| // UpdateNodeRetry calls f to update a node object in Kubernetes. | ||
| // It will attempt to update the node by applying f to it up to DefaultBackoff | ||
| // number of times. | ||
| // f will be called each time since the node object will likely have changed if | ||
| // a retry is necessary. | ||
| func UpdateNodeRetry(client corev1client.NodeInterface, lister corev1lister.NodeLister, nodeName string, f func(*corev1.Node)) (*corev1.Node, error) { | ||
| var node *corev1.Node | ||
| if err := retry.RetryOnConflict(retry.DefaultBackoff, func() error { | ||
| n, err := lister.Get(nodeName) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| oldNode, err := json.Marshal(n) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| nodeClone := n.DeepCopy() | ||
| f(nodeClone) | ||
|
|
||
| newNode, err := json.Marshal(nodeClone) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| patchBytes, err := strategicpatch.CreateTwoWayMergePatch(oldNode, newNode, corev1.Node{}) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to create patch for node %q: %v", nodeName, err) | ||
| } | ||
|
|
||
| node, err = client.Patch(nodeName, types.StrategicMergePatchType, patchBytes) | ||
| return err | ||
| }); err != nil { | ||
| // may be conflict if max retries were hit | ||
| return nil, fmt.Errorf("unable to update node %q: %v", node, err) | ||
| } | ||
| return node, nil | ||
| } |
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
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
Oops, something went wrong.
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.
This can be changed futher to just list, instead of giving
*