-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[ML] Fix cloud deployment ID check #68695
[ML] Fix cloud deployment ID check #68695
Conversation
Pinging @elastic/ml-ui (:ml) |
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
|
||
const badCloudId = 'cloud_message_test:this_is_not_a_base64_string'; | ||
|
||
it('cloud ID with deployment name', () => { |
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.
test suit sentence usually starts with should
, e.g. should extract cloud id when deployment name is presented
} | ||
|
||
export function extractDeploymentId(cloudId: string) { | ||
const tempCloudId = cloudId.replace(/^(.+)?:/, ''); |
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.
nit: you can achieve it without regexp, const tempCloudId = cloudId.split(':')[1]
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.
if the deployment name isn't present at all then the array will only have a length of 1 and so an extra check will be needed.
i think using replace here is the simplest approach, even though it's not the most performant.
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.
But you regexp relies on :
anyway. It expects something like":xyz"
, so split will return 2 elements anyway, the first one will be an empty string. Not critical at all anyway, just suppose it's always easier without regexp
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, just a couple of suggestions
@elasticmachine merge upstream |
@elasticmachine merge upstream |
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
* [ML] Fix cloud ID check * updates for tests * adding extra test * updating test titles Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
* [ML] Fix cloud ID check * updates for tests * adding extra test * updating test titles Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
* master: (91 commits) [Search][BUG] Call wrong search strategy recursively in async search (elastic#69116) [Observability] Create context container to enable Observability plugin registry function (elastic#68642) Rename space id for disabled index pattern test (elastic#68990) skip flaky suite (elastic#63339) Resolver Light Theme And Kibana Integration (elastic#67859) [kbn/dev-utils] expose public tooling_log module (elastic#68868) index pattern(s) take dependencies as object (elastic#69055) include ci-stats metrics in pr comment (elastic#68563) Bump webpack packages (elastic#68716) [Uptime] Fixed metric query broken because of missing mapping (elastic#68999) Added cloud as an optional dependency (elastic#69050) Fixed all external links (elastic#68614) [DOCS] Reorganizes doc nav to match new Kibana nav (elastic#69069) [Endpoint] Using the stats provided by the backend for resolver UI (elastic#68577) [DOCS] Removees 8.0 from Upgrade Assistant docs (elastic#69067) [ML] Fix cloud deployment ID check (elastic#68695) [DOCS] Move metrics app content to metrics monitoring guide (elastic#69033) Add ingest manager topic to docs (elastic#68980) [SECURITY SOLUTION] EMT-401: add policy data to metadata and fix tests (elastic#68582) [DOCS] Fixes POST request for saved objects (elastic#69036) ...
* master: (60 commits) Re-enable mistakenly skipped tests. (elastic#69123) [Search][BUG] Call wrong search strategy recursively in async search (elastic#69116) [Observability] Create context container to enable Observability plugin registry function (elastic#68642) Rename space id for disabled index pattern test (elastic#68990) skip flaky suite (elastic#63339) Resolver Light Theme And Kibana Integration (elastic#67859) [kbn/dev-utils] expose public tooling_log module (elastic#68868) index pattern(s) take dependencies as object (elastic#69055) include ci-stats metrics in pr comment (elastic#68563) Bump webpack packages (elastic#68716) [Uptime] Fixed metric query broken because of missing mapping (elastic#68999) Added cloud as an optional dependency (elastic#69050) Fixed all external links (elastic#68614) [DOCS] Reorganizes doc nav to match new Kibana nav (elastic#69069) [Endpoint] Using the stats provided by the backend for resolver UI (elastic#68577) [DOCS] Removees 8.0 from Upgrade Assistant docs (elastic#69067) [ML] Fix cloud deployment ID check (elastic#68695) [DOCS] Move metrics app content to metrics monitoring guide (elastic#69033) Add ingest manager topic to docs (elastic#68980) [SECURITY SOLUTION] EMT-401: add policy data to metadata and fix tests (elastic#68582) ...
* [ML] Fix cloud ID check * updates for tests * adding extra test * updating test titles Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
The deployment name at the beginning of the cloud deployment ID can sometimes be blank.
This causes our ID check to fail to recognise it.
This PR updates the regex to make the deployment name optional.
Refactors
getCloudDeploymentId
so it can be tested without the mocked info endpoint response.Fixes issue raised here: #35217 (comment)