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

Commit26e7bdd

Browse files
committed
Merge branch 'main' into stevenmasley/org_group_sync
2 parents0df7f28 +3301212 commit26e7bdd

File tree

47 files changed

+1112
-251
lines changed

Some content is hidden

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

47 files changed

+1112
-251
lines changed

‎.github/workflows/stale.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ jobs:
1717
with:
1818
stale-issue-label:"stale"
1919
stale-pr-label:"stale"
20-
days-before-stale:180
20+
# days-before-stale: 180
21+
# essentially disabled for now while we work through polish issues
22+
days-before-stale:3650
23+
2124
# Pull Requests become stale more quickly due to merge conflicts.
2225
# Also, we promote minimizing WIP.
2326
days-before-pr-stale:7

‎agent/agent.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1510,6 +1510,8 @@ func (a *agent) Collect(ctx context.Context, networkStats map[netlogtype.Connect
15101510
varmu sync.Mutex
15111511
status:=a.network.Status()
15121512
durations:= []float64{}
1513+
p2pConns:=0
1514+
derpConns:=0
15131515
pingCtx,cancelFunc:=context.WithTimeout(ctx,5*time.Second)
15141516
defercancelFunc()
15151517
fornodeID,peer:=rangestatus.Peer {
@@ -1526,13 +1528,18 @@ func (a *agent) Collect(ctx context.Context, networkStats map[netlogtype.Connect
15261528
wg.Add(1)
15271529
gofunc() {
15281530
deferwg.Done()
1529-
duration,_,_,err:=a.network.Ping(pingCtx,addresses[0].Addr())
1531+
duration,p2p,_,err:=a.network.Ping(pingCtx,addresses[0].Addr())
15301532
iferr!=nil {
15311533
return
15321534
}
15331535
mu.Lock()
15341536
defermu.Unlock()
15351537
durations=append(durations,float64(duration.Microseconds()))
1538+
ifp2p {
1539+
p2pConns++
1540+
}else {
1541+
derpConns++
1542+
}
15361543
}()
15371544
}
15381545
wg.Wait()
@@ -1552,6 +1559,9 @@ func (a *agent) Collect(ctx context.Context, networkStats map[netlogtype.Connect
15521559
// Agent metrics are changing all the time, so there is no need to perform
15531560
// reflect.DeepEqual to see if stats should be transferred.
15541561

1562+
// currentConnections behaves like a hypothetical `GaugeFuncVec` and is only set at collection time.
1563+
a.metrics.currentConnections.WithLabelValues("p2p").Set(float64(p2pConns))
1564+
a.metrics.currentConnections.WithLabelValues("derp").Set(float64(derpConns))
15551565
metricsCtx,cancelFunc:=context.WithTimeout(ctx,5*time.Second)
15561566
defercancelFunc()
15571567
a.logger.Debug(ctx,"collecting agent metrics for stats")

‎agent/agent_test.go

Lines changed: 52 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2531,17 +2531,17 @@ func TestAgent_Metrics_SSH(t *testing.T) {
25312531
err=session.Shell()
25322532
require.NoError(t,err)
25332533

2534-
expected:= []agentsdk.AgentMetric{
2534+
expected:= []*proto.Stats_Metric{
25352535
{
25362536
Name:"agent_reconnecting_pty_connections_total",
2537-
Type:agentsdk.AgentMetricTypeCounter,
2537+
Type:proto.Stats_Metric_COUNTER,
25382538
Value:0,
25392539
},
25402540
{
25412541
Name:"agent_sessions_total",
2542-
Type:agentsdk.AgentMetricTypeCounter,
2542+
Type:proto.Stats_Metric_COUNTER,
25432543
Value:1,
2544-
Labels: []agentsdk.AgentMetricLabel{
2544+
Labels: []*proto.Stats_Metric_Label{
25452545
{
25462546
Name:"magic_type",
25472547
Value:"ssh",
@@ -2554,30 +2554,46 @@ func TestAgent_Metrics_SSH(t *testing.T) {
25542554
},
25552555
{
25562556
Name:"agent_ssh_server_failed_connections_total",
2557-
Type:agentsdk.AgentMetricTypeCounter,
2557+
Type:proto.Stats_Metric_COUNTER,
25582558
Value:0,
25592559
},
25602560
{
25612561
Name:"agent_ssh_server_sftp_connections_total",
2562-
Type:agentsdk.AgentMetricTypeCounter,
2562+
Type:proto.Stats_Metric_COUNTER,
25632563
Value:0,
25642564
},
25652565
{
25662566
Name:"agent_ssh_server_sftp_server_errors_total",
2567-
Type:agentsdk.AgentMetricTypeCounter,
2567+
Type:proto.Stats_Metric_COUNTER,
25682568
Value:0,
25692569
},
25702570
{
2571-
Name:"coderd_agentstats_startup_script_seconds",
2572-
Type:agentsdk.AgentMetricTypeGauge,
2571+
Name:"coderd_agentstats_currently_reachable_peers",
2572+
Type:proto.Stats_Metric_GAUGE,
25732573
Value:0,
2574-
Labels: []agentsdk.AgentMetricLabel{
2574+
Labels: []*proto.Stats_Metric_Label{
2575+
{
2576+
Name:"connection_type",
2577+
Value:"derp",
2578+
},
2579+
},
2580+
},
2581+
{
2582+
Name:"coderd_agentstats_currently_reachable_peers",
2583+
Type:proto.Stats_Metric_GAUGE,
2584+
Value:1,
2585+
Labels: []*proto.Stats_Metric_Label{
25752586
{
2576-
Name:"success",
2577-
Value:"true",
2587+
Name:"connection_type",
2588+
Value:"p2p",
25782589
},
25792590
},
25802591
},
2592+
{
2593+
Name:"coderd_agentstats_startup_script_seconds",
2594+
Type:proto.Stats_Metric_GAUGE,
2595+
Value:1,
2596+
},
25812597
}
25822598

25832599
varactual []*promgo.MetricFamily
@@ -2586,17 +2602,33 @@ func TestAgent_Metrics_SSH(t *testing.T) {
25862602
iferr!=nil {
25872603
returnfalse
25882604
}
2589-
2590-
iflen(expected)!=len(actual) {
2591-
returnfalse
2605+
count:=0
2606+
for_,m:=rangeactual {
2607+
count+=len(m.GetMetric())
25922608
}
2593-
2594-
returnverifyCollectedMetrics(t,expected,actual)
2609+
returncount==len(expected)
25952610
},testutil.WaitLong,testutil.IntervalFast)
25962611

2597-
require.Len(t,actual,len(expected))
2598-
collected:=verifyCollectedMetrics(t,expected,actual)
2599-
require.True(t,collected,"expected metrics were not collected")
2612+
i:=0
2613+
for_,mf:=rangeactual {
2614+
for_,m:=rangemf.GetMetric() {
2615+
assert.Equal(t,expected[i].Name,mf.GetName())
2616+
assert.Equal(t,expected[i].Type.String(),mf.GetType().String())
2617+
// Value is max expected
2618+
ifexpected[i].Type==proto.Stats_Metric_GAUGE {
2619+
assert.GreaterOrEqualf(t,expected[i].Value,m.GetGauge().GetValue(),"expected %s to be greater than or equal to %f, got %f",expected[i].Name,expected[i].Value,m.GetGauge().GetValue())
2620+
}elseifexpected[i].Type==proto.Stats_Metric_COUNTER {
2621+
assert.GreaterOrEqualf(t,expected[i].Value,m.GetCounter().GetValue(),"expected %s to be greater than or equal to %f, got %f",expected[i].Name,expected[i].Value,m.GetCounter().GetValue())
2622+
}
2623+
forj,lbl:=rangeexpected[i].Labels {
2624+
assert.Equal(t,m.GetLabel()[j],&promgo.LabelPair{
2625+
Name:&lbl.Name,
2626+
Value:&lbl.Value,
2627+
})
2628+
}
2629+
i++
2630+
}
2631+
}
26002632

26012633
_=stdin.Close()
26022634
err=session.Wait()
@@ -2828,28 +2860,6 @@ func TestAgent_ManageProcessPriority(t *testing.T) {
28282860
})
28292861
}
28302862

2831-
funcverifyCollectedMetrics(t*testing.T,expected []agentsdk.AgentMetric,actual []*promgo.MetricFamily)bool {
2832-
t.Helper()
2833-
2834-
fori,e:=rangeexpected {
2835-
assert.Equal(t,e.Name,actual[i].GetName())
2836-
assert.Equal(t,string(e.Type),strings.ToLower(actual[i].GetType().String()))
2837-
2838-
for_,m:=rangeactual[i].GetMetric() {
2839-
assert.Equal(t,e.Value,m.Counter.GetValue())
2840-
2841-
iflen(m.GetLabel())>0 {
2842-
forj,lbl:=rangem.GetLabel() {
2843-
assert.Equal(t,e.Labels[j].Name,lbl.GetName())
2844-
assert.Equal(t,e.Labels[j].Value,lbl.GetValue())
2845-
}
2846-
}
2847-
m.GetLabel()
2848-
}
2849-
}
2850-
returntrue
2851-
}
2852-
28532863
typesyncWriterstruct {
28542864
mu sync.Mutex
28552865
w io.Writer

‎agent/metrics.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ type agentMetrics struct {
1919
// startupScriptSeconds is the time in seconds that the start script(s)
2020
// took to run. This is reported once per agent.
2121
startupScriptSeconds*prometheus.GaugeVec
22+
currentConnections*prometheus.GaugeVec
2223
}
2324

2425
funcnewAgentMetrics(registerer prometheus.Registerer)*agentMetrics {
@@ -45,10 +46,19 @@ func newAgentMetrics(registerer prometheus.Registerer) *agentMetrics {
4546
}, []string{"success"})
4647
registerer.MustRegister(startupScriptSeconds)
4748

49+
currentConnections:=prometheus.NewGaugeVec(prometheus.GaugeOpts{
50+
Namespace:"coderd",
51+
Subsystem:"agentstats",
52+
Name:"currently_reachable_peers",
53+
Help:"The number of peers (e.g. clients) that are currently reachable over the encrypted network.",
54+
}, []string{"connection_type"})
55+
registerer.MustRegister(currentConnections)
56+
4857
return&agentMetrics{
4958
connectionsTotal:connectionsTotal,
5059
reconnectingPTYErrors:reconnectingPTYErrors,
5160
startupScriptSeconds:startupScriptSeconds,
61+
currentConnections:currentConnections,
5262
}
5363
}
5464

‎cli/ping_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func TestPing(t *testing.T) {
6767

6868
pty.ExpectMatch("pong from "+workspace.Name)
6969
pty.ExpectMatch("✔ received remote agent data from Coder networking coordinator")
70-
pty.ExpectMatch("You are connected directly (p2p)")
70+
pty.ExpectMatch("You are connected")
7171
cancel()
7272
<-cmdDone
7373
})

‎cli/templatecreate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ func (r *RootCmd) templateCreate() *serpent.Command {
237237
},
238238
{
239239
Flag:"require-active-version",
240-
Description:"Requires workspace builds to use the active template version. This setting does not apply to template admins. This is an enterprise-only feature.",
240+
Description:"Requires workspace builds to use the active template version. This setting does not apply to template admins. This is an enterprise-only feature. See https://coder.com/docs/templates/general-settings#require-automatic-updates-enterprise for more details.",
241241
Value:serpent.BoolOf(&requireActiveVersion),
242242
Default:"false",
243243
},

‎cli/templateedit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ func (r *RootCmd) templateEdit() *serpent.Command {
290290
},
291291
{
292292
Flag:"require-active-version",
293-
Description:"Requires workspace builds to use the active template version. This setting does not apply to template admins. This is an enterprise-only feature.",
293+
Description:"Requires workspace builds to use the active template version. This setting does not apply to template admins. This is an enterprise-only feature. See https://coder.com/docs/templates/general-settings#require-automatic-updates-enterprise for more details.",
294294
Value:serpent.BoolOf(&requireActiveVersion),
295295
Default:"false",
296296
},

‎cli/testdata/coder_templates_create_--help.golden

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ OPTIONS:
5454
--require-active-version bool (default: false)
5555
Requires workspace builds to use the active template version. This
5656
setting does not apply to template admins. This is an enterprise-only
57-
feature.
57+
feature. See
58+
https://coder.com/docs/templates/general-settings#require-automatic-updates-enterprise
59+
for more details.
5860

5961
--var string-array
6062
Alias of --variable.

‎cli/testdata/coder_templates_edit_--help.golden

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ OPTIONS:
8686
--require-active-version bool (default: false)
8787
Requires workspace builds to use the active template version. This
8888
setting does not apply to template admins. This is an enterprise-only
89-
feature.
89+
feature. See
90+
https://coder.com/docs/templates/general-settings#require-automatic-updates-enterprise
91+
for more details.
9092

9193
-y, --yes bool
9294
Bypass prompts.

‎coderd/coderdtest/coderdtest.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1143,7 +1143,7 @@ func MustWorkspace(t testing.TB, client *codersdk.Client, workspaceID uuid.UUID)
11431143

11441144
// RequestExternalAuthCallback makes a request with the proper OAuth2 state cookie
11451145
// to the external auth callback endpoint.
1146-
funcRequestExternalAuthCallback(t testing.TB,providerIDstring,client*codersdk.Client)*http.Response {
1146+
funcRequestExternalAuthCallback(t testing.TB,providerIDstring,client*codersdk.Client,opts...func(*http.Request))*http.Response {
11471147
client.HTTPClient.CheckRedirect=func(req*http.Request,via []*http.Request)error {
11481148
returnhttp.ErrUseLastResponse
11491149
}
@@ -1160,6 +1160,9 @@ func RequestExternalAuthCallback(t testing.TB, providerID string, client *coders
11601160
Name:codersdk.SessionTokenCookie,
11611161
Value:client.SessionToken(),
11621162
})
1163+
for_,opt:=rangeopts {
1164+
opt(req)
1165+
}
11631166
res,err:=client.HTTPClient.Do(req)
11641167
require.NoError(t,err)
11651168
t.Cleanup(func() {

‎coderd/coderdtest/oidctest/idp.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,6 @@ func (f *FakeIDP) AttemptLogin(t testing.TB, client *codersdk.Client, idTokenCla
479479
// This is a niche case, but it is needed for testing ConvertLoginType.
480480
func (f*FakeIDP)LoginWithClient(t testing.TB,client*codersdk.Client,idTokenClaims jwt.MapClaims,opts...func(r*http.Request)) (*codersdk.Client,*http.Response) {
481481
t.Helper()
482-
483482
path:="/api/v2/users/oidc/callback"
484483
iff.callbackPath!="" {
485484
path=f.callbackPath
@@ -489,13 +488,23 @@ func (f *FakeIDP) LoginWithClient(t testing.TB, client *codersdk.Client, idToken
489488
f.SetRedirect(t,coderOauthURL.String())
490489

491490
cli:=f.HTTPClient(client.HTTPClient)
492-
cli.CheckRedirect=func(req*http.Request,via []*http.Request)error {
491+
redirectFn:=cli.CheckRedirect
492+
checkRedirect:=func(req*http.Request,via []*http.Request)error {
493493
// Store the idTokenClaims to the specific state request. This ties
494494
// the claims 1:1 with a given authentication flow.
495-
state:=req.URL.Query().Get("state")
496-
f.stateToIDTokenClaims.Store(state,idTokenClaims)
495+
ifstate:=req.URL.Query().Get("state");state!="" {
496+
f.stateToIDTokenClaims.Store(state,idTokenClaims)
497+
returnnil
498+
}
499+
// This is mainly intended to prevent the _last_ redirect
500+
// The one involving the state param is a core part of the
501+
// OIDC flow and shouldn't be redirected.
502+
ifredirectFn!=nil {
503+
returnredirectFn(req,via)
504+
}
497505
returnnil
498506
}
507+
cli.CheckRedirect=checkRedirect
499508

500509
req,err:=http.NewRequestWithContext(context.Background(),"GET",coderOauthURL.String(),nil)
501510
require.NoError(t,err)

‎coderd/database/queries.sql.go

Lines changed: 10 additions & 7 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/queries/notifications.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
-- name: FetchNewMessageMetadata :one
22
-- This is used to build up the notification_message's JSON payload.
33
SELECTnt.nameAS notification_name,
4+
nt.idAS notification_template_id,
45
nt.actionsAS actions,
56
nt.methodAS custom_method,
67
u.idAS user_id,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp