Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete bindings when deleting a service instance #2150

Merged
merged 1 commit into from
Sep 26, 2017

Conversation

jeff-phillips-18
Copy link
Member

Fixes #2149

@jeff-phillips-18
Copy link
Member Author

image

image

Copy link
Member

@spadgett spadgett left a comment

Choose a reason for hiding this comment

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

It's still possible to delete the service instance... It just won't complete until the bindings are deleted as well. Do we want to block it completely in the UI or just warn?

@ncameronbritt

};

if (CatalogService.SERVICE_CATALOG_ENABLED) {
DataService.list(resource, context, function (bindings) {
Copy link
Member

Choose a reason for hiding this comment

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

I believe everywhere we call this, we already have a list of the bindings. I'd rather just pass those in if we have them.

Copy link
Member Author

Choose a reason for hiding this comment

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

The service instance page does not have the bindings. I can take them optionally and only retrieve if not given.

Copy link
Member

Choose a reason for hiding this comment

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

The service instance page does not have the bindings.

Hey @jeff-phillips-18 I'm OK with it in that case.

I want to look at the instance page anyway later. It looks like it's requesting service classes twice, and that's potentially a lot of data.

In general, I think it's better for the page controllers to get the data and pass them down to the components to avoid requesting things more than once.

Copy link
Member Author

Choose a reason for hiding this comment

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

I can take a look at that as part of this. Basically its the ResourceServiceBindings that gets the bindings for the service instance page (an all the 'application' pages. I can update that logic as well if you'd like.

Copy link
Member

Choose a reason for hiding this comment

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

It might be better to wait for #2155 since I have some changes to instance page and resource service bindings component in flight :/

Copy link
Member Author

Choose a reason for hiding this comment

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

Pushed changes to only get bindings when not passed. Holding off on updating all the controllers using the ResourceServiceBindings.

});
};

var deprovision = function (apiObject) {
Copy link
Member

Choose a reason for hiding this comment

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

I realize this isn't new, but I'd rather call the parameter serviceInstance because the function is very specific to instances. apiObject sounds like any object.

<div class="modal-resource-action">
<div class="modal-body">
<h1>
<span class="pficon pficon-warning-triangle-o"></span>
Copy link
Member

Choose a reason for hiding this comment

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

<span class="pficon pficon-warning-triangle-o" aria-hidden="true"></span>
<span class="sr-only">warning</span>

// TODO - remove once this is resolved https://github.com/kubernetes-incubator/service-catalog/issues/942
var opts = {
propagationPolicy: null
};
Copy link
Member

Choose a reason for hiding this comment

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

Not related to this PR, but we should double-check that this isn't needed for bindings as well. Right now we're using delete-link for bindings and in some cases and not passing propogationPolicy: null

Copy link
Member

Choose a reason for hiding this comment

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

resolve: {
modalConfig: function() {
return {
title: "Unable to Deprovision",
Copy link
Member

Choose a reason for hiding this comment

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

We call the action "Delete" in the UI, so I'd be consistent in the messages we use (in the dialog and notifications).

@spadgett
Copy link
Member

Do we want to check if binding has a deletion timestamp? Otherwise you will have to wait for all the bindings to be deleted from the system completely before deleting the service instance, which could take a while depending on the broker. I'd rather be able to to mark everything deleted once and let it finish whenever it's done.

I'm starting to think it should just be a warning and not block.

@ncameronbritt
Copy link

The original idea was to block the user from deleting until the bindings had been deleted, but I'm not sure we considered the possibility that deleting the bindings could take some time.

I think it would be a better experience to allow users to delete the bindings from that dialog, rather than just telling them to go do it. The bindings would be then marked for deletion and the deprovision could go ahead as @spadgett suggested. Maybe something like this?
screen shot 2017-09-23 at 10 10 15 am

Related but probably outside of this scope, should we even be showing things that are marked for deletion in the UI? I know it doesn't work this way in practice, but deleting seems like an action that should be able to happen more or less instantaneously. Do users need to care about things they deleted but which are just hanging around waiting for the system to delete them?

@ncameronbritt
Copy link

ncameronbritt commented Sep 23, 2017 via email

@jeff-phillips-18
Copy link
Member Author

@ncameronbritt How about the title?

@jeff-phillips-18
Copy link
Member Author

@ncameronbritt @spadgett How about something like:

image

@ncameronbritt
Copy link

@spadgett and I were just talking about this. I think the best experience is to simply delete the bindings for the user. Deleting the service will also delete any deployments created by the service, and there's no reason for the user to think that bindings needed to be treated in a special way, and a binding doesn't have any value without the service.

Maybe it makes sense to add a sentence like we have here: "$service and its data will no longer be available to your application."

@jeff-phillips-18 jeff-phillips-18 changed the title Do not attempt service instance deletion if it has bindings Delete bindings when deleting a service instance Sep 25, 2017
@jeff-phillips-18
Copy link
Member Author

Updated to automatically delete bindings when deleting a service instance (updated PR title as well).
Confirmation Dialog:
image

@ncameronbritt
Copy link

Works for me. I would probably change "It cannot be undone" to "This cannot be undone." And in the sentence before it should be "your applications".

@jeff-phillips-18
Copy link
Member Author

I would probably change "It cannot be undone" to "This cannot be undone."

This is in the delete utility code (been there for a while). I can change it, but it would change for most deletion confirmation dialogs. @ncameronbritt Please advise.

@jeff-phillips-18
Copy link
Member Author

@spadgett Also added checks to not show the "no bindable services" message when the object is either a service instance or it is marked for deletion. Removed the "Create Binding" link when the object is marked for deletion.

var resource = {
group: 'servicecatalog.k8s.io',
resource: 'serviceinstancecredentials'
};
Copy link
Member

Choose a reason for hiding this comment

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

We should probably start switching to

var resource = APIService.getPreferredVersion('serviceinstancecredentials');

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

var resource = {
group: 'servicecatalog.k8s.io',
resource: 'serviceinstances'
};
Copy link
Member

Choose a reason for hiding this comment

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

var resource = APIService.getPreferredVersion('serviceinstances');

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

var resource = {
group: 'servicecatalog.k8s.io',
resource: 'serviceinstancecredentials'
};
Copy link
Member

Choose a reason for hiding this comment

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

var resource = APIService.getPreferredVersion('serviceinstancecredentials');

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

});
}

return deferred.promise;
Copy link
Member

Choose a reason for hiding this comment

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

You can just return the promise from DataService.list instead of creating your own deferred.

    return DataService.list(resource, context, function (serviceBindings) {
      bindings = serviceBindings.by('metadata.name');
      return BindingService.getBindingsForResource(bindings, apiObject);
    });

Copy link
Member Author

Choose a reason for hiding this comment

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

@spadgett What comes back from the promise is not the bindings manipulated by the callback function. Maybe I'm doing something else wrong?

Copy link
Member

Choose a reason for hiding this comment

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

Sorry my JS was wrong:

   return DataService.list(resource, context).then(function(serviceBindings) {
      bindings = serviceBindings.by('metadata.name');
      return BindingService.getBindingsForResource(bindings, apiObject);
    });

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yes, that makes sense. Sorry, I should have seen that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed. Thanks @spadgett


getBindingsIfNecessary(apiObject, bindings).then(function(serviceBindings) {
_.each(serviceBindings, function (binding) {
if (!binding.metadata.deletionTimestamp) {
Copy link
Member

@spadgett spadgett Sep 26, 2017

Choose a reason for hiding this comment

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

This is a style nit, but I personally find early returns easier to reason about.

if (binding.metadata.deletionTimestamp) {
  // The binding is already marked for deletion.
  return;
}

// <code to delete the binding>

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@ncameronbritt
Copy link

@jeff-phillips-18 I don't feel that strongly about "this" vs. "it", so if it's going to change a bunch of other stuff, I'd say leave it as is for now, and we can address the language change taking into account all of the different contexts in which it occurs later, if we feel like we need to.

Copy link
Member

@spadgett spadgett left a comment

Choose a reason for hiding this comment

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

Thanks @jeff-phillips-18 looks good

@spadgett
Copy link
Member

[merge]

@openshift-bot
Copy link

Evaluated for origin web console merge up to 1056510

@openshift-bot
Copy link

openshift-bot commented Sep 26, 2017

Origin Web Console Merge Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_request_origin_web_console/272/) (Base Commit: b92abe5) (PR Branch Commit: 1056510)

@openshift-bot openshift-bot merged commit c6db605 into openshift:master Sep 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants