Skip to content
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: Fix job detail crash when recommendations off #9269

Merged
merged 6 commits into from
Nov 6, 2020

Conversation

backspace
Copy link
Contributor

@backspace backspace commented Nov 4, 2020

Without this, visiting any job detail page on Nomad OSS would
crash with an error like this:

Error: Ember Data Request GET /v1/recommendations?job=ping%F0%9F%A5%B3&namespace=default returned a 404
Payload (text/xml)

The problem was twofold.

  1. The recommendation ability didn’t include anything about checking whether the feature was present. This adds a request to /v1/operator/license on application load to determine which features are present and store them in the system service. The ability now looks for Dynamic Application Sizing in that feature list.

  2. Second, I didn’t check permissions at all in the job-fetching or job detail templates.

Thanks to @DingoEatingFuzz for catching this! 😯

Without this, visiting any job detail page on Nomad OSS would
crash with an error like this:

Error: Ember Data Request GET /v1/recommendations?job=ping%F0%9F%A5%B3&namespace=default returned a 404
Payload (text/xml)

The problem was twofold. First, I made a copypaste error when
creating the recommendations ability: it shouldn’t include
bypassAuthorization, which is meant to skip permissions-checks
in the absence of ACLs. Second, I didn’t check permissions
at all in the job-fetching or job detail templates.

Thanks to @DingoEatingFuzz for catching this! 😯
@backspace backspace self-assigned this Nov 4, 2020
@backspace backspace marked this pull request as draft November 4, 2020 23:31
@backspace
Copy link
Contributor Author

oops wait I only ran the one new test instead of the others which are now broken due to needing the management token 😬

@github-actions
Copy link

github-actions bot commented Nov 4, 2020

Ember Asset Size action

As of 53a29b4

Files that got Bigger 🚨:

File raw gzip
nomad-ui.js +2.24 kB +412 B

Files that stayed the same size 🤷‍:

File raw gzip
vendor.js 0 B 0 B
nomad-ui.css 0 B 0 B
vendor.css 0 B 0 B

@backspace
Copy link
Contributor Author

okay, all is well now, sorry for the premature review request 😯

@github-actions
Copy link

github-actions bot commented Nov 5, 2020

Ember Test Audit comparison

master 53a29b4 change
passes 1515 1517 +2
failures 0 0 0
flaky 0 0 0
duration 7m 32s 256ms 7m 32s 579ms +323ms

Copy link
Contributor

@DingoEatingFuzz DingoEatingFuzz left a comment

Choose a reason for hiding this comment

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

I have a couple questions regarding the underlying permissions.

Comment on lines 16 to 20
{{#if (can "read agent")}}
{{#each this.job.recommendationSummaries as |summary|}}
<Das::RecommendationAccordion @summary={{summary}} />
{{/each}}
{{/if}}
Copy link
Contributor

Choose a reason for hiding this comment

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

read agent is required here? That's surprising to me. Why is that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ughhhhhhhhh just wrong, fixed in ee0e00d 😞

@@ -3,7 +3,7 @@ import { computed } from '@ember/object';
import { or } from '@ember/object/computed';

export default class Recommendation extends AbstractAbility {
@or('bypassAuthorization', 'selfTokenIsManagement', 'policiesSupportAcceptingOnAnyNamespace')
@or('selfTokenIsManagement', 'policiesSupportAcceptingOnAnyNamespace')
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you not use recommendations without ACLs?

Copy link
Contributor Author

@backspace backspace Nov 5, 2020

Choose a reason for hiding this comment

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

hmm… you’re right that this is not a correct way to determine this! 😢

I’ve now added 24c3a95 which introduces a license-fetching step when loading the application akin to when the policies are fetched. On enterprise GET /v1/operator/license returns something that we can use to check for whether a feature exists:

{
  …,
  License: {
    …,
    Features: […, 'Dynamic Application Sizing', …],
    …,
  …,
}

On OSS the endpoint 501s so I store an empty license with no features instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

🤩🤩🤩🤩

This is fantastic. I'm sorry this bug ended up being bigger than it appeared, but having this level of feature-checking is an excellent addition.

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 glad to have finally added this despite the sadness of another spurious failure message:

image

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah :( Related: #4567

Copy link
Contributor Author

Choose a reason for hiding this comment

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

😳

copypaste again 😭
This adds a call to /v1/operator/license when the application
loads to fetch the list of enterprise features if they exist.
The feature list can be used in abilities.
Copy link
Contributor

@DingoEatingFuzz DingoEatingFuzz left a comment

Choose a reason for hiding this comment

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

Excellent work!

@backspace backspace merged commit 7b9f8b5 into master Nov 6, 2020
@backspace backspace deleted the b-ui/das-oss-job-detail-crisis branch November 6, 2020 14:21
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants