-
Notifications
You must be signed in to change notification settings - Fork 75
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
api: u.pro.services.enable.v1 #3015
Conversation
Jira: This PR is not related to a Jira item. (The PR title does not include a SC-#### reference) GitHub Issues: No GitHub issues are fixed by this PR. (No commits have Fixes: #### references) Launchpad Bugs: No Launchpad bugs are fixed by this PR. (No commits have LP: #### references) Documentation: The changes in this PR do require documentation changes, but those were not addressed yet. 👍 this comment to confirm that this is correct. |
🌎 This PR changes translatable messages. 🌏 Please select which scenarios apply. For further explanation, please read our policy on message changes.
|
9604c53
to
4f86793
Compare
e42dc41
to
37f2407
Compare
I will separate out the enable cli refactor to use the api into a separate PR, since that is the only part that is blocking this (and is only blocked because a separate internal assume_yes refactor is required that doesn't affect the API). |
bd7800d
to
ab3ebc8
Compare
ab3ebc8
to
556b06e
Compare
556b06e
to
5de0362
Compare
5de0362
to
83eff85
Compare
83eff85
to
b89381c
Compare
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.
Thanks for the efforts, this LGTM.
I am most curious on how progress will work for other endpoints but I like the way it was thought and the implementation details here.
@@ -124,7 +129,12 @@ def call_api( | |||
) | |||
|
|||
try: | |||
result = endpoint.fn(options, cfg) | |||
if endpoint.supports_progress: |
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.
smart
with lock.RetryLock( | ||
lock_holder="u.pro.services.enable.v1", | ||
): | ||
success, fail_reason = entitlement.enable(progress) |
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.
should we try to refresh the contract similar to what the CLI does ?
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.
As discussed, created #3042 to cover adding this with caching
ent_cls = entitlements.entitlement_factory( | ||
cfg=cfg, name=options.service, variant=options.variant or "" | ||
) | ||
entitlement = ent_cls( | ||
cfg, | ||
assume_yes=True, | ||
allow_beta=True, | ||
called_name=options.service, | ||
access_only=options.access_only, | ||
) |
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 we should handle the situation where the user provides an invalid service
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.
The exception already raised looks pretty good and I added it to the integration test. It looks like this:
{
"code": "entitlement-not-found",
"meta": {
"entitlement_name": "invalid"
},
"title": "could not find entitlement named \"invalid\""
}
if isinstance(msg, str) | ||
] | ||
|
||
progress.finish() |
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.
Should we also update the status cache and send the activity ping to the CS server here ?
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.
In standup we decided:
yes update status cache
no don't send activity ping (it will send on a timer anyway)
b89381c
to
c6fdef9
Compare
@lucasmoura updated! |
except wait I broke unit tests... fixing |
c6fdef9
to
10896fe
Compare
@lucasmoura okay now looking good :) |
2f45363
to
fc218d5
Compare
CI error is unrelated to this change |
Why is this needed?
This is based on #3028 so that should be merged first.
This adds u.pro.services.enable.v1 with progress support and the code to allow the
--show-progress
flag for theapi
subcommand.This does not yet refactor cli enable to use the api.
Test Steps
New tests should pass.
Checklist
Does this PR require extra reviews?