-
Notifications
You must be signed in to change notification settings - Fork 889
feat: add force refresh of license entitlements #9155
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
Conversation
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.
BE LGTM 👍
enterprise/coderd/licenses.go
Outdated
err = api.Pubsub.Publish(PubsubEventLicenses, []byte("refresh")) | ||
if err != nil { | ||
api.Logger.Error(context.Background(), "failed to publish forced entitlement update", slog.Error(err)) | ||
// don't fail the HTTP request, since we did write it successfully to the database |
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 you should still fail the request if it fails to notify other replicas to update
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.
Ok 👍
<Button | ||
onClick={() => { | ||
if (refreshEntitlements) { | ||
if (refreshEntitlements()) { |
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.
Why is this in an if
?
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 it isn't null
, I do not want to call a null function.
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.
Could you do if (!!refreshEntitlements && refreshEntitlements())
onClick={() => { | ||
if (refreshEntitlements) { | ||
if (refreshEntitlements()) { | ||
displaySuccess("Successfully refreshed licenses") |
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.
Sending an event is not a sync operation so does not make too much sense to display this message here. Since you are using XState for that, you could do:
- Call the
refreshEntitlements
function - In the refresh button, add a prop
loading={...}
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.
Hmm, ngl I was not sure exactly how to get this done
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.
@BrunoQuaresma can I merge this and then we improve it?
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.
Yeap!
Closes #8665
What this does
PubsubEventLicenses
pubsub to force a new entitlement update on other Coderds. This should update the replica count and remove the warning. This should fix things without any intervention.Abuse prevention
I prevent force refreshing more than once per minute
Manual Refresh
@BrunoQuaresma thoughts?
Peek.2023-08-17.16-56.webm