Skip to content

Don't register management section if capabilities are not granted#90782

Merged
legrego merged 6 commits intoelastic:masterfrom
legrego:chore/fix-beats-flakyness
Feb 10, 2021
Merged

Don't register management section if capabilities are not granted#90782
legrego merged 6 commits intoelastic:masterfrom
legrego:chore/fix-beats-flakyness

Conversation

@legrego
Copy link
Copy Markdown
Member

@legrego legrego commented Feb 9, 2021

Summary

Only registers the Beats CM and Logstash management sections if the user is authorized for them. Addresses a race condition where the section would be registered after the Management app had gone through and disabled sections based on capabilities.

Ideally Beats CM wouldn't register itself in an async manner (i.e., potentially during the start phase), but priorities aren't aligned with rewriting the way this application is structured.

Flaky test verification:

Resolves #90849
Resolves #90770

@legrego
Copy link
Copy Markdown
Member Author

legrego commented Feb 9, 2021

@elasticmachine merge upstream

@azasypkin
Copy link
Copy Markdown
Contributor

ACK: reviewing...

Copy link
Copy Markdown
Contributor

@azasypkin azasypkin left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the quick fix!

Would you mind running a flaky test runner on the backport PR as well (if possible)? I'm a bit worried that in 7.11 I've seen both Logstash pipelines and Beats Management sections rendered when there should have been none of these sections (see gif in #90770).


One thing I noticed is that this fix made another minor problem more apparent, but since tests don't complain I'm fine with it. I believe Beats team needs to eventually implement a proper fix and register sections in setup though:

  • Logout
  • Try to go directly to https://localhost:5601/app/management
  • Log in as a super user and observe that Beats Management section is missing sometimes
  • Browser refresh fixes this problem

@legrego
Copy link
Copy Markdown
Member Author

legrego commented Feb 10, 2021

One thing I noticed is that this fix made another minor problem more apparent, but since tests don't complain I'm fine with it. I believe Beats team needs to eventually implement a proper fix and register sections in setup though:

  • Logout
  • Try to go directly to https://localhost:5601/app/management
  • Log in as a super user and observe that Beats Management section is missing sometimes
  • Browser refresh fixes this problem

Great catch, thanks @azasypkin! I think I identified this, and fixed in 845b2c8 (#90782) 🤞

@legrego
Copy link
Copy Markdown
Member Author

legrego commented Feb 10, 2021

I commented the wrong part above. I fixed the logstash issue, not the beats issue you described

@legrego
Copy link
Copy Markdown
Member Author

legrego commented Feb 10, 2021

I'm re-running the flaky test runner for CI groups 7,8,9, and additionally for CI group 2, which includes the Logstash functional tests for feature controls.

@legrego
Copy link
Copy Markdown
Member Author

legrego commented Feb 10, 2021

@azasypkin Would you mind reviewing the latest logstash changes?
The flaky test runners completed for all test suites linked above, with no flakyness

@azasypkin azasypkin self-requested a review February 10, 2021 15:09

export class LogstashPlugin implements Plugin<void, void, SetupDeps> {
private licenseSubscription?: Subscription;
private capabilities$ = new BehaviorSubject<null | Capabilities>(null);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: it feels like you can just use new Subject<Capabilities>() and remove null check in the subscription?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good call, will do!

Copy link
Copy Markdown
Contributor

@azasypkin azasypkin left a comment

Choose a reason for hiding this comment

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

Still LGTM with optional nit, thanks for handling Logstash Pipelines as well!

@kibanamachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
beatsManagement 538.9KB 538.7KB -198.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
beatsManagement 126.4KB 128.4KB +1.9KB
logstash 22.2KB 22.6KB +418.0B
total +2.4KB

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@legrego legrego added the auto-backport Deprecated - use backport:version if exact versions are needed label Feb 10, 2021
@legrego legrego merged commit 9778060 into elastic:master Feb 10, 2021
@legrego legrego deleted the chore/fix-beats-flakyness branch February 10, 2021 19:10
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Feb 10, 2021
…astic#90782)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Feb 10, 2021
…astic#90782)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
@kibanamachine
Copy link
Copy Markdown
Contributor

Backport result

{"level":"info","message":"POST https://api.github.com/graphql (status: 200)"}
{"level":"info","message":"POST https://api.github.com/graphql (status: 200)"}
{"meta":{"labels":["auto-backport","release_note:skip","v7.11.1","v7.12.0","v8.0.0"],"branchLabelMapping":{"^v8.0.0$":"master","^v7.12.0$":"7.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"},"existingTargetPullRequests":[]},"level":"info","message":"Inputs when calculating target branches:"}
{"meta":["7.11","7.x"],"level":"info","message":"Target branches inferred from labels:"}
{"meta":{"killed":false,"code":2,"signal":null,"cmd":"git remote rm kibanamachine","stdout":"","stderr":"error: No such remote: 'kibanamachine'\n"},"level":"info","message":"exec error 'git remote rm kibanamachine':"}
{"meta":{"killed":false,"code":2,"signal":null,"cmd":"git remote rm elastic","stdout":"","stderr":"error: No such remote: 'elastic'\n"},"level":"info","message":"exec error 'git remote rm elastic':"}
{"level":"info","message":"Backporting [{\"sourceBranch\":\"master\",\"targetBranchesFromLabels\":[\"7.11\",\"7.x\"],\"sha\":\"9778060ae81d29644b543b27bac5e3e6ce4ae82f\",\"formattedMessage\":\"Don't register management section if capabilities are not granted (#90782)\",\"originalMessage\":\"Don't register management section if capabilities are not granted (#90782)\\n\\nCo-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>\",\"pullNumber\":90782,\"existingTargetPullRequests\":[]}] to 7.11"}

Backporting to 7.11:
{"level":"info","message":"Backporting via filesystem"}
{"level":"info","message":"Creating PR with title: \"[7.11] Don't register management section if capabilities are not granted (#90782)\". kibanamachine:backport/7.11/pr-90782 -> 7.11"}
{"level":"info","message":"POST /repos/elastic/kibana/pulls - 201 in 1230ms"}
{"level":"info","message":"Adding assignees to #91006: legrego"}
{"level":"info","message":"POST /repos/elastic/kibana/issues/91006/assignees - 201 in 763ms"}
{"level":"info","message":"Adding labels: backport"}
{"level":"info","message":"POST /repos/elastic/kibana/issues/91006/labels - 200 in 581ms"}
View pull request: https://github.com/elastic/kibana/pull/91006
{"level":"info","message":"Backporting [{\"sourceBranch\":\"master\",\"targetBranchesFromLabels\":[\"7.11\",\"7.x\"],\"sha\":\"9778060ae81d29644b543b27bac5e3e6ce4ae82f\",\"formattedMessage\":\"Don't register management section if capabilities are not granted (#90782)\",\"originalMessage\":\"Don't register management section if capabilities are not granted (#90782)\\n\\nCo-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>\",\"pullNumber\":90782,\"existingTargetPullRequests\":[]}] to 7.x"}

Backporting to 7.x:
{"level":"info","message":"Backporting via filesystem"}
{"level":"info","message":"Creating PR with title: \"[7.x] Don't register management section if capabilities are not granted (#90782)\". kibanamachine:backport/7.x/pr-90782 -> 7.x"}
{"level":"info","message":"POST /repos/elastic/kibana/pulls - 201 in 1128ms"}
{"level":"info","message":"Adding assignees to #91007: legrego"}
{"level":"info","message":"POST /repos/elastic/kibana/issues/91007/assignees - 201 in 695ms"}
{"level":"info","message":"Adding labels: backport"}
{"level":"info","message":"POST /repos/elastic/kibana/issues/91007/labels - 200 in 362ms"}
View pull request: https://github.com/elastic/kibana/pull/91007

legrego added a commit that referenced this pull request Feb 10, 2021
…0782) (#91006)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Larry Gregory <larry.gregory@elastic.co>
legrego added a commit that referenced this pull request Feb 10, 2021
…ed (#90782) (#91007)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Larry Gregory <larry.gregory@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-backport Deprecated - use backport:version if exact versions are needed release_note:skip Skip the PR/issue when compiling release notes v7.11.1 v7.12.0 v8.0.0

Projects

None yet

3 participants