-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Emit notifications when creating User Task for a given Integration #47556
base: master
Are you sure you want to change the base?
Conversation
f7ac023
to
7868348
Compare
aeb8da5
to
d452cdd
Compare
7868348
to
1ee8889
Compare
d452cdd
to
5c59d0f
Compare
1ee8889
to
c2bae80
Compare
8048d2e
to
8688572
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.
Not entirely familiar with the notification system. But does the global notification not need to be deleted when the user task is deleted? Do we just want to wait for it to expire instead?
It should but I'm not too worried about it because UserTasks should expire after 10 minutes (twice the PollInterval of I'm hesitant in adding the deletion of the Notification when a given UserTask is deleted, because it would add some complexity and make the system slower. So, we would need to iterate over all UserTasks to check whether we must delete the Integration or update the expiration date. I would rather not do it for now, but please let me know what you think. |
bca87f4
to
1dbb17a
Compare
1dbb17a
to
6a81ac9
Compare
f1788bb
to
147f187
Compare
2da8ed9
to
2c6948c
Compare
279ec57
to
f3058a9
Compare
User Tasks is a new resource that contains issues about an integration. For now, User Tasks are only created to register issues related to auto enrolling EC2 instances. Other types of issues will be registered in the future. Users must proactively list User Tasks in order to understand existing issues. For now, this can only be done using `tctl get user_task`. An UI for this new resource will be created, but users still need to navigate to that UI to see what issues exist. This PR creates a new Notification type which is used to explicitly notify the user that the Integration has pending User Tasks. When are users notified about pending User Tasks? When a User Task is created or updated, if its state is OPEN, then a notification is created. Given that we can have dozens of UserTasks for a single integration, we had to ensure only one Notification exists per Integration. To do that, the current Notification ID is stored in the Integration's Status field. This way, when we try to create a new Notification, we ensure the existing one is deleted to prevent showing two (or more) Notifications saying "Your integration needs attention". All of this is protected by a semaphore lock. The DiscoveryService is highly async and multiple UserTasks can be created in parallel, and the locks prevents it.
f3058a9
to
c25372a
Compare
User Tasks is a new resource that contains issues about an integration.
For now, User Tasks are only created to register issues related to auto
enrolling EC2 instances.
Other types of issues will be registered in the future.
Users must proactively list User Tasks in order to understand existing
issues.
For now, this can only be done using
tctl get user_task
.An UI for this new resource will be created, but users still need to
navigate to that UI to see what issues exist.
This PR creates a new Notification type which is used to explicitly
notify the user that the Integration has pending User Tasks.
When are users notified about pending User Tasks?
When a User Task is created or updated, if its state is OPEN, then a
notification is created.
Given that we can have dozens of UserTasks for a single integration, we
had to ensure only one Notification exists per Integration.
To do that, the current Notification ID is stored in the Integration's
Status field.
This way, when we try to create a new Notification, we ensure the
existing one is deleted to prevent showing two (or more) Notifications
saying "Your integration needs attention".
All of this is protected by a semaphore lock. The DiscoveryService is
highly async and multiple UserTasks can be created in parallel, and the
locks prevents it.
Before merging: