Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Commit

Permalink
add a feature gate to disable instance locking
Browse files Browse the repository at this point in the history
Signed-off-by: Doug Davis <[email protected]>
  • Loading branch information
Doug Davis committed Mar 28, 2018
1 parent 6910fc1 commit 00ea8f4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
27 changes: 17 additions & 10 deletions pkg/apis/servicecatalog/validation/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (

sc "github.com/kubernetes-incubator/service-catalog/pkg/apis/servicecatalog"
"github.com/kubernetes-incubator/service-catalog/pkg/controller"
scfeatures "github.com/kubernetes-incubator/service-catalog/pkg/features"
utilfeature "k8s.io/apiserver/pkg/util/feature"
)

// validateServiceInstanceName is the validation function for Instance names.
Expand Down Expand Up @@ -260,20 +262,25 @@ func validateServiceInstanceUpdate(instance *sc.ServiceInstance) field.ErrorList
func internalValidateServiceInstanceUpdateAllowed(new *sc.ServiceInstance, old *sc.ServiceInstance) field.ErrorList {
errors := field.ErrorList{}

oldUID := ""
newUID := ""
// If the DisableInstanceLocking feature is not set then only allow the
// same user to edit the Instance.
if !utilfeature.DefaultFeatureGate.Enabled(scfeatures.DisableInstanceLocking) {
oldUID, newUID := "", ""

if old.Spec.UserInfo != nil {
oldUID = old.Spec.UserInfo.UID
}
if old.Spec.UserInfo != nil {
oldUID = old.Spec.UserInfo.UID
}

if new.Spec.UserInfo != nil {
newUID = new.Spec.UserInfo.UID
}
if new.Spec.UserInfo != nil {
newUID = new.Spec.UserInfo.UID
}

if old.Generation != new.Generation && old.Status.CurrentOperation != "" && oldUID != newUID {
errors = append(errors, field.Forbidden(field.NewPath("spec"), "Another update for this service instance is in progress"))
}

if old.Generation != new.Generation && old.Status.CurrentOperation != "" && oldUID != newUID {
errors = append(errors, field.Forbidden(field.NewPath("spec"), "Another update for this service instance is in progress"))
}

if old.Spec.ClusterServicePlanExternalName != new.Spec.ClusterServicePlanExternalName && new.Spec.ClusterServicePlanRef != nil {
errors = append(errors, field.Forbidden(field.NewPath("spec").Child("clusterServicePlanRef"), "clusterServicePlanRef must not be present when clusterServicePlanExternalName is being changed"))
}
Expand Down
7 changes: 7 additions & 0 deletions pkg/features/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ const (
// owner: @eriknelson & @jeremyrickard
// alpha: v0.1.10
NamespacedServiceBroker utilfeature.Feature = "NamespacedServiceBroker"

// DisableInstanceLocking disables the locking of Instances so that
// more than one user can modify an Instance at a time.
// owner: @duglin
// alpha: v0.1.12
DisableInstanceLocking utilfeature.Feature = "DisableInstanceLocking"
)

func init() {
Expand All @@ -66,4 +72,5 @@ var defaultServiceCatalogFeatureGates = map[utilfeature.Feature]utilfeature.Feat
OriginatingIdentity: {Default: false, PreRelease: utilfeature.Alpha},
AsyncBindingOperations: {Default: false, PreRelease: utilfeature.Alpha},
NamespacedServiceBroker: {Default: false, PreRelease: utilfeature.Alpha},
DisableInstanceLocking: {Default: false, PreRelease: utilfeature.Alpha},
}

0 comments on commit 00ea8f4

Please sign in to comment.