-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Add SloGlobalDiagnosis check to SLO List and SLO Create pages #157488
Add SloGlobalDiagnosis check to SLO List and SLO Create pages #157488
Conversation
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
118c5d9
to
fd81f81
Compare
x-pack/plugins/observability/public/hooks/slo/helpers/convert_error_for_use_in_toast.ts
Show resolved
Hide resolved
x-pack/plugins/observability/public/hooks/slo/use_fetch_global_diagnosis.ts
Outdated
Show resolved
Hide resolved
userPrivileges, | ||
sloResources, | ||
}; | ||
try { |
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.
this try catch is not needed if we are just throwing the error.
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 is needed.
const sloResources = await getSloResourcesDiagnosis(esClient);
throws an error when ES has insufficient permissions, so if we don't throw here this function returns a normal object:
return {
licenseAndFeatures: { something },
userPrivileges: { something },
sloResources: { message: 'Some error message', statusCode: 403, ...etc }
};
if (error.cause.statusCode === 403) { | ||
throw forbidden('Insufficient Elasticsearch cluster permissions to access feature.'); | ||
} | ||
throw failedDependency(error); |
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.
what does this thing do?
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's one of HAPI Boom's methods to auto-format the response:
Boom.failedDependency([message], [data])
Returns a 424 Failed Dependency error where:
message - optional message.
data - optional additional error data.
Boom.failedDependency('an external resource failed');
Generates the following response payload:
{
"statusCode": 424,
"error": "Failed Dependency",
"message": "an external resource failed"
}
https://hapi.dev/module/boom/api/?v=10.0.1#boomfaileddependencymessage-data
onError: (error: Error) => { | ||
toasts.addError(error, { | ||
title: i18n.translate('xpack.observability.slo.globalDiagnosis.errorNotification', { | ||
defaultMessage: 'You do not have the right permissions to use this feature.', | ||
}), | ||
}); |
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.
So basically we rely on an error response coming from the API to consider the permission as insufficient?
I guess it works for now, but for 8.9 I would probably move this logic into the different SLO endpoints (create, update, etc..) and handle the 403 from there, returning a special error response, so we guarantee a universal experience on both UI and API.
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, this can be improved.
The bug report mentioned disabling the "Create SLO" button on the Welcome page when no permissions are found, so we at least need this call to do that, not only on mutating endpoints.
…_diagnosis.ts Co-authored-by: Kevin Delemme <[email protected]>
…-ref HEAD~1..HEAD --fix'
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.
LGTM
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
Unknown metric groupsESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
…c#157488) Co-authored-by: Kevin Delemme <[email protected]> Co-authored-by: kibanamachine <[email protected]> (cherry picked from commit e753256)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…157488) (#157514) # Backport This will backport the following commits from `main` to `8.8`: - [Add SloGlobalDiagnosis check to SLO List and SLO Create pages (#157488)](#157488) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Coen Warmer","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-05-12T15:45:16Z","message":"Add SloGlobalDiagnosis check to SLO List and SLO Create pages (#157488)\n\nCo-authored-by: Kevin Delemme <[email protected]>\r\nCo-authored-by: kibanamachine <[email protected]>","sha":"e75325653c88553454270bf412ddbed700fc022b","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:prev-minor","v8.8.0","v8.9.0"],"number":157488,"url":"https://github.com/elastic/kibana/pull/157488","mergeCommit":{"message":"Add SloGlobalDiagnosis check to SLO List and SLO Create pages (#157488)\n\nCo-authored-by: Kevin Delemme <[email protected]>\r\nCo-authored-by: kibanamachine <[email protected]>","sha":"e75325653c88553454270bf412ddbed700fc022b"}},"sourceBranch":"main","suggestedTargetBranches":["8.8"],"targetPullRequestStates":[{"branch":"8.8","label":"v8.8.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/157488","number":157488,"mergeCommit":{"message":"Add SloGlobalDiagnosis check to SLO List and SLO Create pages (#157488)\n\nCo-authored-by: Kevin Delemme <[email protected]>\r\nCo-authored-by: kibanamachine <[email protected]>","sha":"e75325653c88553454270bf412ddbed700fc022b"}}]}] BACKPORT--> Co-authored-by: Coen Warmer <[email protected]>
Co-authored-by: Kevin Delemme <[email protected]> Co-authored-by: kibanamachine <[email protected]>
Resolves #157317
📝 Summary
This adds the usage of the SLO Global Diagnosis endpoint in the SLO app on the SLO Welcome and SLO Create pages.
If the endpoint returns an error, the user will receive a toast with more detailed information as to what is the cause of the issue.
On the Welcome page the Create SLO button will be disabled. When the user visits the Create page via URL she will be navigated back to the Welcome page.
✅ Checklist