Skip to content

Commit 52e64db

Browse files
staeblerkibbles-n-bytes
authored andcommitted
Clear out plan ref when plan changed using k8s names (#1553)
1 parent 4b49594 commit 52e64db

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

pkg/registry/servicecatalog/instance/strategy.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ func (instanceRESTStrategy) PrepareForUpdate(ctx genericapirequest.Context, new,
156156
newServiceInstance.Spec.ClusterServicePlanRef = oldServiceInstance.Spec.ClusterServicePlanRef
157157

158158
// Clear out the ClusterServicePlanRef so that it is resolved during reconciliation
159-
if newServiceInstance.Spec.ClusterServicePlanExternalName != oldServiceInstance.Spec.ClusterServicePlanExternalName {
159+
if newServiceInstance.Spec.ClusterServicePlanExternalName != oldServiceInstance.Spec.ClusterServicePlanExternalName ||
160+
newServiceInstance.Spec.ClusterServicePlanName != oldServiceInstance.Spec.ClusterServicePlanName {
160161
newServiceInstance.Spec.ClusterServicePlanRef = nil
161162
}
162163

pkg/registry/servicecatalog/instance/strategy_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,27 @@ func TestInstanceUpdate(t *testing.T) {
103103
shouldGenerationIncrement: true,
104104
shouldPlanRefClear: true,
105105
},
106+
{
107+
name: "plan change using k8s name",
108+
older: func() *servicecatalog.ServiceInstance {
109+
i := getTestInstance()
110+
i.Spec.ClusterServiceClassExternalName = ""
111+
i.Spec.ClusterServicePlanExternalName = ""
112+
i.Spec.ClusterServiceClassName = "class-name"
113+
i.Spec.ClusterServicePlanName = "old-plan-name"
114+
return i
115+
}(),
116+
newer: func() *servicecatalog.ServiceInstance {
117+
i := getTestInstance()
118+
i.Spec.ClusterServiceClassExternalName = ""
119+
i.Spec.ClusterServicePlanExternalName = ""
120+
i.Spec.ClusterServiceClassName = "class-name"
121+
i.Spec.ClusterServicePlanName = "new-plan-name"
122+
return i
123+
}(),
124+
shouldGenerationIncrement: true,
125+
shouldPlanRefClear: true,
126+
},
106127
}
107128

108129
for _, tc := range cases {

0 commit comments

Comments
 (0)