Skip to content

Commit 1f56d58

Browse files
committed
Merge remote-tracking branch 'origin/main' into 277-idp-sync-dash
2 parents b6cab0b + 3897ea4 commit 1f56d58

File tree

107 files changed

+1437
-1282
lines changed

Some content is hidden

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

107 files changed

+1437
-1282
lines changed

agent/agent_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@ func TestAgent_FileTransferBlocked(t *testing.T) {
977977
isErr := strings.Contains(errorMessage, agentssh.BlockedFileTransferErrorMessage) ||
978978
strings.Contains(errorMessage, "EOF") ||
979979
strings.Contains(errorMessage, "Process exited with status 65")
980-
require.True(t, isErr, fmt.Sprintf("Message: "+errorMessage))
980+
require.True(t, isErr, "Message: "+errorMessage)
981981
}
982982

983983
t.Run("SFTP", func(t *testing.T) {
@@ -1962,7 +1962,7 @@ func TestAgent_UpdatedDERP(t *testing.T) {
19621962
// Push a new DERP map to the agent.
19631963
err := client.PushDERPMapUpdate(newDerpMap)
19641964
require.NoError(t, err)
1965-
t.Logf("pushed DERPMap update to agent")
1965+
t.Log("pushed DERPMap update to agent")
19661966

19671967
require.Eventually(t, func() bool {
19681968
conn := uut.TailnetConn()
@@ -1974,7 +1974,7 @@ func TestAgent_UpdatedDERP(t *testing.T) {
19741974
t.Logf("agent Conn DERPMap with regionIDs %v, PreferredDERP %d", regionIDs, preferredDERP)
19751975
return len(regionIDs) == 1 && regionIDs[0] == 2 && preferredDERP == 2
19761976
}, testutil.WaitLong, testutil.IntervalFast)
1977-
t.Logf("agent got the new DERPMap")
1977+
t.Log("agent got the new DERPMap")
19781978

19791979
// Connect from a second client and make sure it uses the new DERP map.
19801980
conn2 := newClientConn(newDerpMap, "client2")

agent/agentscripts/agentscripts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ func (r *Runner) run(ctx context.Context, script codersdk.WorkspaceAgentScript,
290290
cmd = cmdPty.AsExec()
291291
cmd.SysProcAttr = cmdSysProcAttr()
292292
cmd.WaitDelay = 10 * time.Second
293-
cmd.Cancel = cmdCancel(cmd)
293+
cmd.Cancel = cmdCancel(ctx, logger, cmd)
294294

295295
// Expose env vars that can be used in the script for storing data
296296
// and binaries. In the future, we may want to expose more env vars

agent/agentscripts/agentscripts_other.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
package agentscripts
44

55
import (
6+
"context"
67
"os/exec"
78
"syscall"
9+
10+
"cdr.dev/slog"
811
)
912

1013
func cmdSysProcAttr() *syscall.SysProcAttr {
@@ -13,8 +16,9 @@ func cmdSysProcAttr() *syscall.SysProcAttr {
1316
}
1417
}
1518

16-
func cmdCancel(cmd *exec.Cmd) func() error {
19+
func cmdCancel(ctx context.Context, logger slog.Logger, cmd *exec.Cmd) func() error {
1720
return func() error {
21+
logger.Debug(ctx, "cmdCancel: sending SIGHUP to process and children", slog.F("pid", cmd.Process.Pid))
1822
return syscall.Kill(-cmd.Process.Pid, syscall.SIGHUP)
1923
}
2024
}
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
package agentscripts
22

33
import (
4+
"context"
45
"os"
56
"os/exec"
67
"syscall"
8+
9+
"cdr.dev/slog"
710
)
811

912
func cmdSysProcAttr() *syscall.SysProcAttr {
1013
return &syscall.SysProcAttr{}
1114
}
1215

13-
func cmdCancel(cmd *exec.Cmd) func() error {
16+
func cmdCancel(ctx context.Context, logger slog.Logger, cmd *exec.Cmd) func() error {
1417
return func() error {
18+
logger.Debug(ctx, "cmdCancel: sending interrupt to process", slog.F("pid", cmd.Process.Pid))
1519
return cmd.Process.Signal(os.Interrupt)
1620
}
1721
}

cli/clilog/clilog_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ func assertLogs(t testing.TB, path string, expected ...string) {
181181

182182
logs := strings.Split(strings.TrimSpace(string(data)), "\n")
183183
if !assert.Len(t, logs, len(expected)) {
184-
t.Logf(string(data))
184+
t.Log(string(data))
185185
t.FailNow()
186186
}
187187
for i, log := range logs {
@@ -202,7 +202,7 @@ func assertLogsJSON(t testing.TB, path string, levelExpected ...string) {
202202

203203
logs := strings.Split(strings.TrimSpace(string(data)), "\n")
204204
if !assert.Len(t, logs, len(levelExpected)/2) {
205-
t.Logf(string(data))
205+
t.Log(string(data))
206206
t.FailNow()
207207
}
208208
for i, log := range logs {

cli/gitssh.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func (r *RootCmd) gitssh() *serpent.Command {
9191
if xerrors.As(err, &exitErr) && exitErr.ExitCode() == 255 {
9292
_, _ = fmt.Fprintln(inv.Stderr,
9393
"\n"+pretty.Sprintf(
94-
cliui.DefaultStyles.Wrap,
94+
cliui.DefaultStyles.Wrap, "%s",
9595
"Coder authenticates with "+pretty.Sprint(cliui.DefaultStyles.Field, "git")+
9696
" using the public key below. All clones with SSH are authenticated automatically 🪄.")+"\n",
9797
)

cli/login.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ func (r *RootCmd) login() *serpent.Command {
209209

210210
// nolint: nestif
211211
if !hasFirstUser {
212-
_, _ = fmt.Fprintf(inv.Stdout, Caret+"Your Coder deployment hasn't been set up!\n")
212+
_, _ = fmt.Fprint(inv.Stdout, Caret+"Your Coder deployment hasn't been set up!\n")
213213

214214
if username == "" {
215215
if !isTTYIn(inv) {

cli/logout.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (r *RootCmd) logout() *serpent.Command {
6868
errorString := strings.TrimRight(errorStringBuilder.String(), "\n")
6969
return xerrors.New("Failed to log out.\n" + errorString)
7070
}
71-
_, _ = fmt.Fprintf(inv.Stdout, Caret+"You are no longer logged in. You can log in using 'coder login <url>'.\n")
71+
_, _ = fmt.Fprint(inv.Stdout, Caret+"You are no longer logged in. You can log in using 'coder login <url>'.\n")
7272
return nil
7373
},
7474
}

cli/publickey.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ func (r *RootCmd) publickey() *serpent.Command {
4545
return xerrors.Errorf("create codersdk client: %w", err)
4646
}
4747

48-
cliui.Infof(inv.Stdout,
48+
cliui.Info(inv.Stdout,
4949
"This is your public key for using "+pretty.Sprint(cliui.DefaultStyles.Field, "git")+" in "+
5050
"Coder. All clones with SSH will be authenticated automatically 🪄.",
5151
)
52-
cliui.Infof(inv.Stdout, pretty.Sprint(cliui.DefaultStyles.Code, strings.TrimSpace(key.PublicKey))+"\n")
53-
cliui.Infof(inv.Stdout, "Add to GitHub and GitLab:")
54-
cliui.Infof(inv.Stdout, "> https://github.com/settings/ssh/new")
55-
cliui.Infof(inv.Stdout, "> https://gitlab.com/-/profile/keys")
52+
cliui.Info(inv.Stdout, pretty.Sprint(cliui.DefaultStyles.Code, strings.TrimSpace(key.PublicKey))+"\n")
53+
cliui.Info(inv.Stdout, "Add to GitHub and GitLab:")
54+
cliui.Info(inv.Stdout, "> https://github.com/settings/ssh/new")
55+
cliui.Info(inv.Stdout, "> https://gitlab.com/-/profile/keys")
5656

5757
return nil
5858
},

cli/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
513513
}
514514

515515
accessURL := vals.AccessURL.String()
516-
cliui.Infof(inv.Stdout, lipgloss.NewStyle().
516+
cliui.Info(inv.Stdout, lipgloss.NewStyle().
517517
Border(lipgloss.DoubleBorder()).
518518
Align(lipgloss.Center).
519519
Padding(0, 3).

cli/templateversionarchive.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func (r *RootCmd) setArchiveTemplateVersion(archive bool) *serpent.Command {
7676
for _, version := range versions {
7777
if version.Archived == archive {
7878
_, _ = fmt.Fprintln(
79-
inv.Stdout, fmt.Sprintf("Version "+pretty.Sprint(cliui.DefaultStyles.Keyword, version.Name)+" already "+pastVerb),
79+
inv.Stdout, "Version "+pretty.Sprint(cliui.DefaultStyles.Keyword, version.Name)+" already "+pastVerb,
8080
)
8181
continue
8282
}
@@ -87,7 +87,7 @@ func (r *RootCmd) setArchiveTemplateVersion(archive bool) *serpent.Command {
8787
}
8888

8989
_, _ = fmt.Fprintln(
90-
inv.Stdout, fmt.Sprintf("Version "+pretty.Sprint(cliui.DefaultStyles.Keyword, version.Name)+" "+pastVerb+" at "+cliui.Timestamp(time.Now())),
90+
inv.Stdout, "Version "+pretty.Sprint(cliui.DefaultStyles.Keyword, version.Name)+" "+pastVerb+" at "+cliui.Timestamp(time.Now()),
9191
)
9292
}
9393
return nil

cli/vpndaemon_windows.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ func (r *RootCmd) vpnDaemonRun() *serpent.Command {
4141
},
4242
Handler: func(inv *serpent.Invocation) error {
4343
ctx := inv.Context()
44-
logger := inv.Logger.AppendSinks(sloghuman.Sink(inv.Stderr)).Leveled(slog.LevelDebug)
44+
sinks := []slog.Sink{
45+
sloghuman.Sink(inv.Stderr),
46+
}
47+
logger := inv.Logger.AppendSinks(sinks...).Leveled(slog.LevelDebug)
4548

4649
if rpcReadHandleInt < 0 || rpcWriteHandleInt < 0 {
4750
return xerrors.Errorf("rpc-read-handle (%v) and rpc-write-handle (%v) must be positive", rpcReadHandleInt, rpcWriteHandleInt)
@@ -60,7 +63,11 @@ func (r *RootCmd) vpnDaemonRun() *serpent.Command {
6063
defer pipe.Close()
6164

6265
logger.Info(ctx, "starting tunnel")
63-
tunnel, err := vpn.NewTunnel(ctx, logger, pipe, vpn.NewClient())
66+
tunnel, err := vpn.NewTunnel(ctx, logger, pipe, vpn.NewClient(),
67+
vpn.UseOSNetworkingStack(),
68+
vpn.UseAsLogger(),
69+
vpn.UseCustomLogSinks(sinks...),
70+
)
6471
if err != nil {
6572
return xerrors.Errorf("create new tunnel for client: %w", err)
6673
}

coderd/database/dbpurge/dbpurge_test.go

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

6767
defer func() {
6868
if t.Failed() {
69-
t.Logf("Test failed, printing rows...")
69+
t.Log("Test failed, printing rows...")
7070
ctx := testutil.Context(t, testutil.WaitShort)
7171
buf := &bytes.Buffer{}
7272
enc := json.NewEncoder(buf)

coderd/database/migrations/migrate_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,9 @@ func TestMigrateUpWithFixtures(t *testing.T) {
283283
}
284284
}
285285
if len(emptyTables) > 0 {
286-
t.Logf("The following tables have zero rows, consider adding fixtures for them or create a full database dump:")
286+
t.Log("The following tables have zero rows, consider adding fixtures for them or create a full database dump:")
287287
t.Errorf("tables have zero rows: %v", emptyTables)
288-
t.Logf("See https://github.com/coder/coder/blob/main/docs/CONTRIBUTING.md#database-fixtures-for-testing-migrations for more information")
288+
t.Log("See https://github.com/coder/coder/blob/main/docs/CONTRIBUTING.md#database-fixtures-for-testing-migrations for more information")
289289
}
290290
})
291291

coderd/database/pubsub/pubsub_linux_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,9 @@ func TestMeasureLatency(t *testing.T) {
305305
require.NoError(t, err)
306306
db, err := sql.Open("postgres", connectionURL)
307307
require.NoError(t, err)
308+
t.Cleanup(func() {
309+
_ = db.Close()
310+
})
308311
ps, err := pubsub.New(ctx, logger, db, connectionURL)
309312
require.NoError(t, err)
310313

coderd/database/pubsub/pubsub_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ func TestPGPubsubDriver(t *testing.T) {
137137
// use a separate subber and pubber so we can keep track of listener connections
138138
db, err := sql.Open("postgres", connectionURL)
139139
require.NoError(t, err)
140+
defer db.Close()
140141
pubber, err := pubsub.New(ctx, logger, db, connectionURL)
141142
require.NoError(t, err)
142143
defer pubber.Close()
@@ -147,6 +148,7 @@ func TestPGPubsubDriver(t *testing.T) {
147148
tconn, err := subDriver.Connector(connectionURL)
148149
require.NoError(t, err)
149150
tcdb := sql.OpenDB(tconn)
151+
defer tcdb.Close()
150152
subber, err := pubsub.New(ctx, logger, tcdb, connectionURL)
151153
require.NoError(t, err)
152154
defer subber.Close()

coderd/healthcheck/workspaceproxy.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ func (r *WorkspaceProxyReport) Run(ctx context.Context, opts *WorkspaceProxyRepo
100100
for _, err := range errs {
101101
switch r.Severity {
102102
case health.SeverityWarning, health.SeverityOK:
103-
r.Warnings = append(r.Warnings, health.Messagef(health.CodeProxyUnhealthy, err))
103+
r.Warnings = append(r.Warnings, health.Messagef(health.CodeProxyUnhealthy, "%s", err))
104104
case health.SeverityError:
105-
r.appendError(*health.Errorf(health.CodeProxyUnhealthy, err))
105+
r.appendError(*health.Errorf(health.CodeProxyUnhealthy, "%s", err))
106106
}
107107
}
108108
}

coderd/httpapi/httpapi_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,15 @@ func TestWebsocketCloseMsg(t *testing.T) {
143143
t.Parallel()
144144

145145
msg := strings.Repeat("d", 255)
146-
trunc := httpapi.WebsocketCloseSprintf(msg)
146+
trunc := httpapi.WebsocketCloseSprintf("%s", msg)
147147
assert.Equal(t, len(trunc), 123)
148148
})
149149

150150
t.Run("TruncateMultiByteCharacters", func(t *testing.T) {
151151
t.Parallel()
152152

153153
msg := strings.Repeat("こんにちは", 10)
154-
trunc := httpapi.WebsocketCloseSprintf(msg)
154+
trunc := httpapi.WebsocketCloseSprintf("%s", msg)
155155
assert.Equal(t, len(trunc), 123)
156156
})
157157
}

coderd/idpsync/organization.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ func (s AGPLIDPSync) UpdateOrganizationSettings(ctx context.Context, db database
4545
}
4646

4747
func (s AGPLIDPSync) OrganizationSyncSettings(ctx context.Context, db database.Store) (*OrganizationSyncSettings, error) {
48+
// If this logic is ever updated, make sure to update the corresponding
49+
// checkIDPOrgSync in coderd/telemetry/telemetry.go.
4850
rlv := s.Manager.Resolver(db)
4951
orgSettings, err := s.SyncSettings.Organization.Resolve(ctx, rlv)
5052
if err != nil {

coderd/notifications/notifications_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ func TestBackpressure(t *testing.T) {
388388
}, testutil.WaitShort, testutil.IntervalFast)
389389
}
390390
}
391-
t.Logf("done advancing")
391+
t.Log("done advancing")
392392
// The batch completes
393393
w.MustWait(ctx)
394394

coderd/provisionerdserver/acquirer_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,8 +547,8 @@ func TestAcquirer_MatchTags(t *testing.T) {
547547
s := fmt.Sprintf("| %s | %s | %s | %s |", kvs(tt.acquireJobTags), kvs(tt.provisionerJobTags), sameOrg, acquire)
548548
lines = append(lines, s)
549549
}
550-
t.Logf("You can paste this into docs/admin/provisioners.md")
551-
t.Logf(strings.Join(lines, "\n"))
550+
t.Log("You can paste this into docs/admin/provisioners.md")
551+
t.Log(strings.Join(lines, "\n"))
552552
})
553553
}
554554

coderd/provisionerdserver/provisionerdserver_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func TestHeartbeat(t *testing.T) {
101101
ctx := testutil.Context(t, testutil.WaitShort)
102102
heartbeatChan := make(chan struct{})
103103
heartbeatFn := func(hbCtx context.Context) error {
104-
t.Logf("heartbeat")
104+
t.Log("heartbeat")
105105
select {
106106
case <-hbCtx.Done():
107107
return hbCtx.Err()

0 commit comments

Comments
 (0)