Skip to content

Fix the binding list update failure in service instance rows on the overview #1410

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

Merged
merged 1 commit into from
Apr 12, 2017

Conversation

benjaminapetersen
Copy link
Contributor

  • $onChanges does not see properties of object row.state change
  • moving getBindings to $doCheck solves the problem
  • this does call the function on every digest loop, but it does not trigger infinite digests
    • it is possible that storing a temp reference to the old bindings & testing against the new before assigning to row. instanceBindings could be slightly more performant as it would ensure no DOM updates, but that may be overkill in this situation.

@benjaminapetersen
Copy link
Contributor Author

Eh, updated & added the check anyway. Better be safe.

var prevBindings = [];
row.$doCheck = function() {
var bindings = getBindings();
if(prevBindings.length !== bindings.length) {
Copy link
Member

Choose a reason for hiding this comment

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

a length check isn't sufficient, you'll lose updates to the status of a binding

Copy link
Member

Choose a reason for hiding this comment

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

Instead of having to filter row.state.bindings every digest loop, can we keep a map of bindings by instance ref name updated in the overview watch callback? Then $doCheck might not be necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jwforres this just hits adding the additional binding row, I'm working on looking at the statuses now.

@spadgett i can do that, assuming that we would want something like this then:

<service-instance-row
  api-object="serviceInstance"
  bindings="bindingsByRef[serviceInstance.metadata.name]"></service-instance-row>

Copy link
Member

Choose a reason for hiding this comment

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

@benjaminapetersen that works for me and should perform better

Copy link
Contributor Author

Choose a reason for hiding this comment

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

&& overview.state.bindingsByInstanceRef, where the other maps seem to be.

@benjaminapetersen
Copy link
Contributor Author

@jwforres @spadgett updated, this includes a couple filter additions that I'm using for other updates coming to the service instances.

@benjaminapetersen
Copy link
Contributor Author

Fixes the following:

  • bindings will now update on overview after "bind" action
  • secret link will not appear until the binding action completes, will show "Pending"

@@ -1263,6 +1264,13 @@ function OverviewController($scope,
resource: 'bindings'
}, context, function(bindings) {
state.bindings = bindings.by('metadata.name');
state.bindingsByInstanceRef = _.reduce(state.bindings, function(result, next) {
Copy link
Member

Choose a reason for hiding this comment

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

Can this just be

state.bindingsByInstanceRef = _.indexBy(state.bindings, 'spec.instanceRef.name');

@@ -1093,6 +1105,13 @@ angular.module('openshiftConsole')
return _.find(_.get(apiObject, 'status.conditions'), {type: type});
};
})
// returns true/false based on the presence of a Ready status conditions
// statusConditionReady(obj)
.filter('statusConditionReady', function(statusConditionFilter) {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I might give this a name to make it clear it's specific to service catalog items. Maybe isInstanceOrBindingReady since it doesn't apply to other types (a bit long I know)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Long, but works, I'll update.

Copy link
Member

Choose a reason for hiding this comment

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

You could also have two names for the filter. Call this isServiceInstanceReady and then have an isBindingReady filter that returns isServiceInstanceReadyFilter.

These might be useful in origin-web-common, but don't worry about that for this PR.

@@ -365,6 +365,7 @@ <h2 ng-if="overview.state.serviceInstances">
<service-instance-row
ng-repeat="serviceInstance in overview.state.orderedServiceInstances"
api-object="serviceInstance"
bindings="overview.state.bindingsByInstanceRef[serviceInstance.metadata.name]"
Copy link
Member

Choose a reason for hiding this comment

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

Generally the items in state are meant to be accessed directly by the row. So maybe bindingsByInstanceRef should just be on overview directly.

But I'm OK either way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok cool, I can move that.

};

row.getSecretForBinding = function(binding) {
return binding && _.get(row, ['state', 'secrets', binding.spec.secretName]);
};

row.showSecretLink = function(binding) {
return statusConditionReady(binding);
Copy link
Member

Choose a reason for hiding this comment

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

I think it's more clear if you just call the filter directly in the view. I was confused why !showSecretLink() means show a pending icon, whereas

          <span ng-if="!(binding | statusConditionReady)">
             <status-icon status="'Pending'"></status-icon> Pending
          </span>

is pretty clear

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree, I'll update. I originally had the filter logic in that function, factored it out to a filter but should have also made this change.

</span>
<a
ng-if="row.showSecretLink(binding)"
href="{{row.getSecretForBinding(binding) | navigateResourceURL}}">
Copy link
Member

Choose a reason for hiding this comment

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

Probably worth a canI check if you can view secrets

@benjaminapetersen benjaminapetersen force-pushed the binding-update branch 2 times, most recently from 525af44 to 10e91cb Compare April 12, 2017 03:10
@benjaminapetersen
Copy link
Contributor Author

@spadget i think i got all of the items, but doing a little more testing. Having trouble with my instances getting stuck.

@@ -1093,6 +1104,16 @@ angular.module('openshiftConsole')
return _.find(_.get(apiObject, 'status.conditions'), {type: type});
};
})
// returns true/false based on the presence of a Ready status conditions
// statusConditionReady(obj)
Copy link
Member

Choose a reason for hiding this comment

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

Looks like the comment has the old filter name.

return _.get(statusConditionFilter(apiObject, 'Ready'), 'status') === 'True';
};
})
.filter('isBindingReady', function(isServiceInstanceReadyFilter) {
Copy link
Member

Choose a reason for hiding this comment

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

👍 I think these names read a lot better, thanks

</span>
<a
ng-if="binding | isBindingReady"
href="{{row.getSecretForBinding(binding) | navigateResourceURL}}">
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, already did. let me push that up. Sorry, didn't update after a bit more tinkering last night.

@@ -1084,7 +1084,18 @@ angular.module('openshiftConsole')
return lastFinishTime;
};
})
// gets the first status condition.
.filter('statusCondition', function() {
Copy link
Member

Choose a reason for hiding this comment

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

Hm, you can't change the behavior of this filter since it's used elsewhere (bind dialog)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ill do a search again, but I thought I updated the other refrences. Let me check.

Copy link
Member

Choose a reason for hiding this comment

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

No I disagree with this behavior change. You may at any point have multiple status conditions, you need to actually ask for the one you want.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, working on this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

statusConditionIs filter is the original code, so I aliased statusCondition back to it & updated my calls.

@benjaminapetersen
Copy link
Contributor Author

Pushed again this morning, but give me a few, rebuilding my env as things blew up. I want to test a bit more before another review.

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 12, 2017
<notification-icon ng-if="!row.expanded" alerts="row.notifications"></notification-icon>
<span ng-if="!row.isReady">
<status-icon status="row.status"></status-icon> {{row.statusReason | sentenceCase}}
Copy link
Member

Choose a reason for hiding this comment

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

it is unlikely status-icon is going to work with the condition reasons we are getting back, and at any time they might add more and break us / cause us to show the ? I would prefer we check for known failure conditions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And this should probably be handled in the <notification-icon> above like other alerts, correct?

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'm opting for #2, the less verbose. Objections @jwforres @spadgett ?
screen shot 2017-04-12 at 2 25 38 pm
screen shot 2017-04-12 at 2 29 34 pm

@@ -1263,6 +1263,7 @@ function OverviewController($scope,
resource: 'bindings'
}, context, function(bindings) {
state.bindings = bindings.by('metadata.name');
overview.bindingsByInstanceRef = _.indexBy(state.bindings, 'spec.instanceRef.name');
Copy link
Member

Choose a reason for hiding this comment

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

Should be _.groupBy not _.indexBy (my fault)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Heh. Was messing with that before I read this. Getting only 1 item every time was confusing 😄

@jwforres
Copy link
Member

jwforres commented Apr 12, 2017 via email

@jwforres
Copy link
Member

jwforres commented Apr 12, 2017 via email

@jwforres
Copy link
Member

jwforres commented Apr 12, 2017 via email

@benjaminapetersen
Copy link
Contributor Author

Ok cool, got those.

@benjaminapetersen
Copy link
Contributor Author

& rebased.

@benjaminapetersen
Copy link
Contributor Author

one more tweak coming

@@ -1252,6 +1253,20 @@ function OverviewController($scope,
resource: 'instances'
}, context, function(serviceInstances) {
state.serviceInstances = serviceInstances.by('metadata.name');
_.each(state.serviceInstances, function(instance) {
var failConditions = _.filter(instance.status.conditions, {status: 'False'});
Copy link
Member

Choose a reason for hiding this comment

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

a condition with status false is not necessarily a failure condition

@benjaminapetersen
Copy link
Contributor Author

ok. think this is ready for one more pass?

@@ -21,6 +22,8 @@ function ServiceInstanceRow($filter, DataService, rowMethods, $uibModal) {
_.extend(row, rowMethods.ui);

var getErrorDetails = $filter('getErrorDetails');
var statusCondition = $filter('statusCondition');
Copy link
Member

Choose a reason for hiding this comment

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

is anything actually referencing these?

@@ -147,10 +147,46 @@ angular.module("openshiftConsole")
return alerts;
};

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jwforres @spadgett closer to the mark adding this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updating to _.find since _.filter doesn't make sense here.

@jwforres
Copy link
Member

[merge]

@benjaminapetersen
Copy link
Contributor Author

😂

@openshift-bot openshift-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 12, 2017
@jwforres
Copy link
Member

[merge]

@jwforres
Copy link
Member

jwforres commented Apr 12, 2017 via email

@openshift-bot
Copy link

Evaluated for origin web console merge up to 84fcfd6

@openshift-bot
Copy link

openshift-bot commented Apr 12, 2017

Origin Web Console Merge Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin_web_console/1223/) (Base Commit: aa4a228)

@openshift-bot openshift-bot merged commit dd72cfb into openshift:master Apr 12, 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.

4 participants