Skip to content

Commit

Permalink
Allow editing service instances again if previous update failed
Browse files Browse the repository at this point in the history
Service catalog now allows users to edit a service instance if the previous
update failed. We were incorrectly blocking it in the UI since we check for
readiness instead of failure.
  • Loading branch information
spadgett committed Nov 7, 2017
1 parent 766b9b8 commit 9c9c926
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
15 changes: 11 additions & 4 deletions app/scripts/controllers/serviceInstance.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ angular.module('openshiftConsole')
var servicePlansPromise;

var serviceInstanceDisplayName = $filter('serviceInstanceDisplayName');
var serviceInstanceReady = $filter('isServiceInstanceReady');
var isServiceInstanceFailed = $filter('isServiceInstanceFailed');

// API Versions
var serviceBindingsVersion = APIService.getPreferredVersion('servicebindings');
Expand Down Expand Up @@ -118,9 +118,16 @@ angular.module('openshiftConsole')
}

var updateSchema = _.get($scope.plan, 'spec.instanceUpdateParameterSchema');
var planUpdatable = (_.size(_.get(updateSchema, 'properties')) > 0) || (_.get($scope.serviceClass, 'spec.planUpdatable') && (_.size($scope.servicePlans) > 1));

$scope.editAvailable = planUpdatable && serviceInstanceReady($scope.serviceInstance) && !_.get($scope.serviceInstance, 'metadata.deletionTimestamp');
var updatable = (_.size(_.get(updateSchema, 'properties')) > 0) || (_.get($scope.serviceClass, 'spec.planUpdatable') && (_.size($scope.servicePlans) > 1));

$scope.editAvailable =
updatable &&
// Instances in failed state are considered permanently failed and shouldn't be updated.
!isServiceInstanceFailed($scope.serviceInstance) &&
// Wait until either the provision or other async operation completes before letting the user edit.
!_.get($scope.serviceInstance, 'status.asyncOpInProgress') &&
// Don't allow editing deleted instances.
!_.get($scope.serviceInstance, 'metadata.deletionTimestamp');
};

var updateParameterSchema = function() {
Expand Down
4 changes: 2 additions & 2 deletions dist/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -6359,7 +6359,7 @@ e.showParameterValues = !e.showParameterValues;
}, e.closeEditDialog = function() {
e.editDialogShown = !1;
};
var m, p, f = [], g = [], v = t("serviceInstanceDisplayName"), h = t("isServiceInstanceReady"), y = a.getPreferredVersion("servicebindings");
var m, p, f = [], g = [], v = t("serviceInstanceDisplayName"), h = t("isServiceInstanceFailed"), y = a.getPreferredVersion("servicebindings");
e.serviceInstancesVersion = a.getPreferredVersion("serviceinstances");
var b = function() {
e.breadcrumbs.push({
Expand Down Expand Up @@ -6389,7 +6389,7 @@ c.warn("Unable to load parameters from secret " + _.get(t, "secretKeyRef.name"),
}, S = function() {
if (e.plan && e.serviceClass && e.serviceInstance) {
var t = _.get(e.plan, "spec.instanceUpdateParameterSchema"), n = _.size(_.get(t, "properties")) > 0 || _.get(e.serviceClass, "spec.planUpdatable") && _.size(e.servicePlans) > 1;
e.editAvailable = n && h(e.serviceInstance) && !_.get(e.serviceInstance, "metadata.deletionTimestamp");
e.editAvailable = n && !h(e.serviceInstance) && !_.get(e.serviceInstance, "status.asyncOpInProgress") && !_.get(e.serviceInstance, "metadata.deletionTimestamp");
}
}, w = function() {
e.parameterFormDefinition = angular.copy(_.get(e.plan, "spec.externalMetadata.schemas.service_instance.update.openshift_form_definition")), e.parameterSchema = _.get(e.plan, "spec.instanceCreateParameterSchema"), C();
Expand Down

0 comments on commit 9c9c926

Please sign in to comment.