mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-10-22 15:09:39 +00:00
node config_source
Signed-off-by: Serguei Bezverkhi <sbezverk@cisco.com>
This commit is contained in:
@@ -67,9 +67,9 @@ func (nodeStrategy) AllowCreateOnUpdate() bool {
|
||||
func (nodeStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
|
||||
node := obj.(*api.Node)
|
||||
// Nodes allow *all* fields, including status, to be set on create.
|
||||
|
||||
if !utilfeature.DefaultFeatureGate.Enabled(features.DynamicKubeletConfig) {
|
||||
node.Spec.ConfigSource = nil
|
||||
node.Status.Config = nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,12 +79,22 @@ func (nodeStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Objec
|
||||
oldNode := old.(*api.Node)
|
||||
newNode.Status = oldNode.Status
|
||||
|
||||
if !utilfeature.DefaultFeatureGate.Enabled(features.DynamicKubeletConfig) {
|
||||
if !utilfeature.DefaultFeatureGate.Enabled(features.DynamicKubeletConfig) && !nodeConfigSourceInUse(oldNode) {
|
||||
newNode.Spec.ConfigSource = nil
|
||||
oldNode.Spec.ConfigSource = nil
|
||||
}
|
||||
}
|
||||
|
||||
// nodeConfigSourceInUse returns true if node's Spec ConfigSource is set(used)
|
||||
func nodeConfigSourceInUse(node *api.Node) bool {
|
||||
if node == nil {
|
||||
return false
|
||||
}
|
||||
if node.Spec.ConfigSource != nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Validate validates a new node.
|
||||
func (nodeStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
|
||||
node := obj.(*api.Node)
|
||||
@@ -127,26 +137,27 @@ type nodeStatusStrategy struct {
|
||||
|
||||
var StatusStrategy = nodeStatusStrategy{Strategy}
|
||||
|
||||
func (nodeStatusStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
|
||||
node := obj.(*api.Node)
|
||||
// Nodes allow *all* fields, including status, to be set on create.
|
||||
|
||||
if !utilfeature.DefaultFeatureGate.Enabled(features.DynamicKubeletConfig) {
|
||||
node.Status.Config = nil
|
||||
}
|
||||
}
|
||||
|
||||
func (nodeStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
|
||||
newNode := obj.(*api.Node)
|
||||
oldNode := old.(*api.Node)
|
||||
newNode.Spec = oldNode.Spec
|
||||
|
||||
if !utilfeature.DefaultFeatureGate.Enabled(features.DynamicKubeletConfig) {
|
||||
if !utilfeature.DefaultFeatureGate.Enabled(features.DynamicKubeletConfig) && !nodeStatusConfigInUse(oldNode) {
|
||||
newNode.Status.Config = nil
|
||||
oldNode.Status.Config = nil
|
||||
}
|
||||
}
|
||||
|
||||
// nodeStatusConfigInUse returns true if node's Status Config is set(used)
|
||||
func nodeStatusConfigInUse(node *api.Node) bool {
|
||||
if node == nil {
|
||||
return false
|
||||
}
|
||||
if node.Status.Config != nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (nodeStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
|
||||
return validation.ValidateNodeUpdate(obj.(*api.Node), old.(*api.Node))
|
||||
}
|
||||
|
Reference in New Issue
Block a user