forked from openshift/machine-config-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Watch scheduler CR and make masters schedulable accordingly
By default, the MCO's kubelet configuration injects a taint to disable scheduling. This adds support in the MCO for watching the API recently added to allow the masters to be schedulable. openshift/api#366 Use cases here are for 3 node bare metal clusters (which have significant resources on the masters), as well as CodeReady Containers which wants to make a single node OpenShift as a VM. Closes: openshift#763
- Loading branch information
1 parent
43b202c
commit 5144a15
Showing
96 changed files
with
2,348 additions
and
110 deletions.
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 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 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 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 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 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 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 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.