-
Notifications
You must be signed in to change notification settings - Fork 232
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
Fix the binding list update failure in service instance rows on the overview #1410
Conversation
d6a966a
to
2fc9393
Compare
Eh, updated & added the check anyway. Better be safe. |
var prevBindings = []; | ||
row.$doCheck = function() { | ||
var bindings = getBindings(); | ||
if(prevBindings.length !== bindings.length) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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>
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
6dce473
to
fd9a533
Compare
Fixes the following:
|
@@ -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) { |
There was a problem hiding this comment.
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');
app/scripts/filters/resources.js
Outdated
@@ -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) { |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
app/views/new-overview.html
Outdated
@@ -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]" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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}}"> |
There was a problem hiding this comment.
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
525af44
to
10e91cb
Compare
@spadget i think i got all of the items, but doing a little more testing. Having trouble with my instances getting stuck. |
app/scripts/filters/resources.js
Outdated
@@ -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) |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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}}"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mind adding the canI
check? Users with view
access typically can't get secrets.
There was a problem hiding this comment.
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.
app/scripts/filters/resources.js
Outdated
@@ -1084,7 +1084,18 @@ angular.module('openshiftConsole') | |||
return lastFinishTime; | |||
}; | |||
}) | |||
// gets the first status condition. | |||
.filter('statusCondition', function() { |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, working on this.
There was a problem hiding this comment.
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.
10e91cb
to
cf21a96
Compare
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. |
<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}} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -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'); |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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 😄
FYI I pulled down your PR and validated switching to _.groupBy works
…On Wed, Apr 12, 2017 at 1:32 PM, Sam Padgett ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In app/scripts/controllers/newOverview.js
<#1410 (comment)>
:
> @@ -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');
Should be _.groupBy not _.indexBy (my fault)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1410 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABZk7Uy_MwURPJlOGmoX-F9apxTFdoaYks5rvQqVgaJpZM4M5Gox>
.
|
Not sure why we would keep both in that case. Just keep statusCondition
…On Wed, Apr 12, 2017 at 2:43 PM, Ben Petersen ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In app/scripts/filters/resources.js
<#1410 (comment)>
:
> @@ -1084,7 +1084,18 @@ angular.module('openshiftConsole')
return lastFinishTime;
};
})
+ // gets the first status condition.
.filter('statusCondition', function() {
statusConditionIs filter is the original code, so I aliased
statusCondition back to it & updated my calls.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1410 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABZk7U9hAjIgzhac39MO1-oR5-qU037tks5rvRtcgaJpZM4M5Gox>
.
|
cf21a96
to
fd8e795
Compare
If we are going to show the error from the API lets show the full error
message, we don't typically truncate it
…On Wed, Apr 12, 2017 at 2:30 PM, Ben Petersen ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In app/views/overview/_service-instance-row.html
<#1410 (comment)>
:
> <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}}
I'm opting for #2 <#2>,
the less verbose. Objections @jwforres <https://github.com/jwforres>
@spadgett <https://github.com/spadgett> ?
[image: screen shot 2017-04-12 at 2 25 38 pm]
<https://cloud.githubusercontent.com/assets/280512/24973378/7ca0835c-1f8c-11e7-9cac-e77fde3a3468.png>
[image: screen shot 2017-04-12 at 2 29 34 pm]
<https://cloud.githubusercontent.com/assets/280512/24973377/7c9fb9e0-1f8c-11e7-9a40-54686ed39271.png>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1410 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABZk7cao5BsoDMxN1S9Ss4v4uFJbMyHsks5rvRg3gaJpZM4M5Gox>
.
|
fd8e795
to
12a57cf
Compare
Ok cool, got those. |
12a57cf
to
214d770
Compare
& rebased. |
one more tweak coming |
214d770
to
d42602a
Compare
@@ -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'}); |
There was a problem hiding this comment.
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
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'); |
There was a problem hiding this comment.
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?
d42602a
to
d3293b3
Compare
@@ -147,10 +147,46 @@ angular.module("openshiftConsole") | |||
return alerts; | |||
}; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
d3293b3
to
4fec96c
Compare
[merge] |
😂 |
4fec96c
to
84fcfd6
Compare
[merge] |
Looks like a flake [merge]
…On Apr 12, 2017 6:23 PM, "OpenShift Bot" ***@***.***> wrote:
Origin Web Console Merge Results: FAILURE (https://ci.openshift.redhat.
com/jenkins/job/test_pull_requests_origin_web_console/1222/) (Base
Commit: aa4a228
<aa4a228>
)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1410 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABZk7cgczNhSAz6UZ6kG86_Fm6lSoHErks5rvU7NgaJpZM4M5Gox>
.
|
Evaluated for origin web console merge up to 84fcfd6 |
Origin Web Console Merge Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin_web_console/1223/) (Base Commit: aa4a228) |
$onChanges
does not see properties of objectrow.state
changegetBindings
to$doCheck
solves the problemrow. instanceBindings
could be slightly more performant as it would ensure no DOM updates, but that may be overkill in this situation.