-
Notifications
You must be signed in to change notification settings - Fork 382
Allow the same user to edit an instance #1872
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
|
@@ -254,13 +256,31 @@ func validateServiceInstanceUpdate(instance *sc.ServiceInstance) field.ErrorList | |
} | ||
|
||
// internalValidateServiceInstanceUpdateAllowed ensures there is not a | ||
// pending update on-going with the spec of the instance before allowing an update | ||
// to the spec to go through. | ||
// pending update on-going with the spec of the instance before allowing an | ||
// update to the spec to go through unless its the same user who made the | ||
// original update. | ||
func internalValidateServiceInstanceUpdateAllowed(new *sc.ServiceInstance, old *sc.ServiceInstance) field.ErrorList { | ||
errors := field.ErrorList{} | ||
if old.Generation != new.Generation && old.Status.CurrentOperation != "" { | ||
errors = append(errors, field.Forbidden(field.NewPath("spec"), "Another update for this service instance is in progress")) | ||
|
||
// If the OriginatingIdentityLocking feature is not set then only allow the | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wrong comment, the condition is reverse: |
||
// same user to edit the Instance. | ||
if utilfeature.DefaultFeatureGate.Enabled(scfeatures.OriginatingIdentityLocking) { | ||
oldUID, newUID := "", "" | ||
|
||
if old.Spec.UserInfo != nil { | ||
oldUID = old.Spec.UserInfo.UID | ||
} | ||
|
||
if new.Spec.UserInfo != nil { | ||
newUID = new.Spec.UserInfo.UID | ||
} | ||
|
||
if old.Generation != new.Generation && old.Status.CurrentOperation != "" && oldUID != newUID { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @duglin I'm not sure if this condition is sufficient for you. The
The condition for locking should not be based on whether there is an operation in progress. It should be based on whether controller has finished processing the current generation (i.e. either succeeded, or failed and won't retry). So I would suggest to change the condition to something more strict. if old.Generation != new.Generation && oldUID != newUID && !isServiceInstanceProcessedAlready(old) { ... and copy (will also need to change P.S. I know that the condition was written this way before, but given that we decided to change it, it's worth fixing it as well. |
||
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")) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,17 @@ const ( | |
// owner: @luksa | ||
// alpha: v0.1.12 | ||
ResponseSchema utilfeature.Feature = "ResponseSchema" | ||
|
||
// OriginatingIdentityLocking controls whether we lock OSB API resources | ||
// that are being updated while we are still processing the update request. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
// Meaning, we're still talking to the Broker to see if the requested | ||
// change will be accepted or not. If locked, then no *other* user is | ||
// allowed to update the resource. | ||
// This lock was added in an attempt to fulfill the requirements | ||
// of the OSBAPI OriginatingIdentity header. | ||
// owner: @duglin | ||
// alpha: v0.1.12 | ||
OriginatingIdentityLocking utilfeature.Feature = "OriginatingIdentityLocking" | ||
) | ||
|
||
func init() { | ||
|
@@ -68,9 +79,10 @@ func init() { | |
// To add a new feature, define a key for it above and add it here. The features will be | ||
// available throughout service catalog binaries. | ||
var defaultServiceCatalogFeatureGates = map[utilfeature.Feature]utilfeature.FeatureSpec{ | ||
PodPreset: {Default: false, PreRelease: utilfeature.Alpha}, | ||
OriginatingIdentity: {Default: false, PreRelease: utilfeature.Alpha}, | ||
AsyncBindingOperations: {Default: false, PreRelease: utilfeature.Alpha}, | ||
NamespacedServiceBroker: {Default: false, PreRelease: utilfeature.Alpha}, | ||
ResponseSchema: {Default: false, PreRelease: utilfeature.Alpha}, | ||
PodPreset: {Default: false, PreRelease: utilfeature.Alpha}, | ||
OriginatingIdentity: {Default: false, PreRelease: utilfeature.Alpha}, | ||
AsyncBindingOperations: {Default: false, PreRelease: utilfeature.Alpha}, | ||
NamespacedServiceBroker: {Default: false, PreRelease: utilfeature.Alpha}, | ||
ResponseSchema: {Default: false, PreRelease: utilfeature.Alpha}, | ||
OriginatingIdentityLocking: {Default: true, PreRelease: utilfeature.Alpha}, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may want to update this comment to reflect how changes by the same user are treated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch- fixed