- Notifications
You must be signed in to change notification settings - Fork927
chore: remove notifications experiment#14869
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
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
5cc1e73
cb0be34
6e7c919
7c571ae
0107ad1
0aa6d7b
bf1a148
27d28b3
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -56,15 +56,16 @@ import ( | ||
"cdr.dev/slog" | ||
"cdr.dev/slog/sloggers/sloghuman" | ||
"github.com/coder/pretty" | ||
"github.com/coder/quartz" | ||
"github.com/coder/retry" | ||
"github.com/coder/serpent" | ||
"github.com/coder/wgtunnel/tunnelsdk" | ||
"github.com/coder/coder/v2/coderd/entitlements" | ||
"github.com/coder/coder/v2/coderd/notifications/reports" | ||
"github.com/coder/coder/v2/coderd/runtimeconfig" | ||
dannykopping marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
"github.com/coder/coder/v2/buildinfo" | ||
"github.com/coder/coder/v2/cli/clilog" | ||
"github.com/coder/coder/v2/cli/cliui" | ||
@@ -679,10 +680,6 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd. | ||
options.OIDCConfig = oc | ||
} | ||
// We'll read from this channel in the select below that tracks shutdown. If it remains | ||
// nil, that case of the select will just never fire, but it's important not to have a | ||
// "bare" read on this channel. | ||
@@ -946,6 +943,33 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd. | ||
return xerrors.Errorf("write config url: %w", err) | ||
} | ||
// Manage notifications. | ||
cfg := options.DeploymentValues.Notifications | ||
metrics := notifications.NewMetrics(options.PrometheusRegistry) | ||
helpers := templateHelpers(options) | ||
// The enqueuer is responsible for enqueueing notifications to the given store. | ||
enqueuer, err := notifications.NewStoreEnqueuer(cfg, options.Database, helpers, logger.Named("notifications.enqueuer"), quartz.NewReal()) | ||
if err != nil { | ||
return xerrors.Errorf("failed to instantiate notification store enqueuer: %w", err) | ||
} | ||
options.NotificationsEnqueuer = enqueuer | ||
// The notification manager is responsible for: | ||
// - creating notifiers and managing their lifecycles (notifiers are responsible for dequeueing/sending notifications) | ||
// - keeping the store updated with status updates | ||
notificationsManager, err := notifications.NewManager(cfg, options.Database, helpers, metrics, logger.Named("notifications.manager")) | ||
if err != nil { | ||
return xerrors.Errorf("failed to instantiate notification manager: %w", err) | ||
} | ||
// nolint:gocritic // TODO: create own role. | ||
notificationsManager.Run(dbauthz.AsSystemRestricted(ctx)) | ||
// Run report generator to distribute periodic reports. | ||
notificationReportGenerator := reports.NewReportGenerator(ctx, logger.Named("notifications.report_generator"), options.Database, options.NotificationsEnqueuer, quartz.NewReal()) | ||
defer notificationReportGenerator.Close() | ||
// Since errCh only has one buffered slot, all routines | ||
// sending on it must be wrapped in a select/default to | ||
// avoid leaving dangling goroutines waiting for the | ||
@@ -1002,38 +1026,6 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd. | ||
options.WorkspaceUsageTracker = tracker | ||
defer tracker.Close() | ||
// Wrap the server in middleware that redirects to the access URL if | ||
// the request is not to a local IP. | ||
var handler http.Handler = coderAPI.RootHandler | ||
@@ -1153,19 +1145,17 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd. | ||
// Cancel any remaining in-flight requests. | ||
shutdownConns() | ||
// Stop the notification manager, which will cause any buffered updates to the store to be flushed. | ||
// If the Stop() call times out, messages that were sent but not reflected as such in the store will have | ||
// their leases expire after a period of time and will be re-queued for sending. | ||
// See CODER_NOTIFICATIONS_LEASE_PERIOD. | ||
cliui.Info(inv.Stdout, "Shutting down notifications manager..."+"\n") | ||
err = shutdownWithTimeout(notificationsManager.Stop, 5*time.Second) | ||
if err != nil { | ||
cliui.Warnf(inv.Stderr, "Notifications manager shutdown took longer than 5s, "+ | ||
"this may result in duplicate notifications being sent: %s\n", err) | ||
} else { | ||
cliui.Info(inv.Stdout, "Gracefully shut down notifications manager\n") | ||
} | ||
// Shut down provisioners before waiting for WebSockets | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -49,7 +49,7 @@ func NewReportGenerator(ctx context.Context, logger slog.Logger, db database.Sto | ||
return nil | ||
} | ||
err = reportFailedWorkspaceBuilds(ctx, logger,tx, enqueuer, clk) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Passing the main | ||
if err != nil { | ||
return xerrors.Errorf("unable to generate reports with failed workspace builds: %w", err) | ||
} | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -20,7 +20,6 @@ func createOpts(t *testing.T) *coderdtest.Options { | ||
t.Helper() | ||
dt := coderdtest.DeploymentValues(t) | ||
dannykopping marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
return &coderdtest.Options{ | ||
DeploymentValues: dt, | ||
} | ||
Uh oh!
There was an error while loading.Please reload this page.