-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
ui: Topology - Fix up Default Allow and Permissive Intentions notices #11216
Conversation
16f9582
to
4042d33
Compare
const allNotices = [ | ||
...document.querySelectorAll('div.collapsible-notices > div.notices > .notice'), | ||
]; | ||
this.collapsible = allNotices.length > 2; |
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.
These code changes are a more efficient solution to showing or not the collapsible button.
FYI in upcoming Topology changes we'll be adding more notices.
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.
Curious as to why this could be more efficient? Mostly in modern frameworks the idea is to declaratively configure what you want the view to be based on the state and then the framework efficiently creates that view for you - using querySelector[All] is generally shied away from. I would say that generally if you find yourself using DOM methods like this it might be worth thinking of another way to do it (there's always an outlier but generally the reason for that outlier is clear if there is)
@@ -33,14 +31,19 @@ export default class Topology extends Model { | |||
return undefinedDownstream; | |||
} | |||
|
|||
@computed('FilteredByACL', 'DefaultAllow', 'WildcardIntention', 'notDefinedIntention') |
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 removed this code because it was not efficient to show or not the collapsible banner. Soon it will be impossible to figure out all the "notice combos" that will exist.
With BE folks we verified that default allow and wildcard intentions can co-exist.
@@ -136,7 +98,7 @@ as |nspace dc items topology|}} | |||
{{#if config.data}} | |||
<TopologyMetrics | |||
@nspace={{nspace}} | |||
@dc={{dc.Name}} | |||
@dc={{dc}} |
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 had to pass the whole dc
object since I need the dc.DefaultACLPolicy
in topology-metrics/index.js
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.
Cool yeah good move, thanks for the explanation.
@@ -53,17 +53,11 @@ ${ | |||
fake.seed(index); | |||
|
|||
|
|||
// Randomly make permissive intentions | |||
const defaultAllow = fake.random.boolean(); |
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 thought about keeping this, but we verified with BE that default allow and wildcard intentions can co-exist.
Super nice we can do this now with that new ACL header. I have a few question based on your description before I give this a proper look:
If there are no backend changes, should we be updating the mocks? The mocks should be as close to the backend as possible. Is there a plan to make the same changes to the backend that are made here in the mocks?
Could you explain what you mean by the limitations here, off the top of my head I can't think of what that might be? Lemme know and I can take a look over this |
The mocks were wrong and did not match BE response. No changes are needed in the BE.
I could not set |
Ah gotcha, thanks for the explanation!
Ah, so not a limitation as such, more you're not sure how it's done? How much time did you time block this for? I can either walk you through it, show you where we do this already or pop something on the end of this myself depending on whether you can spend some more time on this or not. Lemme know how big your time block is and we can sort 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.
I made a few inline comments also, but don't feel like you have to address them before we get a chance to talk about avoiding deleting the test here (re: mocking out the ACL header). I'll wait til you get back to me on the other (not-inline) comment I made and we can go from there.
edit: Is this the one we had a list of user stories to test for? The one we were going to make a spreadsheet for to make sure we covered them all?
const allNotices = [ | ||
...document.querySelectorAll('div.collapsible-notices > div.notices > .notice'), | ||
]; | ||
this.collapsible = allNotices.length > 2; |
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.
Curious as to why this could be more efficient? Mostly in modern frameworks the idea is to declaratively configure what you want the view to be based on the state and then the framework efficiently creates that view for you - using querySelector[All] is generally shied away from. I would say that generally if you find yourself using DOM methods like this it might be worth thinking of another way to do it (there's always an outlier but generally the reason for that outlier is clear if there is)
@@ -136,7 +98,7 @@ as |nspace dc items topology|}} | |||
{{#if config.data}} | |||
<TopologyMetrics | |||
@nspace={{nspace}} | |||
@dc={{dc.Name}} | |||
@dc={{dc}} |
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.
Cool yeah good move, thanks for the explanation.
this.Upstreams.filter(item => !item.Intention.HasExact && item.Intention.Allowed).length !== | ||
0; | ||
|
||
return downstreamWildcard || upstreamWildcard; |
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.
Just a note here, not sure if it matters or not. Did you know we have all this intention information available to us in the API call we make for the Services > Intentions tab (we also use the same call to do the intention updating on this Topology Tab). I would guess reusing that would save a bunch of backend work here, and if the user was using TProxy I don't think (not entirely sure) we'd have to make the extra topology endpoint API call at all. Anyway, no action to be made on FEs part here, but if you are talking to BE about this it might free them up a little.
@johncowen I time-blocked a whole afternoon for this one assertion. I mostly looked through the |
@johncowen I see what you mean. I've refactored the code I wrote in the CollapsibleNotices JS file to be in a helper. I made the changes in a separate commit. |
@johncowen sorry, I forgot to reply to this. Yes, we got on a call and discovered this was the actual issue. A spreadsheet has been made, but we still see no need for new notices atm. |
You can use the
So instead of using randomize here use
X-Consul-Default-Acl-Policy: ${env('CONSUL_ACL_POLICY', fake.helpers.randomize(['allow', 'deny']))} To make it still use a random value if the env var (the cookie/mock) isn't set. If you try this just in your browser first to make sure you can set it in your development environment, then you can add mocking it in a test environment. During testing, you were right, you will need to add a new step like: Given the default ACL policy is "$policy" And then set your cookie in that step in order to mock this value out. There are a couple of ways to do that, one simpler that the other: consul/ui/packages/consul-ui/tests/steps/doubles/http.js Lines 15 to 17 in 2d05164
or something like this:
Looking at the new stuff now 👍 |
@johncowen I've put the solution you suggested to the test in this branch |
Did you try both approaches I linked to? The first one works fine for me. |
17d81e0
to
408d52c
Compare
@johncowen I've rebased this PR. Is it ready to be merged? |
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.
Not a blocking question, but whats the difference between a "wildcard intention" and a "permissive intention"?
@johncowen they mean the same thing. The only difference is |
🍒 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/469698. |
✨ Description:
This PR updates the conditionals used to show the Default Allow notice, the Permissive Intentions notice, and all the collapsible notices.
Demo Link
📸 Screenshots:
Permissive Intention Notice
Default Allow Notice
⚡ Backend Changes:
No BE changes but we did verify with BE what the response should look like.
🤡 Updates to mock-api:
Removed
DefaultAllow
andWildcardIntention
from root/v1/internal/ui/service-topology
response.🧪 Testing:
Removed the test that covered the Default Allow notice, because of limitations with mocking out API header response. Time-blocked the effort and deleted it in the end.
Updated the test that covered the Permissive Intentions notice.
📝 PR Tasks: