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

#1147 Store in-progress and external resource properties state #1250

Merged
merged 1 commit into from
Sep 28, 2017

Conversation

staebler
Copy link
Contributor

@staebler staebler commented Sep 21, 2017

Closes #1147.
Closes #882.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Sep 21, 2017
@staebler staebler force-pushed the 1147-properties-by-view branch 3 times, most recently from be82b70 to 6a75d82 Compare September 25, 2017 21:22
Copy link
Contributor

@pmorie pmorie left a 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.

// 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
Copy link
Contributor

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.


// InProgressProperties is the properties state for which there is a
// provision or update action in progress.
InProgressProperties *ServiceInstancePropertiesState
Copy link
Contributor

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)...)
Copy link
Contributor

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.

Copy link
Contributor

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 {
Copy link
Contributor

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))
Copy link
Contributor

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

Copy link
Contributor Author

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 {
Copy link
Contributor

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] {
Copy link
Contributor

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?

}

var rawParametersWithRedaction *runtime.RawExtension
if parametersWithSecretsRedacted != nil {
Copy link
Contributor

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.

@@ -370,6 +422,8 @@ func (c *controller) reconcileServiceInstanceCredential(binding *v1alpha1.Servic
return err
}

toUpdate.Status.ExternalProperties = toUpdate.Status.InProgressProperties
Copy link
Contributor

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) {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@staebler staebler changed the title WIP: #1147 Store in-progress and external resource properties state #1147 Store in-progress and external resource properties state Sep 26, 2017
@pmorie pmorie added the LGTM1 label Sep 26, 2017
@staebler staebler force-pushed the 1147-properties-by-view branch from bcce810 to fabd5a6 Compare September 26, 2017 20:06
// Deprovision, this will be nil.
InProgressProperties *ServiceInstancePropertiesState

// ExternalProperties is the properites state of the ServiceInstance which the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: properties

// 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
Copy link
Contributor

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.

Copy link
Contributor

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"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ExternalServicePlanName for consistency

@staebler staebler force-pushed the 1147-properties-by-view branch from fabd5a6 to f552d27 Compare September 27, 2017 16:05
@vaikas
Copy link
Contributor

vaikas commented Sep 27, 2017

Looks good just needs a rebase.

@staebler staebler force-pushed the 1147-properties-by-view branch from f552d27 to 046f7ef Compare September 28, 2017 00:02
// 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"`
Copy link
Contributor

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

Copy link
Contributor

@kibbles-n-bytes kibbles-n-bytes left a 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.

@vaikas vaikas added the LGTM2 label Sep 28, 2017
@vaikas
Copy link
Contributor

vaikas commented Sep 28, 2017

I'll merge after rebase & tests pass.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. LGTM1 LGTM2 size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants