Conversation
| @@ -1,5 +1,9 @@ | |||
| {{#if (eq @item.Name '* (All Services)')}} | |||
| <a data-test-topology-metrics-card class="topology-metrics-card" href={{href-to 'dc.services.index'}}> | |||
| {{#if @item.Empty}} | |||
There was a problem hiding this comment.
It was easier to send an attribute then matching all the names.
|
|
||
| {{#each @items as |item|}} | ||
| {{#if (or (not item.Intention.Allowed) item.Intention.HasPermissions)}} | ||
| {{#if (and (not item.Empty) (or (not item.Intention.Allowed) item.Intention.HasPermissions))}} |
There was a problem hiding this comment.
Added this in so the lines wouldn't get a Deny or L7 button on them.
| class="topology-container consul-topology-metrics" | ||
| > | ||
| {{#if (gt @topology.Downstreams.length 0)}} | ||
| {{#if (gt this.downstreams.length 0)}} |
There was a problem hiding this comment.
This conditional still need to exist in case there are zero Downstreams but there are some Upstreams, and vice versa.
| {{did-update this.setHeight 'downstream-lines' @topology.Downstreams}} | ||
| {{did-update this.setHeight 'downstream-lines' this.downstreams}} | ||
| > | ||
| {{#if (not this.emptyColumn)}} |
There was a problem hiding this comment.
I had to create this attribute specifically for the downstream column because it groups all the Downstream cards together with a DC and tooltip at the top.
| const items = [...downstreams]; | ||
| const noDependencies = get(this.args.topology, 'noDependecies'); | ||
|
|
||
| if (!this.env.var('CONSUL_ACLS_ENABLED')) { |
There was a problem hiding this comment.
@johncowen My ACLs disabled test is failing and I wonder if it has to do with this implementation. I implemented this following what was done in the abilities files.
Is the test failing because it should be enable?
There was a problem hiding this comment.
Looking at the existing test that uses this functionality and the step itself, the step seems to act on HTTP requests only. It was originally used to mock out a HTTP API with disabled ACLs (in order to respond with a 401 status) so that makes sense also.
It looks like here you need to mock out settings during Ember's bootup process, basically mock out the settings we add into the index.html file. Ember's test runner instantiates with ACLs enabled for the frontend it seems and once set that cannot be changed because during testing Ember doesn't refresh the page like proper e2e testing would.
So if we've hit the point where we need to test this case we'll have to find a way to change (or appear to change) 'bootup settings' for every single test.
There was a problem hiding this comment.
@johncowen I tried to mock settings like this:
When settings from yaml
---
CONSUL_ACLS_ENABLE: 0
---
It did not work. Is there a specific way to format mocking settings?
There was a problem hiding this comment.
There is no way currently to turn off ACLs for the frontend once the application has booted up. You can only turn off ACLs (well, better said 'toggle') for the HTTP API once the frontend has booted. I believe all the pieces are there to be able to do this 'fake' toggling bootup config, but it's not all joined up as yet.
You won't be able to write the specific acceptance test you are writing for this without adding a bunch of extra app/test code.
Given settings from yaml mocks out the users settings (in localStorage) for example the users token, not operator/bootup config. This is currently mockable after bootup.
There was a problem hiding this comment.
It sounds like we don't have a good/solid way to test this reliably at the moment (unfortunately) so for now we likely need to skip until we can find a solution.
| const upstreamLines = document.getElementById('upstream-lines').getBoundingClientRect(); | ||
| const upstreamColumn = document.getElementById('upstream-column'); | ||
|
|
||
| if (this.emptyColumn) { |
There was a problem hiding this comment.
I had to make this change because the line's arrow were getting cut off. This is the first time the Downstream has an "empty card", unlike Upstreams Column that's had the *(All Services) card.
There was a problem hiding this comment.
Gotcha, thanks for the explanation. So you are adding the 'fake' one here for the downView also (if its empty) right?
| @@ -0,0 +1,22 @@ | |||
| import { helper } from '@ember/component/helper'; | |||
|
|
|||
| export default helper(function serviceCardPermissions([params] /*, hash*/) { | |||
There was a problem hiding this comment.
I had to rename this whole helper because the lines in Topology don't always have to do with Intentions. They do mostly, but I really wanted to get away from "mocking" Intentions into these empty cards. Something I actually have to do for Routing Config card in the future.
There was a problem hiding this comment.
Cool makes sense, I was gonna ask 'why not just permissions?' but I guess you are a little blocked by the "an ember helper should contain a -" thing.
I also wondered if we are talking about 'services' in general here, or are we talking 'streams? (i.e. a service that has a relationship with another service). No specific action from me here though.
There was a problem hiding this comment.
Naming is always hard, no matter what 😬
| } | ||
|
|
||
| @computed('Downstreams', 'Upstreams') | ||
| get noDependecies() { |
There was a problem hiding this comment.
This has to be in the model level because it is used for the notices in template level. The notices is the next PR which needs to be merged into this one.
| loader.data | ||
| as |nspace dc items topology|}} | ||
| <div class="tab-section"> | ||
| {{#if (and (eq topology.Upstreams.length 0) (eq topology.Downstreams.length 0) (not-eq dc.DefaultACLPolicy 'allow') (not topology.wildcardIntention))}} |
There was a problem hiding this comment.
Removing the original Empty State with "No dependencies" message.
| And I see the text "No downstreams." in "#downstream-container > a > p" | ||
| And I see the text "No upstreams." in "#upstream-container > a > p" | ||
| # Scenario: ACLs disabled | ||
| # Given ACLs are disabled |
There was a problem hiding this comment.
When I run this test I see CONSUL_ACLS_ENABLE=0 get put in the Application Cookies, but it returns true in the end. It could be getting overwritten by cookies or it could be my implementation (enable or enabled).
@johncowen please let me know if you have any insight.
There was a problem hiding this comment.
Just a self note more than anything, this is covered in a comment thread further up.
1bbf495 to
ddc2329
Compare
|
Hey! I've had a brief look over the code for this and from a code perspective there are some potential suggestions. But then I gave it a whirl, and managed to get it in this state: I should never see 'streams and the unknown cards together right? I figured you would prefer for me not to make any suggestions until you'd had a chance to look at that ^ (you might completely change the code whilst doing looking and then the suggestions are no longer relevant), but do let me know if you want me to also comment on the code or anything else. Otherwise ping me here when you want me to look again. |
@johncowen no, you shouldn't. What setup did you have here? |
|
I changed the amount of 'streams from 0 to a higher number and then waited for a blocking call to resolve/respond. |
are ACLs enabled or disabled? |
|
I can't quite remember. Looking at the screengrab and what I understand from the feature I guess disabled if it says "'streams unknown.". Lemme know I can check it out again and try if you like. |
@johncowen I've added a fix. Thanks for catching that. |
|
No problem. I gave another whirl and that looks much better. I tried it with ACLs enabled with a downstream count of 2 and an upstream count of 0 and I see this: I'm not entirely sure whether I should see a 'No upstreams.' on the right hand side there? I left it to update for a while and sometimes I see: Not sure if this is due to the mocks or something else, or whether this is expected. Lemme know. If it's expected I can have a look through the code. |
No, you should not see a |
|
Gotcha. Yeah I'd say let's ask them, just based on the fact that I expected for that to "No upstreams" to stay in the right column once I'd added a downstream. (we can still move forwards with this and get it merged if we don't hear back for a bit) Should I see "(* All Services)" ever when upstreams = 0 (second screengrab)? Or is that a problem with the mocks or something? |
johncowen
left a comment
There was a problem hiding this comment.
I thought I'd take a scan over the code whilst waiting on the last screengrab question I had. But please don't feel like you need to go off and make any changes you feel you would like to make as a result of that straight-away. Let me know on that last screengrab question and we can maybe just talk about what you want to go ahead and do (and how) and what you don't want to do.
In the meantime I'll have a look at your test question in a bit (somepoint today) and see if I can help there. I'll come back in a bit with anything I can offer there also.
| const upstreamLines = document.getElementById('upstream-lines').getBoundingClientRect(); | ||
| const upstreamColumn = document.getElementById('upstream-column'); | ||
|
|
||
| if (this.emptyColumn) { |
There was a problem hiding this comment.
Gotcha, thanks for the explanation. So you are adding the 'fake' one here for the downView also (if its empty) right?
| } else if (defaultACLPolicy === 'allow' || wildcardIntention) { | ||
| items.push({ | ||
| Name: '* (All Services)', | ||
| Empty: true, |
There was a problem hiding this comment.
I think the Empty is fine all in all, so this isn't a blocker. But one suggestion I would have if you like it is: Alternatively you could check for an empty Datacenter value. I'm pretty sure (at least for the fairly distant future) we will never have a 'real' 'stream without a Datacenter value. So if its Datacenter value is an empty string then it's Empty
Why do this? (maybe..):
I'm guessing the 'real' data objects don't have an Empty: false? So if you just use Datacenter here you are sticking to the same shaped model/object.
Lemme know what you think.
There was a problem hiding this comment.
Updated to use Datacenter.
| @@ -0,0 +1,22 @@ | |||
| import { helper } from '@ember/component/helper'; | |||
|
|
|||
| export default helper(function serviceCardPermissions([params] /*, hash*/) { | |||
There was a problem hiding this comment.
Cool makes sense, I was gonna ask 'why not just permissions?' but I guess you are a little blocked by the "an ember helper should contain a -" thing.
I also wondered if we are talking about 'services' in general here, or are we talking 'streams? (i.e. a service that has a relationship with another service). No specific action from me here though.
| @action={{true}} | ||
| /> | ||
| {{/if}} | ||
| {{#if (and topology.noDependencies (not (env 'CONSUL_ACLS_ENABLED')))}} |
There was a problem hiding this comment.
Could we update these envs to use ember-can? I would like to get rid of our 'ability related' env usage everywhere in our templates, so its one of those things of "If you are touching something/a file and the work for the ability is already there, then consider switching env to ember-can"
(just for extra explanation/background from me not related to this PR. The other env usage we have when it's not 'ability' related is pretty much for string constants. We can move all of that to use our i18n stuff now we have that. That idea is not quite 100% baked yet tho, there is still one more thing left to do with our i18n support so I'm not as keen to get started on moving those over as yet)
What do you think the likelihood of us using topology.noDependencies anywhere else in the app? I would guess it's unlikely, wdyt?
There was a problem hiding this comment.
It's unlikely that I would use topology.noDependencies anywhere else in the app, but I am using in Topology. Hence, why I created it.
| --- | ||
| Then the url should be /datacenter/services/web/topology | ||
| And I see the text "No downstreams." in "#downstream-container > a > p" | ||
| And I see the text "No upstreams." in "#upstream-container > a > p" |
There was a problem hiding this comment.
I'd like to avoid putting these types of selectors in the tests. Could you change this to use either a page object or a test selector. ty!
Oh actually I think we should also change this not to assert on the value of the text , so change it to use pageobjects and/or test-selectors instead.
There was a problem hiding this comment.
@johncowen What do you suggest I assert on then?
There was a problem hiding this comment.
I'd say something that isn't English/human text. I know we don't have different locales right now but we should try to never assert on English/human text especially now we are transitioning everything to use ember-intl. Actually I'm unsure how worthwhile these are as you are asserting on noDependencies further down, which I'm guessing means there are no upstreams or downstreams?
If this is problematic happy leave as a TODO if you could add that in here somewhere.
If you are leaving this as is, is it possible to update the DOM selectors to use either page objects/data-selectors?
There was a problem hiding this comment.
I've seen elsewhere in tests that we use data-test attributes on elements and write test selectors on those, which is a pattern I feel works well for selecting things specifically and makes the test code more resilient against code changes.
Is it reasonable to add data-test attributes to the corresponding elements in the templates and use that approach?
| }); | ||
|
|
||
| await render(hbs`{{service/intention-permissions inputValue}}`); | ||
| await render(hbs`{{service/card-permissions inputValue}}`); |
There was a problem hiding this comment.
The helper has the tiniest bit of logic, so its arguable whether you might want to test it or not. TBH I'm easy either way with how the helper is right now. Otherwise if its easier for you I'd consider just deleting this, it's at the point where its creating more work and providing very little benefit. Completely up to you though, happy if you want to leave as is also.
There was a problem hiding this comment.
I'm going to leave it as is.
| acls-disabled: | ||
| header: Enable ACLs | ||
| body: This connect-native service may have dependencies, but Consul isn’t aware of them when ACLs are disabled. Enable ACLs to make this view more useful. | ||
| footer: Read the documentation |
There was a problem hiding this comment.
Honestly not sure if the curly apostrophe could look weird cross platform. I'm not even sure if thats a thing anymore or not (I think it all depended on whether everything was using UTF-8 or not, I know I've seen instances of things looking wrong elsewhere on some of our stuff), and I don't know if ember does anything special here either. Maybe just make this non-curly incase considering we don't test this type of stuff, might be worth us checking that out actually 🤔
There was a problem hiding this comment.
I'm not sure what you're talking about here. What is the curly apostrophe?
There was a problem hiding this comment.
This gives an alright overview https://www.theatlantic.com/technology/archive/2016/12/quotation-mark-wars/511766/
I would imagine the one here is OK, plus I think I've just seen some more of these in our translation files and we've not heard of any windows folks asking about mangled chars so I guess this is fine.
There was a problem hiding this comment.
I think @johncowen is referring to a subtle difference in characters; ʼ (close apostrophe) versus ' (prime), yeah?
My guess is most browsers will display either one just fine at this point. Do we have linting rules/tooling that can catch this sort of thing for us automatically/could we look at setting something like that up?
There was a problem hiding this comment.
I think @johncowen is referring to a subtle difference in characters; ʼ (close apostrophe) versus ' (prime), yeah?
Yeah exactly that
My guess is most browsers will display either one just fine at this point
I thought that also, but I saw these kinds of issues on some of our non-Ember properties a little while back, and I wasn't sure. I'm guessing/hoping its dealt with somewhere/somehow so we don't have to worry about it, but I just don't know for sure. I guess I just have always automatically used ' to avoid the issue.
Just to say, this isn't a blocker at all I don't think, more a convo. I'm guessing its not an issue as I've seen we use them elsewhere and we've not had issues posted so should be good. Although a lint rule might be nice to set up if we want to avoid curlies/close, I like the sound of that 👍
The designer has said we should make it consistent to empty state. I'll add that change.
@johncowen Yes, you should "(* All Services)" in this case because of permissive intentions. |
johncowen
left a comment
There was a problem hiding this comment.
I think this is pretty much there then, I left a few clarifications and questions, lemme know.
| @action={{true}} | ||
| /> | ||
| {{/if}} | ||
| {{#if (and topology.noDependencies (can 'use acl'))}} |
There was a problem hiding this comment.
| {{#if (and topology.noDependencies (can 'use acl'))}} | |
| {{#if (and topology.noDependencies (can 'use acls'))}} |
| @action={{true}} | ||
| /> | ||
| {{/if}} | ||
| {{#if (and topology.noDependencies (not (can 'use acl')))}} |
There was a problem hiding this comment.
| {{#if (and topology.noDependencies (not (can 'use acl')))}} | |
| {{#if (and topology.noDependencies (not (can 'use acls')))}} |
.changelog/11280.txt
Outdated
| @@ -0,0 +1,3 @@ | |||
| ```release-note:feature | |||
| ui: Topology - New views for scenarios where no dependencies exist or ACls are disabled | |||
There was a problem hiding this comment.
| ui: Topology - New views for scenarios where no dependencies exist or ACls are disabled | |
| ui: Topology - New views for scenarios where no dependencies exist or ACLs are disabled |
| --- | ||
| Then the url should be /datacenter/services/web/topology | ||
| And I see the text "No downstreams." in "#downstream-container > a > p" | ||
| And I see the text "No upstreams." in "#upstream-container > a > p" |
There was a problem hiding this comment.
I'd say something that isn't English/human text. I know we don't have different locales right now but we should try to never assert on English/human text especially now we are transitioning everything to use ember-intl. Actually I'm unsure how worthwhile these are as you are asserting on noDependencies further down, which I'm guessing means there are no upstreams or downstreams?
If this is problematic happy leave as a TODO if you could add that in here somewhere.
If you are leaving this as is, is it possible to update the DOM selectors to use either page objects/data-selectors?
| acls-disabled: | ||
| header: Enable ACLs | ||
| body: This connect-native service may have dependencies, but Consul isn’t aware of them when ACLs are disabled. Enable ACLs to make this view more useful. | ||
| footer: Read the documentation |
There was a problem hiding this comment.
This gives an alright overview https://www.theatlantic.com/technology/archive/2016/12/quotation-mark-wars/511766/
I would imagine the one here is OK, plus I think I've just seen some more of these in our translation files and we've not heard of any windows folks asking about mangled chars so I guess this is fine.
| Intention: { | ||
| Allowed: true, | ||
| }, | ||
| }); |
There was a problem hiding this comment.
Do we need one of these (an * All Services thing) for the downstream side of things? So if we have default allow does that mean all services can talk to the main service, just like the main service can talk to all services?
Also wondering about the conditionals here, they are difficult for me to follow completely just as I don't have as much context in this as you do, would some sort of comments here explaining the cases for each type of message help me follow this a little better?
There was a problem hiding this comment.
No, we only have it for the Upstreams side.
johncowen
left a comment
There was a problem hiding this comment.
I think this looks good to merge. There is one thing I noticed. The test case we can't currently test (see #11280 (comment)) which you had commented out has been removed which is great. But there was a test in that same file that was removed. Was that test no longer passing? Could it be made to pass if not without having control over CONSUL_ACLS_ENABLED?
I'm always very cautious of removing tests.
Anyway, I approved here also. So you can merge either way.
|
🍒 If backport labels were added before merging, cherry-picking will start automatically. To retroactively trigger a backport after merging, add backport labels and re-run https://circleci.com/gh/hashicorp/consul/494943. |



✨ Description:
In the Topology tab, we currently show a 'No Dependencies' Empty State message when the main Service has no Downstreams or Upstreams. This PR implements a new view "empty state" where you can still see the main Service and its metrics when main service has no dependencies and when ACLs are disabled.
This resolved #10720.
Demo for No Dependencies
📸Screenshots:
⚡ Backend Changes:
No Backend changes required.
🤡 Updates to mock-api:
No updates to mock data.
🧪 Testing:
No tests.
📝 PR Tasks: