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

#1148: Support updates to Instances #1289

Merged
merged 2 commits into from
Oct 5, 2017

Conversation

staebler
Copy link
Contributor

@staebler staebler commented Sep 28, 2017

Closes #1148, #816, #748, #1062, and #1065.

  • Allow parameters and plan to be changed for a ServiceInstance.
  • Send an UpdateInstanceRequest to the Broker when the spec changes.
  • Add UpdateRequests field to ServiceInstance spec that can be bumped to provoke a new UpdateInstanceRequest to the Broker.

@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 28, 2017
@staebler staebler force-pushed the 1148-instance-update branch from 67b0af6 to 3c50265 Compare September 29, 2017 13:25
@staebler staebler changed the title (WIP) #1148: Support updates to Instances #1148: Support updates to Instances Sep 29, 2017
@MHBauer
Copy link
Contributor

MHBauer commented Sep 29, 2017

go vet errors need fixing.

@staebler staebler force-pushed the 1148-instance-update branch from 8f0b718 to b927d37 Compare October 2, 2017 13:51
@pmorie
Copy link
Contributor

pmorie commented Oct 3, 2017

@staebler rebase needed

@nilebox nilebox requested review from nilebox and removed request for nilebox October 3, 2017 13:48
Copy link
Contributor

@nilebox nilebox left a comment

Choose a reason for hiding this comment

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

See the first comments, will review in more detail later

// can be manually incremented by a user to manually trigger an update. This
// allows for parameters to be updated with any out-of-band changes that have
// been made to the secrets from which the parameters are sourced.
UpdateRequests int64
Copy link
Contributor

Choose a reason for hiding this comment

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

if it's non-negative as the comment says, shall we use the uint64 type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#primitive-types

Do not use unsigned integers, due to inconsistent support across languages and libraries. Just validate that the integer is non-negative if that's the case.

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks

allErrs = append(allErrs, internalValidateServiceInstanceUpdateAllowed(new, old)...)
allErrs = append(allErrs, internalValidateServiceInstance(new, false)...)

allErrs = append(allErrs, apivalidation.ValidateImmutableField(new.Spec.ExternalServiceClassName, old.Spec.ExternalServiceClassName, field.NewPath("spec").Child("externalServiceClassName"))...)
Copy link
Contributor

@nilebox nilebox Oct 3, 2017

Choose a reason for hiding this comment

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

We also need to check that the plan hasn't changed if plan updates are not supported (ServiceClass.Spec.PlanUpdatable==false).
If it's costly to validate it there, we can check it before sending an update request to the broker.

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 am not sure about this, but it is my understanding that the validation should not be looking at other resources. The validation should only consider the resource being validated. There is an admission controller [1] that blocks updates to ExternalServicePlanName when the PlanUpdatable field of the service class is false.

[1] https://github.com/kubernetes-incubator/service-catalog/blob/master/plugin/pkg/admission/serviceplan/changevalidator/admission.go

Copy link
Contributor

Choose a reason for hiding this comment

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

@staebler didn't know we have an admission controller for that. then there is no need for checking it again, of course.

// Only send the plan ID if the plan name has changed from what the Broker has
if toUpdate.Status.ExternalProperties == nil ||
toUpdate.Status.InProgressProperties.ExternalServicePlanName != toUpdate.Status.ExternalProperties.ExternalServicePlanName {
planID := servicePlan.Spec.ExternalID
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to check the flag plan_updatable in ServiceClass.Spec.PlanUpdatable

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 don't think that this is the right place to check this. The change to the plan name has already been accepted by the API Server, given the state of the resources at that time. I don't think it is appropriate to ignore the accepted change to the plan name given the state of the resources at this time. We would need to do more than just not send the plan change to the Broker if that were the case. We would also need to somehow revert the plan change in the Spec of the ServiceInstance.

Copy link
Contributor

Choose a reason for hiding this comment

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

There's an admission controller that forbids the plan update.

@staebler staebler force-pushed the 1148-instance-update branch from b927d37 to 2221ffc Compare October 3, 2017 17:57
@staebler staebler force-pushed the 1148-instance-update branch 3 times, most recently from fb6f623 to e7f8c5d Compare October 4, 2017 17:57
@vaikas vaikas added the LGTM1 label Oct 4, 2017
@vaikas
Copy link
Contributor

vaikas commented Oct 4, 2017

This has nothing to do with your PR, nicely injected in there and from diffs easy to reason about. But, we really have to do some refactoring here, having a method that's several hundred lines intertwined with all kinds of different ifs sprinkled in all over makes it really really hard to digest what's going on.

@pmorie
Copy link
Contributor

pmorie commented Oct 4, 2017 via email

@vaikas
Copy link
Contributor

vaikas commented Oct 4, 2017

yes, hence LGTM

@staebler
Copy link
Contributor Author

staebler commented Oct 4, 2017

I also whole-heartedly support refactoring.

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.

Looks pretty good, but there is one fix that is needed re: orphan mitigation.

// Only send the plan ID if the plan name has changed from what the Broker has
if toUpdate.Status.ExternalProperties == nil ||
toUpdate.Status.InProgressProperties.ExternalServicePlanName != toUpdate.Status.ExternalProperties.ExternalServicePlanName {
planID := servicePlan.Spec.ExternalID
Copy link
Contributor

Choose a reason for hiding this comment

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

There's an admission controller that forbids the plan update.

errorProvisionCallFailedReason,
"ClusterServiceBroker returned a failure for provision call; operation will not be retried: "+s)
reason,
fmt.Sprintf("ClusterServiceBroker returned a failure for %v call; operation will not be retried: %v", provisionOrUpdateText, s))

if shouldStartOrphanMitigation(httpErr.StatusCode) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You should only do orphan mitigation here if you're provisioning, not if you're updating.

@staebler staebler force-pushed the 1148-instance-update branch from e7f8c5d to 65ba455 Compare October 5, 2017 00:38
if !apiequality.Semantic.DeepEqual(oldServiceInstance.Spec, newServiceInstance.Spec) {
if utilfeature.DefaultFeatureGate.Enabled(scfeatures.OriginatingIdentity) {
setServiceInstanceUserInfo(newServiceInstance, ctx)
}
newServiceInstance.Generation = oldServiceInstance.Generation + 1
setServiceInstanceReadyFalseCondition(newServiceInstance)
Copy link
Contributor

Choose a reason for hiding this comment

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

In a follow-up, we need to take this out. I'm sorry that I missed it earlier, but update should not affect the status of a resource. It's okay that the ready condition remains set after this - the controller will eventually unset it. Remember, the system is not transactional and only has to eventually converge on the right state.

@pmorie
Copy link
Contributor

pmorie commented Oct 5, 2017

LGTM but we need to correct the status setting in the API server in a follow-up.

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.

6 participants