remove Initializer use from pv label controller
This commit is contained in:
@@ -129,13 +129,6 @@ func TestCreatePatch(t *testing.T) {
|
||||
ignoredPV := v1.PersistentVolume{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "noncloud",
|
||||
Initializers: &metav1.Initializers{
|
||||
Pending: []metav1.Initializer{
|
||||
{
|
||||
Name: initializerName,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Spec: v1.PersistentVolumeSpec{
|
||||
PersistentVolumeSource: v1.PersistentVolumeSource{
|
||||
@@ -148,13 +141,6 @@ func TestCreatePatch(t *testing.T) {
|
||||
awsPV := v1.PersistentVolume{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "awsPV",
|
||||
Initializers: &metav1.Initializers{
|
||||
Pending: []metav1.Initializer{
|
||||
{
|
||||
Name: initializerName,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Spec: v1.PersistentVolumeSpec{
|
||||
PersistentVolumeSource: v1.PersistentVolumeSource{
|
||||
@@ -217,13 +203,6 @@ func TestCreatePatch(t *testing.T) {
|
||||
awsPVWithAffinity := v1.PersistentVolume{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "awsPV",
|
||||
Initializers: &metav1.Initializers{
|
||||
Pending: []metav1.Initializer{
|
||||
{
|
||||
Name: initializerName,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Spec: v1.PersistentVolumeSpec{
|
||||
PersistentVolumeSource: v1.PersistentVolumeSource{
|
||||
@@ -458,9 +437,12 @@ func TestCreatePatch(t *testing.T) {
|
||||
}
|
||||
obj := &v1.PersistentVolume{}
|
||||
json.Unmarshal(patch, obj)
|
||||
if obj.ObjectMeta.Initializers != nil {
|
||||
t.Errorf("%s: initializer wasn't removed: %v", d, obj.ObjectMeta.Initializers)
|
||||
}
|
||||
|
||||
// TODO: check if object was marked as initialized
|
||||
// if ... object was not marked as initialized ... {
|
||||
// t.Errorf("%s: wasn't marked as initialized: %#v", d, obj)
|
||||
// }
|
||||
|
||||
if tc.labels == nil {
|
||||
continue
|
||||
}
|
||||
@@ -491,29 +473,24 @@ func TestAddLabelsToVolume(t *testing.T) {
|
||||
|
||||
testCases := map[string]struct {
|
||||
vol v1.PersistentVolume
|
||||
initializers *metav1.Initializers
|
||||
shouldLabelAndSetAffinity bool
|
||||
}{
|
||||
"PV without initializer": {
|
||||
vol: pv,
|
||||
initializers: nil,
|
||||
shouldLabelAndSetAffinity: false,
|
||||
},
|
||||
"PV with initializer to remove": {
|
||||
vol: pv,
|
||||
initializers: &metav1.Initializers{Pending: []metav1.Initializer{{Name: initializerName}}},
|
||||
shouldLabelAndSetAffinity: true,
|
||||
},
|
||||
"PV with other initializers only": {
|
||||
vol: pv,
|
||||
initializers: &metav1.Initializers{Pending: []metav1.Initializer{{Name: "OtherInit"}}},
|
||||
shouldLabelAndSetAffinity: false,
|
||||
},
|
||||
"PV with other initializers first": {
|
||||
vol: pv,
|
||||
initializers: &metav1.Initializers{Pending: []metav1.Initializer{{Name: "OtherInit"}, {Name: initializerName}}},
|
||||
shouldLabelAndSetAffinity: false,
|
||||
},
|
||||
// "PV with initializer to remove": {
|
||||
// vol: pv,
|
||||
// shouldLabelAndSetAffinity: true,
|
||||
// },
|
||||
// "PV with other initializers only": {
|
||||
// vol: pv,
|
||||
// shouldLabelAndSetAffinity: false,
|
||||
// },
|
||||
// "PV with other initializers first": {
|
||||
// vol: pv,
|
||||
// shouldLabelAndSetAffinity: false,
|
||||
// },
|
||||
}
|
||||
|
||||
for d, tc := range testCases {
|
||||
@@ -550,7 +527,6 @@ func TestAddLabelsToVolume(t *testing.T) {
|
||||
VolumeLabelMap: map[string]map[string]string{"awsPV": {"a": "1"}},
|
||||
}
|
||||
pvlController := &PersistentVolumeLabelController{kubeClient: client, cloud: fakeCloud}
|
||||
tc.vol.ObjectMeta.Initializers = tc.initializers
|
||||
pvlController.addLabelsAndAffinityToVolume(&tc.vol)
|
||||
|
||||
select {
|
||||
|
||||
Reference in New Issue
Block a user