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

Commit683a720

Browse files
stirbydannykoppingf0sselbpmctspikecurtis
authored
chore: cherry pick updates for v2.16.0 (#14919)
- [x]#14869- [x]#14778- [x]#14883Addition to resolve flake: - [x]#14875---------Co-authored-by: Danny Kopping <dannykopping@gmail.com>Co-authored-by: Garrett Delfosse <garrett@coder.com>Co-authored-by: Ben Potter <ben@coder.com>Co-authored-by: Spike Curtis <spike@coder.com>
1 parent5246f8d commit683a720

File tree

70 files changed

+875
-501
lines changed

Some content is hidden

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

70 files changed

+875
-501
lines changed

‎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"
@@ -679,10 +680,6 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
679680
options.OIDCConfig=oc
680681
}
681682

682-
experiments:=coderd.ReadExperiments(
683-
options.Logger,options.DeploymentValues.Experiments.Value(),
684-
)
685-
686683
// We'll read from this channel in the select below that tracks shutdown. If it remains
687684
// nil, that case of the select will just never fire, but it's important not to have a
688685
// "bare" read on this channel.
@@ -946,6 +943,33 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
946943
returnxerrors.Errorf("write config url: %w",err)
947944
}
948945

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

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

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

11711161
// Shut down provisioners before waiting for WebSockets

‎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"
@@ -1257,10 +1258,7 @@ func New(options *Options) *API {
12571258
})
12581259
})
12591260
r.Route("/notifications",func(r chi.Router) {
1260-
r.Use(
1261-
apiKeyMiddleware,
1262-
httpmw.RequireExperiment(api.Experiments,codersdk.ExperimentNotifications),
1263-
)
1261+
r.Use(apiKeyMiddleware)
12641262
r.Get("/settings",api.notificationsSettings)
12651263
r.Put("/settings",api.putNotificationsSettings)
12661264
r.Route("/templates",func(r chi.Router) {

‎coderd/notifications/manager.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ type Manager struct {
5454

5555
runOnce sync.Once
5656
stopOnce sync.Once
57+
doneOnce sync.Once
5758
stopchanany
5859
donechanany
5960

@@ -153,7 +154,9 @@ func (m *Manager) Run(ctx context.Context) {
153154
// events, creating a notifier, and publishing bulk dispatch result updates to the store.
154155
func (m*Manager)loop(ctx context.Context)error {
155156
deferfunc() {
156-
close(m.done)
157+
m.doneOnce.Do(func() {
158+
close(m.done)
159+
})
157160
m.log.Info(context.Background(),"notification manager stopped")
158161
}()
159162

@@ -364,7 +367,9 @@ func (m *Manager) Stop(ctx context.Context) error {
364367
// If the notifier hasn't been started, we don't need to wait for anything.
365368
// This is only really during testing when we want to enqueue messages only but not deliver them.
366369
ifm.notifier==nil {
367-
close(m.done)
370+
m.doneOnce.Do(func() {
371+
close(m.done)
372+
})
368373
}else {
369374
m.notifier.stop()
370375
}

‎coderd/notifications/notifications_test.go

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

11891189
dt:=coderdtest.DeploymentValues(t)
1190-
dt.Experiments= []string{string(codersdk.ExperimentNotifications)}
11911190
return&coderdtest.Options{
11921191
DeploymentValues:dt,
11931192
}

‎coderd/notifications/reports/generator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func NewReportGenerator(ctx context.Context, logger slog.Logger, db database.Sto
4949
returnnil
5050
}
5151

52-
err=reportFailedWorkspaceBuilds(ctx,logger,db,enqueuer,clk)
52+
err=reportFailedWorkspaceBuilds(ctx,logger,tx,enqueuer,clk)
5353
iferr!=nil {
5454
returnxerrors.Errorf("unable to generate reports with failed workspace builds: %w",err)
5555
}

‎coderd/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
}

‎codersdk/deployment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2901,7 +2901,7 @@ const (
29012901
// users to opt-in to via --experimental='*'.
29022902
// Experiments that are not ready for consumption by all users should
29032903
// not be included here and will be essentially hidden.
2904-
varExperimentsAll=Experiments{ExperimentNotifications}
2904+
varExperimentsAll=Experiments{}
29052905

29062906
// Experiments is a list of experiments.
29072907
// Multiple experiments may be enabled at the same time.

‎codersdk/provisionerdaemons.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212

1313
"github.com/google/uuid"
1414
"github.com/hashicorp/yamux"
15+
"golang.org/x/exp/maps"
16+
"golang.org/x/exp/slices"
1517
"golang.org/x/xerrors"
1618
"nhooyr.io/websocket"
1719

@@ -278,9 +280,11 @@ func (c *Client) ServeProvisionerDaemon(ctx context.Context, req ServeProvisione
278280
typeProvisionerKeyTagsmap[string]string
279281

280282
func (pProvisionerKeyTags)String()string {
283+
keys:=maps.Keys(p)
284+
slices.Sort(keys)
281285
tags:= []string{}
282-
forkey,value:=rangep {
283-
tags=append(tags,fmt.Sprintf("%s=%s",key,value))
286+
for_,key:=rangekeys {
287+
tags=append(tags,fmt.Sprintf("%s=%s",key,p[key]))
284288
}
285289
returnstrings.Join(tags," ")
286290
}

‎docs/admin/appearance.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Appearance (enterprise)
1+
#Appearance (enterprise) (premium)
22

33
Customize the look of your Coder deployment to meet your enterprise
44
requirements.
@@ -93,7 +93,3 @@ For CLI, use,
9393
export CODER_SUPPORT_LINKS='[{"name": "Hello GitHub", "target": "https://github.com/coder/coder", "icon": "bug"}, {"name": "Hello Slack", "target": "https://codercom.slack.com/archives/C014JH42DBJ", "icon": "https://raw.githubusercontent.com/coder/coder/main/site/static/icon/slack.svg"}, {"name": "Hello Discord", "target": "https://discord.gg/coder", "icon": "https://raw.githubusercontent.com/coder/coder/main/site/static/icon/discord.svg"}, {"name": "Hello Foobar", "target": "https://discord.gg/coder", "icon": "/emojis/1f3e1.png"}]'
9494
coder-server
9595
```
96-
97-
## Up next
98-
99-
-[Enterprise](../enterprise.md)

‎docs/admin/audit-logs.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,5 +122,5 @@ entry:
122122

123123
##Enabling this feature
124124

125-
This feature is only available withan enterprise license.
126-
[Learn more](../enterprise.md)
125+
This feature is only available witha
126+
[Premium or Enterprise license](https://coder.com/pricing).

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp