-
Notifications
You must be signed in to change notification settings - Fork 382
#1147 Store in-progress and external resource properties state #1250
#1147 Store in-progress and external resource properties state #1250
Conversation
be82b70
to
6a75d82
Compare
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.
Looking pretty solid - I have the most concerns about putting the status validations into update validation methods.
pkg/apis/servicecatalog/types.go
Outdated
// ServiceInstancePropertiesState is the state of a ServiceInstance that | ||
// the ServiceBroker knows about. | ||
type ServiceInstancePropertiesState struct { | ||
// PlanName is the name of the plan that the broker knows this |
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.
We should probably clarify that this is the human readable plan name from the OSB API.
pkg/apis/servicecatalog/types.go
Outdated
|
||
// InProgressProperties is the properties state for which there is a | ||
// provision or update action in progress. | ||
InProgressProperties *ServiceInstancePropertiesState |
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 might clarify that it will not be set for deprovision operations
@@ -37,7 +44,12 @@ func internalValidateServiceInstanceCredential(binding *sc.ServiceInstanceCreden | |||
validateServiceInstanceCredentialName, | |||
field.NewPath("metadata"))...) | |||
allErrs = append(allErrs, validateServiceInstanceCredentialSpec(&binding.Spec, field.NewPath("Spec"), create)...) | |||
|
|||
allErrs = append(allErrs, validateServiceInstanceCredentialStatus(&binding.Status, field.NewPath("Status"), create)...) |
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.
I think this should be in an update validation. For create current operation shouldn't be set at all.
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.
always call field.NewPath
with names starting with lowercase
allErrs = append(allErrs, field.NotSupported(fldPath.Child("currentOperation"), status.CurrentOperation, validValues)) | ||
} | ||
|
||
switch status.CurrentOperation { |
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.
Is this switch statement necessary at all?
validValues[i] = string(operation) | ||
i++ | ||
} | ||
allErrs = append(allErrs, field.NotSupported(fldPath.Child("currentOperation"), status.CurrentOperation, validValues)) |
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.
I think this should be field.Invalid
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.
I thought this was exactly what field.NotSupported was intended for. We have enumerated values and we are enforcing that the field is one of those values.
With that being said, I don't really have a dog in the fight. I am fine either way. If you feel that it should be field.Invalid, I have no problem changing it.
@@ -39,6 +47,11 @@ func internalValidateServiceInstance(instance *sc.ServiceInstance, create bool) | |||
field.NewPath("metadata"))...) | |||
allErrs = append(allErrs, validateServiceInstanceSpec(&instance.Spec, field.NewPath("Spec"), create)...) | |||
allErrs = append(allErrs, validateServiceInstanceStatus(&instance.Status, field.NewPath("Status"), create)...) | |||
if instance.Status.ReconciledGeneration == instance.Generation { |
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.
I think this should go into a separate update validation.
// ongoing | ||
if spec.AsyncOpInProgress { | ||
for _, c := range spec.Conditions { | ||
if !validServiceInstanceOperations[status.CurrentOperation] { |
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.
Why not just have a string with the current valid values instead of building it each time?
pkg/controller/controller_binding.go
Outdated
} | ||
|
||
var rawParametersWithRedaction *runtime.RawExtension | ||
if parametersWithSecretsRedacted != nil { |
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.
seems like this can be part of the above if statement.
We should validate that the parameters and redactedParameters are either both not-nil or both nil.
pkg/controller/controller_binding.go
Outdated
@@ -370,6 +422,8 @@ func (c *controller) reconcileServiceInstanceCredential(binding *v1alpha1.Servic | |||
return err | |||
} | |||
|
|||
toUpdate.Status.ExternalProperties = toUpdate.Status.InProgressProperties |
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.
This method is long enough that a quality saying "Now we care handling the success case" might be helpful.
assertServiceInstanceCredentialExternalPropertiesUnchanged(t, obj, originalBinding) | ||
} | ||
|
||
func assertServiceInstanceCredentialInProgressPropertiesNil(t *testing.T, obj runtime.Object) { |
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.
I think it would be good to have explanatory godoc for these methods but I do not want to block this PR on it. Will you promise to do it in a follow-up?
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.
I promise. I will create an issue for it to remind myself.
bcce810
to
fabd5a6
Compare
pkg/apis/servicecatalog/types.go
Outdated
// Deprovision, this will be nil. | ||
InProgressProperties *ServiceInstancePropertiesState | ||
|
||
// ExternalProperties is the properites state of the ServiceInstance which the |
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.
nit: properties
pkg/apis/servicecatalog/types.go
Outdated
// PlanName is the name of the plan that the broker knows this | ||
// ServiceInstance to be on. This is the human readable plan name from the | ||
// OSB API. | ||
PlanName string |
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.
I'd prefer to call it ExternalServicePlanName just like what we decided to call it on ServiceInstance.Spec for consistency.
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.
+1 to that
// PlanName is the name of the plan that the broker knows this | ||
// ServiceInstance to be on. This is the human readable plan name from the | ||
// OSB API. | ||
PlanName string `json:"planName"` |
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.
ExternalServicePlanName for consistency
fabd5a6
to
f552d27
Compare
Looks good just needs a rebase. |
f552d27
to
046f7ef
Compare
pkg/apis/servicecatalog/types.go
Outdated
// ExternalServicePlanName is the name of the plan that the broker knows this | ||
// ServiceInstance to be on. This is the human readable plan name from the | ||
// OSB API. | ||
ExternalServicePlanName string `json:"externalServicePlanName"` |
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.
no json tags on internal
c4307a6
to
603d8db
Compare
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.
LGTM, though please try to keep the scope of PRs as focused as possible! This is really two changes in one.
I'll merge after rebase & tests pass. |
603d8db
to
aa358be
Compare
Closes #1147.
Closes #882.