mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 10:20:51 +00:00
Remove ClusterName
This commit is contained in:
parent
71df3e819b
commit
331525670b
@ -30,7 +30,6 @@ API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,Duration,Du
|
||||
API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,InternalEvent,Object
|
||||
API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,InternalEvent,Type
|
||||
API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,MicroTime,Time
|
||||
API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,ObjectMeta,ZZZ_DeprecatedClusterName
|
||||
API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,StatusCause,Type
|
||||
API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,Time,Time
|
||||
API rule violation: names_match,k8s.io/apimachinery/pkg/runtime,Unknown,ContentEncoding
|
||||
|
@ -30,7 +30,6 @@ API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,Duration,Du
|
||||
API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,InternalEvent,Object
|
||||
API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,InternalEvent,Type
|
||||
API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,MicroTime,Time
|
||||
API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,ObjectMeta,ZZZ_DeprecatedClusterName
|
||||
API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,StatusCause,Type
|
||||
API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,Time,Time
|
||||
API rule violation: names_match,k8s.io/apimachinery/pkg/runtime,Unknown,ContentEncoding
|
||||
|
@ -30,7 +30,6 @@ API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,Duration,Du
|
||||
API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,InternalEvent,Object
|
||||
API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,InternalEvent,Type
|
||||
API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,MicroTime,Time
|
||||
API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,ObjectMeta,ZZZ_DeprecatedClusterName
|
||||
API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,StatusCause,Type
|
||||
API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,Time,Time
|
||||
API rule violation: names_match,k8s.io/apimachinery/pkg/runtime,Unknown,ContentEncoding
|
||||
|
@ -31,7 +31,6 @@ API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,Duration,Du
|
||||
API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,InternalEvent,Object
|
||||
API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,InternalEvent,Type
|
||||
API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,MicroTime,Time
|
||||
API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,ObjectMeta,ZZZ_DeprecatedClusterName
|
||||
API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,StatusCause,Type
|
||||
API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,Time,Time
|
||||
API rule violation: names_match,k8s.io/apimachinery/pkg/runtime,Unknown,ContentEncoding
|
||||
|
@ -437,7 +437,6 @@ API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,Duration,Du
|
||||
API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,InternalEvent,Object
|
||||
API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,InternalEvent,Type
|
||||
API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,MicroTime,Time
|
||||
API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,ObjectMeta,ZZZ_DeprecatedClusterName
|
||||
API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,StatusCause,Type
|
||||
API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,Time,Time
|
||||
API rule violation: names_match,k8s.io/apimachinery/pkg/runtime,Unknown,ContentEncoding
|
||||
|
@ -180,7 +180,6 @@ func fuzzObject(t *testing.T, gvk schema.GroupVersionKind) runtime.Object {
|
||||
c.FuzzNoCustom(s)
|
||||
s.ManagedFields = nil
|
||||
s.SelfLink = ""
|
||||
s.ZZZ_DeprecatedClusterName = ""
|
||||
},
|
||||
).Fuzz(internalObj)
|
||||
|
||||
|
@ -1356,14 +1356,6 @@ func testValidatePVC(t *testing.T, ephemeral bool) {
|
||||
return claim
|
||||
}(),
|
||||
},
|
||||
"with-cluster-name": {
|
||||
isExpectedFailure: ephemeral,
|
||||
claim: func() *core.PersistentVolumeClaim {
|
||||
claim := testVolumeClaim(goodName, goodNS, goodClaimSpec)
|
||||
claim.ZZZ_DeprecatedClusterName = "foo"
|
||||
return claim
|
||||
}(),
|
||||
},
|
||||
"with-managed-fields": {
|
||||
isExpectedFailure: ephemeral,
|
||||
claim: func() *core.PersistentVolumeClaim {
|
||||
|
@ -1464,7 +1464,7 @@ func TestDropNonEphemeralContainerUpdates(t *testing.T) {
|
||||
Namespace: "test-ns",
|
||||
ResourceVersion: "1",
|
||||
Annotations: map[string]string{"foo": "bar", "whiz": "pop"},
|
||||
ZZZ_DeprecatedClusterName: "milo",
|
||||
Finalizers: []string{"milo"},
|
||||
},
|
||||
Spec: api.PodSpec{
|
||||
Containers: []api.Container{
|
||||
|
@ -190,7 +190,6 @@ func TestNewMetadataFields(t *testing.T) {
|
||||
objMeta.Annotations = nil
|
||||
objMeta.OwnerReferences = nil
|
||||
objMeta.Finalizers = nil
|
||||
objMeta.ZZZ_DeprecatedClusterName = ""
|
||||
objMeta.ManagedFields = nil
|
||||
|
||||
if !reflect.DeepEqual(metav1.ObjectMeta{}, objMeta) {
|
||||
|
@ -130,7 +130,6 @@ func AsPartialObjectMetadata(m metav1.Object) *metav1.PartialObjectMetadata {
|
||||
Annotations: m.GetAnnotations(),
|
||||
OwnerReferences: m.GetOwnerReferences(),
|
||||
Finalizers: m.GetFinalizers(),
|
||||
ZZZ_DeprecatedClusterName: m.GetZZZ_DeprecatedClusterName(),
|
||||
ManagedFields: m.GetManagedFields(),
|
||||
},
|
||||
}
|
||||
|
@ -40,9 +40,6 @@ var BannedOwners = map[schema.GroupVersionKind]struct{}{
|
||||
{Group: "", Version: "v1", Kind: "Event"}: {},
|
||||
}
|
||||
|
||||
// ValidateZZZ_DeprecatedClusterName can be used to check whether the given cluster name is valid.
|
||||
var ValidateZZZ_DeprecatedClusterName = NameIsDNS1035Label
|
||||
|
||||
// ValidateAnnotations validates that a set of annotations are correctly defined.
|
||||
func ValidateAnnotations(annotations map[string]string, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
@ -184,11 +181,6 @@ func ValidateObjectMetaAccessor(meta metav1.Object, requiresNamespace bool, name
|
||||
allErrs = append(allErrs, field.Forbidden(fldPath.Child("namespace"), "not allowed on this type"))
|
||||
}
|
||||
}
|
||||
if len(meta.GetZZZ_DeprecatedClusterName()) != 0 {
|
||||
for _, msg := range ValidateZZZ_DeprecatedClusterName(meta.GetZZZ_DeprecatedClusterName(), false) {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("clusterName"), meta.GetZZZ_DeprecatedClusterName(), msg))
|
||||
}
|
||||
}
|
||||
|
||||
allErrs = append(allErrs, ValidateNonnegativeField(meta.GetGeneration(), fldPath.Child("generation"))...)
|
||||
allErrs = append(allErrs, v1validation.ValidateLabels(meta.GetLabels(), fldPath.Child("labels"))...)
|
||||
@ -261,7 +253,6 @@ func ValidateObjectMetaAccessorUpdate(newMeta, oldMeta metav1.Object, fldPath *f
|
||||
allErrs = append(allErrs, ValidateImmutableField(newMeta.GetCreationTimestamp(), oldMeta.GetCreationTimestamp(), fldPath.Child("creationTimestamp"))...)
|
||||
allErrs = append(allErrs, ValidateImmutableField(newMeta.GetDeletionTimestamp(), oldMeta.GetDeletionTimestamp(), fldPath.Child("deletionTimestamp"))...)
|
||||
allErrs = append(allErrs, ValidateImmutableField(newMeta.GetDeletionGracePeriodSeconds(), oldMeta.GetDeletionGracePeriodSeconds(), fldPath.Child("deletionGracePeriodSeconds"))...)
|
||||
allErrs = append(allErrs, ValidateImmutableField(newMeta.GetZZZ_DeprecatedClusterName(), oldMeta.GetZZZ_DeprecatedClusterName(), fldPath.Child("clusterName"))...)
|
||||
|
||||
allErrs = append(allErrs, v1validation.ValidateLabels(newMeta.GetLabels(), fldPath.Child("labels"))...)
|
||||
allErrs = append(allErrs, ValidateAnnotations(newMeta.GetAnnotations(), fldPath.Child("annotations"))...)
|
||||
|
@ -205,7 +205,6 @@ func TestResetObjectMetaForStatus(t *testing.T) {
|
||||
existingMeta.SetUID(types.UID(""))
|
||||
existingMeta.SetName("")
|
||||
existingMeta.SetNamespace("")
|
||||
existingMeta.SetZZZ_DeprecatedClusterName("")
|
||||
existingMeta.SetCreationTimestamp(Time{})
|
||||
existingMeta.SetDeletionTimestamp(nil)
|
||||
existingMeta.SetDeletionGracePeriodSeconds(nil)
|
||||
|
@ -59,8 +59,6 @@ type Object interface {
|
||||
SetFinalizers(finalizers []string)
|
||||
GetOwnerReferences() []OwnerReference
|
||||
SetOwnerReferences([]OwnerReference)
|
||||
GetZZZ_DeprecatedClusterName() string
|
||||
SetZZZ_DeprecatedClusterName(clusterName string)
|
||||
GetManagedFields() []ManagedFieldsEntry
|
||||
SetManagedFields(managedFields []ManagedFieldsEntry)
|
||||
}
|
||||
@ -172,10 +170,6 @@ func (meta *ObjectMeta) GetOwnerReferences() []OwnerReference { return m
|
||||
func (meta *ObjectMeta) SetOwnerReferences(references []OwnerReference) {
|
||||
meta.OwnerReferences = references
|
||||
}
|
||||
func (meta *ObjectMeta) GetZZZ_DeprecatedClusterName() string { return meta.ZZZ_DeprecatedClusterName }
|
||||
func (meta *ObjectMeta) SetZZZ_DeprecatedClusterName(clusterName string) {
|
||||
meta.ZZZ_DeprecatedClusterName = clusterName
|
||||
}
|
||||
func (meta *ObjectMeta) GetManagedFields() []ManagedFieldsEntry { return meta.ManagedFields }
|
||||
func (meta *ObjectMeta) SetManagedFields(managedFields []ManagedFieldsEntry) {
|
||||
meta.ManagedFields = managedFields
|
||||
|
@ -254,14 +254,9 @@ type ObjectMeta struct {
|
||||
// +patchStrategy=merge
|
||||
Finalizers []string `json:"finalizers,omitempty" patchStrategy:"merge" protobuf:"bytes,14,rep,name=finalizers"`
|
||||
|
||||
// Deprecated: ClusterName is a legacy field that was always cleared by
|
||||
// the system and never used; it will be removed completely in 1.25.
|
||||
//
|
||||
// The name in the go struct is changed to help clients detect
|
||||
// accidental use.
|
||||
//
|
||||
// +optional
|
||||
ZZZ_DeprecatedClusterName string `json:"clusterName,omitempty" protobuf:"bytes,15,opt,name=clusterName"`
|
||||
// Tombstone: ClusterName was a legacy field that was always cleared by
|
||||
// the system and never used.
|
||||
// ClusterName string `json:"clusterName,omitempty" protobuf:"bytes,15,opt,name=clusterName"`
|
||||
|
||||
// ManagedFields maps workflow-id and version to the set of fields
|
||||
// that are managed by that workflow. This is mostly for internal
|
||||
|
@ -444,18 +444,6 @@ func (u *Unstructured) SetFinalizers(finalizers []string) {
|
||||
u.setNestedStringSlice(finalizers, "metadata", "finalizers")
|
||||
}
|
||||
|
||||
func (u *Unstructured) GetZZZ_DeprecatedClusterName() string {
|
||||
return getNestedString(u.Object, "metadata", "clusterName")
|
||||
}
|
||||
|
||||
func (u *Unstructured) SetZZZ_DeprecatedClusterName(clusterName string) {
|
||||
if len(clusterName) == 0 {
|
||||
RemoveNestedField(u.Object, "metadata", "clusterName")
|
||||
return
|
||||
}
|
||||
u.setNestedField(clusterName, "metadata", "clusterName")
|
||||
}
|
||||
|
||||
func (u *Unstructured) GetManagedFields() []metav1.ManagedFieldsEntry {
|
||||
items, found, err := NestedSlice(u.Object, "metadata", "managedFields")
|
||||
if !found || err != nil {
|
||||
|
@ -105,7 +105,6 @@ func TestUnstructuredMetadataOmitempty(t *testing.T) {
|
||||
u.SetAnnotations(nil)
|
||||
u.SetOwnerReferences(nil)
|
||||
u.SetFinalizers(nil)
|
||||
u.SetZZZ_DeprecatedClusterName("")
|
||||
u.SetManagedFields(nil)
|
||||
|
||||
gotMetadata, _, err := unstructured.NestedFieldNoCopy(u.UnstructuredContent(), "metadata")
|
||||
@ -147,6 +146,5 @@ func setObjectMetaUsingAccessors(u, uCopy *unstructured.Unstructured) {
|
||||
uCopy.SetAnnotations(u.GetAnnotations())
|
||||
uCopy.SetOwnerReferences(u.GetOwnerReferences())
|
||||
uCopy.SetFinalizers(u.GetFinalizers())
|
||||
uCopy.SetZZZ_DeprecatedClusterName(u.GetZZZ_DeprecatedClusterName())
|
||||
uCopy.SetManagedFields(u.GetManagedFields())
|
||||
}
|
||||
|
@ -170,7 +170,6 @@ func TestUnstructuredGetters(t *testing.T) {
|
||||
"finalizer.1",
|
||||
"finalizer.2",
|
||||
},
|
||||
"clusterName": "cluster123",
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -245,9 +244,6 @@ func TestUnstructuredGetters(t *testing.T) {
|
||||
if got, want := unstruct.GetFinalizers(), []string{"finalizer.1", "finalizer.2"}; !reflect.DeepEqual(got, want) {
|
||||
t.Errorf("GetFinalizers()=%v, want %v", got, want)
|
||||
}
|
||||
if got, want := unstruct.GetZZZ_DeprecatedClusterName(), "cluster123"; got != want {
|
||||
t.Errorf("GetZZZ_DeprecatedClusterName()=%v, want %v", got, want)
|
||||
}
|
||||
if got, want := unstruct.GetDeletionGracePeriodSeconds(), &ten; !reflect.DeepEqual(got, want) {
|
||||
t.Errorf("GetDeletionGracePeriodSeconds()=%v, want %v", got, want)
|
||||
}
|
||||
@ -302,7 +298,6 @@ func TestUnstructuredSetters(t *testing.T) {
|
||||
"finalizer.1",
|
||||
"finalizer.2",
|
||||
},
|
||||
"clusterName": "cluster123",
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -338,7 +333,6 @@ func TestUnstructuredSetters(t *testing.T) {
|
||||
}
|
||||
unstruct.SetOwnerReferences(newOwnerReferences)
|
||||
unstruct.SetFinalizers([]string{"finalizer.1", "finalizer.2"})
|
||||
unstruct.SetZZZ_DeprecatedClusterName("cluster123")
|
||||
unstruct.SetDeletionGracePeriodSeconds(&ten)
|
||||
unstruct.SetGeneration(ten)
|
||||
|
||||
@ -534,7 +528,6 @@ func TestAccessorMethods(t *testing.T) {
|
||||
{accessor: "Annotations", val: map[string]string{"foo": "bar"}},
|
||||
{accessor: "Finalizers", val: []string{"foo"}},
|
||||
{accessor: "OwnerReferences", val: []metav1.OwnerReference{{Name: "foo"}}},
|
||||
{accessor: "ZZZ_DeprecatedClusterName", val: "foo"},
|
||||
}
|
||||
for i, test := range tests {
|
||||
t.Logf("evaluating test %d (%s)", i, test.accessor)
|
||||
|
@ -267,7 +267,6 @@ func TestApplyStripsFields(t *testing.T) {
|
||||
newObj.SetName("b")
|
||||
newObj.SetNamespace("b")
|
||||
newObj.SetUID("b")
|
||||
newObj.SetZZZ_DeprecatedClusterName("b")
|
||||
newObj.SetGeneration(0)
|
||||
newObj.SetResourceVersion("b")
|
||||
newObj.SetCreationTimestamp(metav1.NewTime(time.Now()))
|
||||
|
@ -123,12 +123,6 @@ func BeforeCreate(strategy RESTCreateStrategy, ctx context.Context, obj runtime.
|
||||
objectMeta.SetManagedFields(nil)
|
||||
}
|
||||
|
||||
// ZZZ_DeprecatedClusterName is ignored and should not be saved
|
||||
if len(objectMeta.GetZZZ_DeprecatedClusterName()) > 0 {
|
||||
objectMeta.SetZZZ_DeprecatedClusterName("")
|
||||
warning.AddWarning(ctx, "", "metadata.clusterName was specified. This field is not preserved and will be removed from the schema in 1.25")
|
||||
}
|
||||
|
||||
if errs := strategy.Validate(ctx, obj); len(errs) > 0 {
|
||||
return errors.NewInvalid(kind.GroupKind(), objectMeta.GetName(), errs)
|
||||
}
|
||||
|
@ -168,8 +168,6 @@ func (t *Tester) TestCreate(valid runtime.Object, createFn CreateFunc, getFn Get
|
||||
t.testCreateInvokesValidation(opts, invalid...)
|
||||
t.testCreateValidatesNames(valid.DeepCopyObject(), dryRunOpts)
|
||||
t.testCreateValidatesNames(valid.DeepCopyObject(), opts)
|
||||
t.testCreateIgnoreZZZ_DeprecatedClusterName(valid.DeepCopyObject(), dryRunOpts)
|
||||
t.testCreateIgnoreZZZ_DeprecatedClusterName(valid.DeepCopyObject(), opts)
|
||||
}
|
||||
|
||||
// Test updating an object.
|
||||
@ -190,7 +188,6 @@ func (t *Tester) TestUpdate(valid runtime.Object, createFn CreateFunc, getFn Get
|
||||
t.testUpdatePropagatesUpdatedObjectError(valid.DeepCopyObject(), createFn, getFn, dryRunOpts)
|
||||
t.testUpdatePropagatesUpdatedObjectError(valid.DeepCopyObject(), createFn, getFn, opts)
|
||||
t.testUpdateIgnoreGenerationUpdates(valid.DeepCopyObject(), createFn, getFn)
|
||||
t.testUpdateIgnoreZZZ_DeprecatedClusterName(valid.DeepCopyObject(), createFn, getFn)
|
||||
}
|
||||
|
||||
// Test deleting an object.
|
||||
@ -506,22 +503,6 @@ func (t *Tester) testCreateResetsUserData(valid runtime.Object, opts metav1.Crea
|
||||
}
|
||||
}
|
||||
|
||||
func (t *Tester) testCreateIgnoreZZZ_DeprecatedClusterName(valid runtime.Object, opts metav1.CreateOptions) {
|
||||
objectMeta := t.getObjectMetaOrFail(valid)
|
||||
objectMeta.SetName(t.namer(3))
|
||||
objectMeta.SetZZZ_DeprecatedClusterName("clustername-to-ignore")
|
||||
|
||||
obj, err := t.storage.(rest.Creater).Create(t.TestContext(), valid.DeepCopyObject(), rest.ValidateAllObjectFunc, &opts)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
defer t.delete(t.TestContext(), obj)
|
||||
createdObjectMeta := t.getObjectMetaOrFail(obj)
|
||||
if len(createdObjectMeta.GetZZZ_DeprecatedClusterName()) != 0 {
|
||||
t.Errorf("Expected empty clusterName on created object, got '%v'", createdObjectMeta.GetZZZ_DeprecatedClusterName())
|
||||
}
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Update tests.
|
||||
|
||||
@ -790,41 +771,6 @@ func (t *Tester) testUpdateRejectsMismatchedNamespace(obj runtime.Object, create
|
||||
}
|
||||
}
|
||||
|
||||
func (t *Tester) testUpdateIgnoreZZZ_DeprecatedClusterName(obj runtime.Object, createFn CreateFunc, getFn GetFunc) {
|
||||
ctx := t.TestContext()
|
||||
|
||||
foo := obj.DeepCopyObject()
|
||||
name := t.namer(9)
|
||||
t.setObjectMeta(foo, name)
|
||||
|
||||
if err := createFn(ctx, foo); err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
storedFoo, err := getFn(ctx, foo)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
older := storedFoo.DeepCopyObject()
|
||||
olderMeta := t.getObjectMetaOrFail(older)
|
||||
olderMeta.SetZZZ_DeprecatedClusterName("clustername-to-ignore")
|
||||
|
||||
_, _, err = t.storage.(rest.Updater).Update(t.TestContext(), olderMeta.GetName(), rest.DefaultUpdatedObjectInfo(older), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc, false, &metav1.UpdateOptions{})
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error: %v", err)
|
||||
}
|
||||
|
||||
updatedFoo, err := getFn(ctx, older)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
if clusterName := t.getObjectMetaOrFail(updatedFoo).GetZZZ_DeprecatedClusterName(); len(clusterName) != 0 {
|
||||
t.Errorf("Unexpected clusterName update: expected empty, got %v", clusterName)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Deletion tests.
|
||||
|
||||
|
@ -136,11 +136,6 @@ func BeforeUpdate(strategy RESTUpdateStrategy, ctx context.Context, obj, old run
|
||||
|
||||
strategy.PrepareForUpdate(ctx, obj, old)
|
||||
|
||||
// ZZZ_DeprecatedClusterName is ignored and should not be saved
|
||||
if len(objectMeta.GetZZZ_DeprecatedClusterName()) > 0 {
|
||||
objectMeta.SetZZZ_DeprecatedClusterName("")
|
||||
warning.AddWarning(ctx, "", "metadata.clusterName was specified. This field is not preserved and will be removed from the schema in 1.25")
|
||||
}
|
||||
// Use the existing UID if none is provided
|
||||
if len(objectMeta.GetUID()) == 0 {
|
||||
objectMeta.SetUID(oldMeta.GetUID())
|
||||
|
@ -395,17 +395,6 @@ func (o *cachingObject) SetOwnerReferences(references []metav1.OwnerReference) {
|
||||
func() { o.object.SetOwnerReferences(references) },
|
||||
)
|
||||
}
|
||||
func (o *cachingObject) GetZZZ_DeprecatedClusterName() string {
|
||||
o.lock.RLock()
|
||||
defer o.lock.RUnlock()
|
||||
return o.object.GetZZZ_DeprecatedClusterName()
|
||||
}
|
||||
func (o *cachingObject) SetZZZ_DeprecatedClusterName(clusterName string) {
|
||||
o.conditionalSet(
|
||||
func() bool { return o.object.GetZZZ_DeprecatedClusterName() == clusterName },
|
||||
func() { o.object.SetZZZ_DeprecatedClusterName(clusterName) },
|
||||
)
|
||||
}
|
||||
func (o *cachingObject) GetManagedFields() []metav1.ManagedFieldsEntry {
|
||||
o.lock.RLock()
|
||||
defer o.lock.RUnlock()
|
||||
|
@ -1,54 +0,0 @@
|
||||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package objectmeta
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
clientset "k8s.io/client-go/kubernetes"
|
||||
restclient "k8s.io/client-go/rest"
|
||||
"k8s.io/kubernetes/test/integration/framework"
|
||||
)
|
||||
|
||||
func TestIgnoreClusterName(t *testing.T) {
|
||||
config := framework.NewControlPlaneConfig()
|
||||
_, s, closeFn := framework.RunAnAPIServer(config)
|
||||
defer closeFn()
|
||||
|
||||
client := clientset.NewForConfigOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}}})
|
||||
ns := v1.Namespace{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "test-namespace",
|
||||
ZZZ_DeprecatedClusterName: "cluster-name-to-ignore",
|
||||
},
|
||||
}
|
||||
nsNew, err := client.CoreV1().Namespaces().Create(context.TODO(), &ns, metav1.CreateOptions{})
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, ns.Name, nsNew.Name)
|
||||
assert.Empty(t, nsNew.ZZZ_DeprecatedClusterName)
|
||||
|
||||
nsNew, err = client.CoreV1().Namespaces().Update(context.TODO(), &ns, metav1.UpdateOptions{})
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, ns.Name, nsNew.Name)
|
||||
assert.Empty(t, nsNew.ZZZ_DeprecatedClusterName)
|
||||
}
|
Loading…
Reference in New Issue
Block a user