Skip to content

Commit e8e5baa

Browse files
staeblerarschles
authored andcommitted
Do not block instance spec changes unless there is an on-going operation (#1536)
* Do not block instance spec changes unless there is an on-going operation. * Do not consider reconciled generation when considering whether to block a spec change
1 parent 4f47ce8 commit e8e5baa

File tree

2 files changed

+27
-30
lines changed

2 files changed

+27
-30
lines changed

pkg/apis/servicecatalog/validation/instance.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ func validateServiceInstanceUpdate(instance *sc.ServiceInstance) field.ErrorList
269269
// to the spec to go through.
270270
func internalValidateServiceInstanceUpdateAllowed(new *sc.ServiceInstance, old *sc.ServiceInstance) field.ErrorList {
271271
errors := field.ErrorList{}
272-
if old.Generation != new.Generation && old.Status.ReconciledGeneration != old.Generation {
272+
if old.Generation != new.Generation && old.Status.CurrentOperation != "" {
273273
errors = append(errors, field.Forbidden(field.NewPath("spec"), "Another update for this service instance is in progress"))
274274
}
275275
if old.Spec.ClusterServicePlanExternalName != new.Spec.ClusterServicePlanExternalName && new.Spec.ClusterServicePlanRef != nil {

pkg/apis/servicecatalog/validation/instance_test.go

+26-29
Original file line numberDiff line numberDiff line change
@@ -698,34 +698,34 @@ func TestValidateServiceInstance(t *testing.T) {
698698

699699
func TestInternalValidateServiceInstanceUpdateAllowed(t *testing.T) {
700700
cases := []struct {
701-
name string
702-
newSpecChange bool
703-
onGoingSpecChange bool
704-
valid bool
701+
name string
702+
specChange bool
703+
onGoingOperation bool
704+
valid bool
705705
}{
706706
{
707-
name: "spec change when no on-going spec change",
708-
newSpecChange: true,
709-
onGoingSpecChange: false,
710-
valid: true,
707+
name: "spec change when no on-going operation",
708+
specChange: true,
709+
onGoingOperation: false,
710+
valid: true,
711711
},
712712
{
713-
name: "spec change when on-going spec change",
714-
newSpecChange: true,
715-
onGoingSpecChange: true,
716-
valid: false,
713+
name: "spec change when on-going operation",
714+
specChange: true,
715+
onGoingOperation: true,
716+
valid: false,
717717
},
718718
{
719-
name: "meta change when no on-going spec change",
720-
newSpecChange: false,
721-
onGoingSpecChange: false,
722-
valid: true,
719+
name: "meta change when no on-going operation",
720+
specChange: false,
721+
onGoingOperation: false,
722+
valid: true,
723723
},
724724
{
725-
name: "meta change when on-going spec change",
726-
newSpecChange: false,
727-
onGoingSpecChange: true,
728-
valid: true,
725+
name: "meta change when on-going operation",
726+
specChange: false,
727+
onGoingOperation: true,
728+
valid: true,
729729
},
730730
}
731731

@@ -742,12 +742,10 @@ func TestInternalValidateServiceInstanceUpdateAllowed(t *testing.T) {
742742
},
743743
},
744744
}
745-
if tc.onGoingSpecChange {
746-
oldInstance.Generation = 2
747-
} else {
748-
oldInstance.Generation = 1
745+
oldInstance.Generation = 1
746+
if tc.onGoingOperation {
747+
oldInstance.Status.CurrentOperation = servicecatalog.ServiceInstanceOperationProvision
749748
}
750-
oldInstance.Status.ReconciledGeneration = 1
751749

752750
newInstance := &servicecatalog.ServiceInstance{
753751
ObjectMeta: metav1.ObjectMeta{
@@ -756,17 +754,16 @@ func TestInternalValidateServiceInstanceUpdateAllowed(t *testing.T) {
756754
},
757755
Spec: servicecatalog.ServiceInstanceSpec{
758756
PlanReference: servicecatalog.PlanReference{
759-
ClusterServiceClassExternalName: "test-serviceclass",
760-
ClusterServicePlanExternalName: "test-plan",
757+
ClusterServiceClassExternalName: clusterServiceClassExternalName,
758+
ClusterServicePlanExternalName: clusterServicePlanExternalName,
761759
},
762760
},
763761
}
764-
if tc.newSpecChange {
762+
if tc.specChange {
765763
newInstance.Generation = oldInstance.Generation + 1
766764
} else {
767765
newInstance.Generation = oldInstance.Generation
768766
}
769-
newInstance.Status.ReconciledGeneration = 1
770767

771768
errs := internalValidateServiceInstanceUpdateAllowed(newInstance, oldInstance)
772769
if len(errs) != 0 && tc.valid {

0 commit comments

Comments
 (0)