Skip to content

Commit 764b0cc

Browse files
Merge branch 'main' into dm-request-and-submit-passcode
2 parents 25581c2 + d0a8424 commit 764b0cc

File tree

143 files changed

+6920
-2301
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+6920
-2301
lines changed

.github/workflows/contrib.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
steps:
3737
- name: cla
3838
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
39-
uses: contributor-assistant/github-action@v2.6.0
39+
uses: contributor-assistant/github-action@v2.6.1
4040
env:
4141
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4242
# the below token should have repo scope and must be manually added by you in the repository's secret

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@ gen: \
488488
agent/proto/agent.pb.go \
489489
provisionersdk/proto/provisioner.pb.go \
490490
provisionerd/proto/provisionerd.pb.go \
491+
vpn/vpn.pb.go \
491492
coderd/database/dump.sql \
492493
$(DB_GEN_FILES) \
493494
site/src/api/typesGenerated.ts \
@@ -517,6 +518,7 @@ gen/mark-fresh:
517518
agent/proto/agent.pb.go \
518519
provisionersdk/proto/provisioner.pb.go \
519520
provisionerd/proto/provisionerd.pb.go \
521+
vpn/vpn.pb.go \
520522
coderd/database/dump.sql \
521523
$(DB_GEN_FILES) \
522524
site/src/api/typesGenerated.ts \
@@ -600,6 +602,12 @@ provisionerd/proto/provisionerd.pb.go: provisionerd/proto/provisionerd.proto
600602
--go-drpc_opt=paths=source_relative \
601603
./provisionerd/proto/provisionerd.proto
602604

605+
vpn/vpn.pb.go: vpn/vpn.proto
606+
protoc \
607+
--go_out=. \
608+
--go_opt=paths=source_relative \
609+
./vpn/vpn.proto
610+
603611
site/src/api/typesGenerated.ts: $(wildcard scripts/apitypings/*) $(shell find ./codersdk $(FIND_EXCLUSIONS) -type f -name '*.go')
604612
go run ./scripts/apitypings/ > $@
605613
./scripts/pnpm_install.sh

cli/notifications_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ func createOpts(t *testing.T) *coderdtest.Options {
2020
t.Helper()
2121

2222
dt := coderdtest.DeploymentValues(t)
23-
dt.Experiments = []string{string(codersdk.ExperimentNotifications)}
2423
return &coderdtest.Options{
2524
DeploymentValues: dt,
2625
}

cli/server.go

Lines changed: 42 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,16 @@ import (
5656

5757
"cdr.dev/slog"
5858
"cdr.dev/slog/sloggers/sloghuman"
59-
"github.com/coder/coder/v2/coderd/entitlements"
60-
"github.com/coder/coder/v2/coderd/notifications/reports"
61-
"github.com/coder/coder/v2/coderd/runtimeconfig"
6259
"github.com/coder/pretty"
6360
"github.com/coder/quartz"
6461
"github.com/coder/retry"
6562
"github.com/coder/serpent"
6663
"github.com/coder/wgtunnel/tunnelsdk"
6764

65+
"github.com/coder/coder/v2/coderd/entitlements"
66+
"github.com/coder/coder/v2/coderd/notifications/reports"
67+
"github.com/coder/coder/v2/coderd/runtimeconfig"
68+
6869
"github.com/coder/coder/v2/buildinfo"
6970
"github.com/coder/coder/v2/cli/clilog"
7071
"github.com/coder/coder/v2/cli/cliui"
@@ -684,10 +685,6 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
684685
options.OIDCConfig = oc
685686
}
686687

687-
experiments := coderd.ReadExperiments(
688-
options.Logger, options.DeploymentValues.Experiments.Value(),
689-
)
690-
691688
// We'll read from this channel in the select below that tracks shutdown. If it remains
692689
// nil, that case of the select will just never fire, but it's important not to have a
693690
// "bare" read on this channel.
@@ -951,6 +948,33 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
951948
return xerrors.Errorf("write config url: %w", err)
952949
}
953950

951+
// Manage notifications.
952+
cfg := options.DeploymentValues.Notifications
953+
metrics := notifications.NewMetrics(options.PrometheusRegistry)
954+
helpers := templateHelpers(options)
955+
956+
// The enqueuer is responsible for enqueueing notifications to the given store.
957+
enqueuer, err := notifications.NewStoreEnqueuer(cfg, options.Database, helpers, logger.Named("notifications.enqueuer"), quartz.NewReal())
958+
if err != nil {
959+
return xerrors.Errorf("failed to instantiate notification store enqueuer: %w", err)
960+
}
961+
options.NotificationsEnqueuer = enqueuer
962+
963+
// The notification manager is responsible for:
964+
// - creating notifiers and managing their lifecycles (notifiers are responsible for dequeueing/sending notifications)
965+
// - keeping the store updated with status updates
966+
notificationsManager, err := notifications.NewManager(cfg, options.Database, helpers, metrics, logger.Named("notifications.manager"))
967+
if err != nil {
968+
return xerrors.Errorf("failed to instantiate notification manager: %w", err)
969+
}
970+
971+
// nolint:gocritic // TODO: create own role.
972+
notificationsManager.Run(dbauthz.AsSystemRestricted(ctx))
973+
974+
// Run report generator to distribute periodic reports.
975+
notificationReportGenerator := reports.NewReportGenerator(ctx, logger.Named("notifications.report_generator"), options.Database, options.NotificationsEnqueuer, quartz.NewReal())
976+
defer notificationReportGenerator.Close()
977+
954978
// Since errCh only has one buffered slot, all routines
955979
// sending on it must be wrapped in a select/default to
956980
// avoid leaving dangling goroutines waiting for the
@@ -1007,38 +1031,6 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
10071031
options.WorkspaceUsageTracker = tracker
10081032
defer tracker.Close()
10091033

1010-
// Manage notifications.
1011-
var (
1012-
notificationsManager *notifications.Manager
1013-
)
1014-
if experiments.Enabled(codersdk.ExperimentNotifications) {
1015-
cfg := options.DeploymentValues.Notifications
1016-
metrics := notifications.NewMetrics(options.PrometheusRegistry)
1017-
helpers := templateHelpers(options)
1018-
1019-
// The enqueuer is responsible for enqueueing notifications to the given store.
1020-
enqueuer, err := notifications.NewStoreEnqueuer(cfg, options.Database, helpers, logger.Named("notifications.enqueuer"), quartz.NewReal())
1021-
if err != nil {
1022-
return xerrors.Errorf("failed to instantiate notification store enqueuer: %w", err)
1023-
}
1024-
options.NotificationsEnqueuer = enqueuer
1025-
1026-
// The notification manager is responsible for:
1027-
// - creating notifiers and managing their lifecycles (notifiers are responsible for dequeueing/sending notifications)
1028-
// - keeping the store updated with status updates
1029-
notificationsManager, err = notifications.NewManager(cfg, options.Database, helpers, metrics, logger.Named("notifications.manager"))
1030-
if err != nil {
1031-
return xerrors.Errorf("failed to instantiate notification manager: %w", err)
1032-
}
1033-
1034-
// nolint:gocritic // TODO: create own role.
1035-
notificationsManager.Run(dbauthz.AsSystemRestricted(ctx))
1036-
1037-
// Run report generator to distribute periodic reports.
1038-
notificationReportGenerator := reports.NewReportGenerator(ctx, logger.Named("notifications.report_generator"), options.Database, options.NotificationsEnqueuer, quartz.NewReal())
1039-
defer notificationReportGenerator.Close()
1040-
}
1041-
10421034
// Wrap the server in middleware that redirects to the access URL if
10431035
// the request is not to a local IP.
10441036
var handler http.Handler = coderAPI.RootHandler
@@ -1158,19 +1150,17 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
11581150
// Cancel any remaining in-flight requests.
11591151
shutdownConns()
11601152

1161-
if notificationsManager != nil {
1162-
// Stop the notification manager, which will cause any buffered updates to the store to be flushed.
1163-
// If the Stop() call times out, messages that were sent but not reflected as such in the store will have
1164-
// their leases expire after a period of time and will be re-queued for sending.
1165-
// See CODER_NOTIFICATIONS_LEASE_PERIOD.
1166-
cliui.Info(inv.Stdout, "Shutting down notifications manager..."+"\n")
1167-
err = shutdownWithTimeout(notificationsManager.Stop, 5*time.Second)
1168-
if err != nil {
1169-
cliui.Warnf(inv.Stderr, "Notifications manager shutdown took longer than 5s, "+
1170-
"this may result in duplicate notifications being sent: %s\n", err)
1171-
} else {
1172-
cliui.Info(inv.Stdout, "Gracefully shut down notifications manager\n")
1173-
}
1153+
// Stop the notification manager, which will cause any buffered updates to the store to be flushed.
1154+
// If the Stop() call times out, messages that were sent but not reflected as such in the store will have
1155+
// their leases expire after a period of time and will be re-queued for sending.
1156+
// See CODER_NOTIFICATIONS_LEASE_PERIOD.
1157+
cliui.Info(inv.Stdout, "Shutting down notifications manager..."+"\n")
1158+
err = shutdownWithTimeout(notificationsManager.Stop, 5*time.Second)
1159+
if err != nil {
1160+
cliui.Warnf(inv.Stderr, "Notifications manager shutdown took longer than 5s, "+
1161+
"this may result in duplicate notifications being sent: %s\n", err)
1162+
} else {
1163+
cliui.Info(inv.Stdout, "Gracefully shut down notifications manager\n")
11741164
}
11751165

11761166
// Shut down provisioners before waiting for WebSockets

coderd/apidoc/docs.go

Lines changed: 36 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 32 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/coderd.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,12 @@ import (
3737
"tailscale.com/util/singleflight"
3838

3939
"cdr.dev/slog"
40+
"github.com/coder/quartz"
41+
"github.com/coder/serpent"
42+
4043
"github.com/coder/coder/v2/coderd/entitlements"
4144
"github.com/coder/coder/v2/coderd/idpsync"
4245
"github.com/coder/coder/v2/coderd/runtimeconfig"
43-
"github.com/coder/quartz"
44-
"github.com/coder/serpent"
4546

4647
agentproto "github.com/coder/coder/v2/agent/proto"
4748
"github.com/coder/coder/v2/buildinfo"
@@ -1259,10 +1260,7 @@ func New(options *Options) *API {
12591260
})
12601261
})
12611262
r.Route("/notifications", func(r chi.Router) {
1262-
r.Use(
1263-
apiKeyMiddleware,
1264-
httpmw.RequireExperiment(api.Experiments, codersdk.ExperimentNotifications),
1265-
)
1263+
r.Use(apiKeyMiddleware)
12661264
r.Get("/settings", api.notificationsSettings)
12671265
r.Put("/settings", api.putNotificationsSettings)
12681266
r.Route("/templates", func(r chi.Router) {

0 commit comments

Comments
 (0)