mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
add field-level warning for deprecated spec.externalID of node
This commit is contained in:
parent
b86f94f438
commit
ba6fcf4169
@ -123,7 +123,7 @@ func (nodeStrategy) Validate(ctx context.Context, obj runtime.Object) field.Erro
|
||||
|
||||
// WarningsOnCreate returns warnings for the creation of the given object.
|
||||
func (nodeStrategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string {
|
||||
return dynamicKubeletConfigIsDeprecatedWarning(obj)
|
||||
return fieldIsDeprecatedWarnings(obj)
|
||||
}
|
||||
|
||||
// Canonicalize normalizes the object after validation.
|
||||
@ -138,7 +138,7 @@ func (nodeStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object)
|
||||
|
||||
// WarningsOnUpdate returns warnings for the given update.
|
||||
func (nodeStrategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string {
|
||||
return dynamicKubeletConfigIsDeprecatedWarning(obj)
|
||||
return fieldIsDeprecatedWarnings(obj)
|
||||
}
|
||||
|
||||
func (nodeStrategy) AllowUnconditionalUpdate() bool {
|
||||
@ -267,13 +267,15 @@ func ResourceLocation(getter ResourceGetter, connection client.ConnectionInfoGet
|
||||
return &url.URL{Scheme: schemeReq, Host: net.JoinHostPort(info.Hostname, portReq)}, proxyTransport, nil
|
||||
}
|
||||
|
||||
func dynamicKubeletConfigIsDeprecatedWarning(obj runtime.Object) []string {
|
||||
func fieldIsDeprecatedWarnings(obj runtime.Object) []string {
|
||||
newNode := obj.(*api.Node)
|
||||
var warnings []string
|
||||
if newNode.Spec.ConfigSource != nil {
|
||||
var warnings []string
|
||||
// KEP https://github.com/kubernetes/enhancements/issues/281
|
||||
warnings = append(warnings, "spec.configSource: the feature is removed")
|
||||
return warnings
|
||||
}
|
||||
return nil
|
||||
if len(newNode.Spec.DoNotUseExternalID) > 0 {
|
||||
warnings = append(warnings, "spec.externalID: this field is deprecated, and is unused by Kubernetes")
|
||||
}
|
||||
return warnings
|
||||
}
|
||||
|
@ -298,6 +298,14 @@ func TestWarningOnUpdateAndCreate(t *testing.T) {
|
||||
"spec.configSource"},
|
||||
{api.Node{Spec: api.NodeSpec{ConfigSource: &api.NodeConfigSource{}}},
|
||||
api.Node{}, ""},
|
||||
{api.Node{},
|
||||
api.Node{Spec: api.NodeSpec{DoNotUseExternalID: "externalID"}},
|
||||
"spec.externalID"},
|
||||
{api.Node{Spec: api.NodeSpec{DoNotUseExternalID: "externalID"}},
|
||||
api.Node{Spec: api.NodeSpec{DoNotUseExternalID: "externalID"}},
|
||||
"spec.externalID"},
|
||||
{api.Node{Spec: api.NodeSpec{DoNotUseExternalID: "externalID"}},
|
||||
api.Node{}, ""},
|
||||
}
|
||||
for i, test := range tests {
|
||||
warnings := (nodeStrategy{}).WarningsOnUpdate(context.Background(), &test.node, &test.oldNode)
|
||||
|
Loading…
Reference in New Issue
Block a user