Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: implement thin vertical slice of system-generated notifications#13537

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
dannykopping merged 30 commits intomainfromdk/system-notifications-lib
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
30 commits
Select commitHold shift + click to select a range
53c9cbb
feat: system-generated notifications
dannykoppingJun 11, 2024
4856aed
Fixing lint errors & minor tests
dannykoppingJun 11, 2024
cda6efb
Fixing dbauthz test
dannykoppingJun 11, 2024
86f937a
TestBufferedUpdates does not need a real db, altering test details sl…
dannykoppingJun 11, 2024
e8f1af2
Correct TestBufferedUpdates to count updated entries, use real db again
dannykoppingJun 12, 2024
a056f54
Use UUID for notifier IDs
dannykoppingJun 27, 2024
8c64d30
Small improvements from review suggestions
dannykoppingJun 27, 2024
ac149ec
Protect notifiers from modification during Stop()
dannykoppingJun 27, 2024
884fadf
Split out enqueuer as separate responsibility, get rid of singleton
dannykoppingJun 28, 2024
4e362e7
Remove unnecessary handler registry
dannykoppingJun 28, 2024
8097290
Remove unused context
dannykoppingJun 28, 2024
1b841ad
Centralise markdown rendering
dannykoppingJun 28, 2024
61f5bd6
Appease the linter
dannykoppingJun 28, 2024
3c8e33b
Only enqueue notification when not initiated by self
dannykoppingJul 1, 2024
757327c
Hide config flags which are unlikely to be modified by operators
dannykoppingJul 1, 2024
6f909ae
Remove unnecessary Labels struct
dannykoppingJul 1, 2024
36698c5
Enable experiment as safe
dannykoppingJul 1, 2024
c5701a6
Correcting bad refactor
dannykoppingJul 1, 2024
9d4c312
Initialize Enqueuer on API startup
dannykoppingJul 1, 2024
9380d8e
Only start one notifier since all dispatches are concurrent anyway
dannykoppingJul 1, 2024
4b7214d
Fix docs
dannykoppingJul 1, 2024
6679ef1
Fix lint error
dannykoppingJul 1, 2024
337997d
Merge branch 'main' of github.com:/coder/coder into dk/system-notific…
dannykoppingJul 2, 2024
ba5f7c6
Merge branch 'main' of github.com:/coder/coder into dk/system-notific…
dannykoppingJul 3, 2024
0f29293
Review feedback
dannykoppingJul 3, 2024
7c6c486
Merge branch 'main' of github.com:/coder/coder into dk/system-notific…
dannykoppingJul 4, 2024
c6e75c2
Fix lint failures
dannykoppingJul 4, 2024
aff9e6c
Review comments
dannykoppingJul 4, 2024
613e074
Avoid race by exposing number of pending updates
dannykoppingJul 4, 2024
faea7fc
Merge branch 'main' of github.com:/coder/coder into dk/system-notific…
dannykoppingJul 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Hide config flags which are unlikely to be modified by operators
Signed-off-by: Danny Kopping <danny@coder.com>
  • Loading branch information
@dannykopping
dannykopping committedJul 1, 2024
commit757327c7ff297ec74a639502859a660118043adf
38 changes: 0 additions & 38 deletionscli/testdata/coder_server_--help.golden
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -330,50 +330,12 @@ NOTIFICATIONS OPTIONS:
--notifications-dispatch-timeout duration, $CODER_NOTIFICATIONS_DISPATCH_TIMEOUT (default: 1m0s)
How long to wait while a notification is being sent before giving up.

--notifications-fetch-interval duration, $CODER_NOTIFICATIONS_FETCH_INTERVAL (default: 15s)
How often to query the database for queued notifications.

--notifications-lease-count int, $CODER_NOTIFICATIONS_LEASE_COUNT (default: 10)
How many notifications a notifier should lease per fetch interval.

--notifications-lease-period duration, $CODER_NOTIFICATIONS_LEASE_PERIOD (default: 2m0s)
How long a notifier should lease a message. This is effectively how
long a notification is 'owned' by a notifier, and once this period
expires it will be available for lease by another notifier. Leasing is
important in order for multiple running notifiers to not pick the same
messages to deliver concurrently. This lease period will only expire
if a notifier shuts down ungracefully; a dispatch of the notification
releases the lease.

--notifications-max-send-attempts int, $CODER_NOTIFICATIONS_MAX_SEND_ATTEMPTS (default: 5)
The upper limit of attempts to send a notification.

--notifications-method string, $CODER_NOTIFICATIONS_METHOD (default: smtp)
Which delivery method to use (available options: 'smtp', 'webhook').

--notifications-retry-interval duration, $CODER_NOTIFICATIONS_RETRY_INTERVAL (default: 5m0s)
The minimum time between retries.

--notifications-store-sync-buffer-size int, $CODER_NOTIFICATIONS_STORE_SYNC_BUFFER_SIZE (default: 50)
The notifications system buffers message updates in memory to ease
pressure on the database. This option controls how many updates are
kept in memory. The lower this value the lower the change of state
inconsistency in a non-graceful shutdown - but it also increases load
on the database. It is recommended to keep this option at its default
value.

--notifications-store-sync-interval duration, $CODER_NOTIFICATIONS_STORE_SYNC_INTERVAL (default: 2s)
The notifications system buffers message updates in memory to ease
pressure on the database. This option controls how often it
synchronizes its state with the database. The shorter this value the
lower the change of state inconsistency in a non-graceful shutdown -
but it also increases load on the database. It is recommended to keep
this option at its default value.

--notifications-worker-count int, $CODER_NOTIFICATIONS_WORKER_COUNT (default: 2)
How many workers should be processing messages in the queue; increase
this count if notifications are not being processed fast enough.

NOTIFICATIONS / EMAIL OPTIONS:
--notifications-email-from string, $CODER_NOTIFICATIONS_EMAIL_FROM
The sender's address to use.
Expand Down
40 changes: 20 additions & 20 deletionscli/testdata/server-config.yaml.golden
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -494,6 +494,26 @@ userQuietHoursSchedule:
# (default: false, type: bool)
allowWorkspaceRenames: false
notifications:
# Which delivery method to use (available options: 'smtp', 'webhook').
# (default: smtp, type: string)
method: smtp
# How long to wait while a notification is being sent before giving up.
# (default: 1m0s, type: duration)
dispatch-timeout: 1m0s
email:
# The sender's address to use.
# (default: <unset>, type: string)
from: ""
# The intermediary SMTP host through which emails are sent.
# (default: localhost:587, type: host:port)
smarthost: localhost:587
# The hostname identifying the SMTP server.
# (default: localhost, type: string)
hello: localhost
webhook:
# The endpoint to which to send webhooks.
# (default: <unset>, type: url)
hello:
# The upper limit of attempts to send a notification.
# (default: 5, type: int)
max-send-attempts: 5
Expand DownExpand Up@@ -532,23 +552,3 @@ notifications:
# How often to query the database for queued notifications.
# (default: 15s, type: duration)
fetch-interval: 15s
# Which delivery method to use (available options: 'smtp', 'webhook').
# (default: smtp, type: string)
method: smtp
# How long to wait while a notification is being sent before giving up.
# (default: 1m0s, type: duration)
dispatch-timeout: 1m0s
email:
# The sender's address to use.
# (default: <unset>, type: string)
from: ""
# The intermediary SMTP host through which emails are sent.
# (default: localhost:587, type: host:port)
smarthost: localhost:587
# The hostname identifying the SMTP server.
# (default: localhost, type: string)
hello: localhost
webhook:
# The endpoint to which to send webhooks.
# (default: <unset>, type: url)
hello:
128 changes: 68 additions & 60 deletionscodersdk/deployment.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,10 +17,11 @@ import (

"github.com/coreos/go-oidc/v3/oidc"

"github.com/coder/serpent"

"github.com/coder/coder/v2/buildinfo"
"github.com/coder/coder/v2/coderd/agentmetrics"
"github.com/coder/coder/v2/coderd/workspaceapps/appurl"
"github.com/coder/serpent"
)

// Entitlement represents whether a feature is licensed.
Expand DownExpand Up@@ -2085,6 +2086,65 @@ Write out the current server config as YAML to stdout.`,
Annotations: serpent.Annotations{}.Mark(annotationFormatDuration, "true"),
},
// Notifications Options
{
Name: "Notifications: Method",
Description: "Which delivery method to use (available options: 'smtp', 'webhook').",
Flag: "notifications-method",
Env: "CODER_NOTIFICATIONS_METHOD",
Value: &c.Notifications.Method,
Default: "smtp",
Group: &deploymentGroupNotifications,
YAML: "method",
},
{
Name: "Notifications: Dispatch Timeout",
Description: "How long to wait while a notification is being sent before giving up.",
Flag: "notifications-dispatch-timeout",
Env: "CODER_NOTIFICATIONS_DISPATCH_TIMEOUT",
Value: &c.Notifications.DispatchTimeout,
Default: time.Minute.String(),
Group: &deploymentGroupNotifications,
YAML: "dispatch-timeout",
Annotations: serpent.Annotations{}.Mark(annotationFormatDuration, "true"),
},
{
Name: "Notifications: Email: From Address",
Description: "The sender's address to use.",
Flag: "notifications-email-from",
Env: "CODER_NOTIFICATIONS_EMAIL_FROM",
Value: &c.Notifications.SMTP.From,
Group: &deploymentGroupNotificationsEmail,
YAML: "from",
},
{
Name: "Notifications: Email: Smarthost",
Description: "The intermediary SMTP host through which emails are sent.",
Flag: "notifications-email-smarthost",
Env: "CODER_NOTIFICATIONS_EMAIL_SMARTHOST",
Default: "localhost:587", // To pass validation.
Value: &c.Notifications.SMTP.Smarthost,
Group: &deploymentGroupNotificationsEmail,
YAML: "smarthost",
},
{
Name: "Notifications: Email: Hello",
Description: "The hostname identifying the SMTP server.",
Flag: "notifications-email-hello",
Env: "CODER_NOTIFICATIONS_EMAIL_HELLO",
Default: "localhost",
Value: &c.Notifications.SMTP.Hello,
Group: &deploymentGroupNotificationsEmail,
YAML: "hello",
},
{
Name: "Notifications: Webhook: Endpoint",
Description: "The endpoint to which to send webhooks.",
Flag: "notifications-webhook-endpoint",
Env: "CODER_NOTIFICATIONS_WEBHOOK_ENDPOINT",
Value: &c.Notifications.Webhook.Endpoint,
Group: &deploymentGroupNotificationsWebhook,
YAML: "hello",
},
{
Name: "Notifications: Max Send Attempts",
Description: "The upper limit of attempts to send a notification.",
Expand All@@ -2105,6 +2165,7 @@ Write out the current server config as YAML to stdout.`,
Group: &deploymentGroupNotifications,
YAML: "retry-interval",
Annotations: serpent.Annotations{}.Mark(annotationFormatDuration, "true"),
Hidden: true, // Hidden because most operators should not need to modify this.
},
{
Name: "Notifications: Store Sync Interval",
Expand All@@ -2119,6 +2180,7 @@ Write out the current server config as YAML to stdout.`,
Group: &deploymentGroupNotifications,
YAML: "store-sync-interval",
Annotations: serpent.Annotations{}.Mark(annotationFormatDuration, "true"),
Hidden: true, // Hidden because most operators should not need to modify this.
},
{
Name: "Notifications: Store Sync Buffer Size",
Expand All@@ -2132,6 +2194,7 @@ Write out the current server config as YAML to stdout.`,
Default: "50",
Group: &deploymentGroupNotifications,
YAML: "store-sync-buffer-size",
Hidden: true, // Hidden because most operators should not need to modify this.
},
{
Name: "Notifications: Worker Count",
Expand All@@ -2143,6 +2206,7 @@ Write out the current server config as YAML to stdout.`,
Default: "2",
Group: &deploymentGroupNotifications,
YAML: "worker-count",
Hidden: true, // Hidden because most operators should not need to modify this.
},
{
Name: "Notifications: Lease Period",
Expand All@@ -2158,6 +2222,7 @@ Write out the current server config as YAML to stdout.`,
Group: &deploymentGroupNotifications,
YAML: "lease-period",
Annotations: serpent.Annotations{}.Mark(annotationFormatDuration, "true"),
Hidden: true, // Hidden because most operators should not need to modify this.
},
{
Name: "Notifications: Lease Count",
Expand All@@ -2168,6 +2233,7 @@ Write out the current server config as YAML to stdout.`,
Default: "10",
Group: &deploymentGroupNotifications,
YAML: "lease-count",
Hidden: true, // Hidden because most operators should not need to modify this.
},
{
Name: "Notifications: Fetch Interval",
Expand All@@ -2179,65 +2245,7 @@ Write out the current server config as YAML to stdout.`,
Group: &deploymentGroupNotifications,
YAML: "fetch-interval",
Annotations: serpent.Annotations{}.Mark(annotationFormatDuration, "true"),
},
{
Name: "Notifications: Method",
Description: "Which delivery method to use (available options: 'smtp', 'webhook').",
Flag: "notifications-method",
Env: "CODER_NOTIFICATIONS_METHOD",
Value: &c.Notifications.Method,
Default: "smtp",
Group: &deploymentGroupNotifications,
YAML: "method",
},
{
Name: "Notifications: Dispatch Timeout",
Description: "How long to wait while a notification is being sent before giving up.",
Flag: "notifications-dispatch-timeout",
Env: "CODER_NOTIFICATIONS_DISPATCH_TIMEOUT",
Value: &c.Notifications.DispatchTimeout,
Default: time.Minute.String(),
Group: &deploymentGroupNotifications,
YAML: "dispatch-timeout",
Annotations: serpent.Annotations{}.Mark(annotationFormatDuration, "true"),
},
{
Name: "Notifications: Email: From Address",
Description: "The sender's address to use.",
Flag: "notifications-email-from",
Env: "CODER_NOTIFICATIONS_EMAIL_FROM",
Value: &c.Notifications.SMTP.From,
Group: &deploymentGroupNotificationsEmail,
YAML: "from",
},
{
Name: "Notifications: Email: Smarthost",
Description: "The intermediary SMTP host through which emails are sent.",
Flag: "notifications-email-smarthost",
Env: "CODER_NOTIFICATIONS_EMAIL_SMARTHOST",
Default: "localhost:587", // To pass validation.
Value: &c.Notifications.SMTP.Smarthost,
Group: &deploymentGroupNotificationsEmail,
YAML: "smarthost",
},
{
Name: "Notifications: Email: Hello",
Description: "The hostname identifying the SMTP server.",
Flag: "notifications-email-hello",
Env: "CODER_NOTIFICATIONS_EMAIL_HELLO",
Default: "localhost",
Value: &c.Notifications.SMTP.Hello,
Group: &deploymentGroupNotificationsEmail,
YAML: "hello",
},
{
Name: "Notifications: Webhook: Endpoint",
Description: "The endpoint to which to send webhooks.",
Flag: "notifications-webhook-endpoint",
Env: "CODER_NOTIFICATIONS_WEBHOOK_ENDPOINT",
Value: &c.Notifications.Webhook.Endpoint,
Group: &deploymentGroupNotificationsWebhook,
YAML: "hello",
Hidden: true, // Hidden because most operators should not need to modify this.
},
}

Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp