Skip to content

Commit b650b0c

Browse files
committed
Merge branch 'main' into lilac/dynamic-parameters-endpoint
2 parents 666f07e + 109e73b commit b650b0c

File tree

75 files changed

+1405
-266
lines changed

Some content is hidden

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

75 files changed

+1405
-266
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1182,6 +1182,7 @@ jobs:
11821182
11831183
- name: SBOM Generation and Attestation
11841184
if: github.ref == 'refs/heads/main'
1185+
continue-on-error: true
11851186
env:
11861187
COSIGN_EXPERIMENTAL: 1
11871188
run: |
@@ -1200,7 +1201,7 @@ jobs:
12001201
syft "${IMAGE}" -o spdx-json > "${SBOM_FILE}"
12011202
12021203
echo "Attesting SBOM to image: ${IMAGE}"
1203-
cosign clean "${IMAGE}"
1204+
cosign clean --force=true "${IMAGE}"
12041205
cosign attest --type spdxjson \
12051206
--predicate "${SBOM_FILE}" \
12061207
--yes \

.github/workflows/release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ jobs:
509509
510510
# Attest SBOM to multi-arch image
511511
echo "Attesting SBOM to multi-arch image: ${{ steps.build_docker.outputs.multiarch_image }}"
512-
cosign clean "${{ steps.build_docker.outputs.multiarch_image }}"
512+
cosign clean --force=true "${{ steps.build_docker.outputs.multiarch_image }}"
513513
cosign attest --type spdxjson \
514514
--predicate coder_${{ steps.version.outputs.version }}_sbom.spdx.json \
515515
--yes \
@@ -522,7 +522,7 @@ jobs:
522522
syft "${latest_tag}" -o spdx-json > coder_latest_sbom.spdx.json
523523
524524
echo "Attesting SBOM to latest image: ${latest_tag}"
525-
cosign clean "${latest_tag}"
525+
cosign clean --force=true "${latest_tag}"
526526
cosign attest --type spdxjson \
527527
--predicate coder_latest_sbom.spdx.json \
528528
--yes \

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,8 @@ GEN_FILES := \
581581
$(TAILNETTEST_MOCKS) \
582582
coderd/database/pubsub/psmock/psmock.go \
583583
agent/agentcontainers/acmock/acmock.go \
584-
agent/agentcontainers/dcspec/dcspec_gen.go
584+
agent/agentcontainers/dcspec/dcspec_gen.go \
585+
coderd/httpmw/loggermock/loggermock.go
585586

586587
# all gen targets should be added here and to gen/mark-fresh
587588
gen: gen/db gen/golden-files $(GEN_FILES)
@@ -630,6 +631,7 @@ gen/mark-fresh:
630631
coderd/database/pubsub/psmock/psmock.go \
631632
agent/agentcontainers/acmock/acmock.go \
632633
agent/agentcontainers/dcspec/dcspec_gen.go \
634+
coderd/httpmw/loggermock/loggermock.go \
633635
"
634636

635637
for file in $$files; do
@@ -669,6 +671,10 @@ agent/agentcontainers/acmock/acmock.go: agent/agentcontainers/containers.go
669671
go generate ./agent/agentcontainers/acmock/
670672
touch "$@"
671673

674+
coderd/httpmw/loggermock/loggermock.go: coderd/httpmw/logger.go
675+
go generate ./coderd/httpmw/loggermock/
676+
touch "$@"
677+
672678
agent/agentcontainers/dcspec/dcspec_gen.go: \
673679
node_modules/.installed \
674680
agent/agentcontainers/dcspec/devContainer.base.schema.json \

agent/agent_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ func TestAgent_Stats_Magic(t *testing.T) {
190190
s, ok := <-stats
191191
t.Logf("got stats: ok=%t, ConnectionCount=%d, RxBytes=%d, TxBytes=%d, SessionCountVSCode=%d, ConnectionMedianLatencyMS=%f",
192192
ok, s.ConnectionCount, s.RxBytes, s.TxBytes, s.SessionCountVscode, s.ConnectionMedianLatencyMs)
193-
return ok && s.ConnectionCount > 0 && s.RxBytes > 0 && s.TxBytes > 0 &&
193+
return ok &&
194194
// Ensure that the connection didn't count as a "normal" SSH session.
195195
// This was a special one, so it should be labeled specially in the stats!
196196
s.SessionCountVscode == 1 &&
@@ -258,8 +258,7 @@ func TestAgent_Stats_Magic(t *testing.T) {
258258
s, ok := <-stats
259259
t.Logf("got stats with conn open: ok=%t, ConnectionCount=%d, SessionCountJetBrains=%d",
260260
ok, s.ConnectionCount, s.SessionCountJetbrains)
261-
return ok && s.ConnectionCount > 0 &&
262-
s.SessionCountJetbrains == 1
261+
return ok && s.SessionCountJetbrains == 1
263262
}, testutil.WaitLong, testutil.IntervalFast,
264263
"never saw stats with conn open",
265264
)

agent/agentscripts/agentscripts_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,16 @@ func TestEnv(t *testing.T) {
102102

103103
func TestTimeout(t *testing.T) {
104104
t.Parallel()
105+
if runtime.GOOS == "darwin" {
106+
t.Skip("this test is flaky on macOS, see https://github.com/coder/internal/issues/329")
107+
}
105108
runner := setup(t, nil)
106109
defer runner.Close()
107110
aAPI := agenttest.NewFakeAgentAPI(t, testutil.Logger(t), nil, nil)
108111
err := runner.Init([]codersdk.WorkspaceAgentScript{{
109112
LogSourceID: uuid.New(),
110113
Script: "sleep infinity",
111-
Timeout: time.Millisecond,
114+
Timeout: 100 * time.Millisecond,
112115
}}, aAPI.ScriptCompleted)
113116
require.NoError(t, err)
114117
require.ErrorIs(t, runner.Execute(context.Background(), agentscripts.ExecuteAllScripts), agentscripts.ErrTimeout)

cli/agent.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"fmt"
66
"io"
7+
"net"
78
"net/http"
89
"net/http/pprof"
910
"net/url"
@@ -491,8 +492,6 @@ func (r *RootCmd) workspaceAgent() *serpent.Command {
491492
}
492493

493494
func ServeHandler(ctx context.Context, logger slog.Logger, handler http.Handler, addr, name string) (closeFunc func()) {
494-
logger.Debug(ctx, "http server listening", slog.F("addr", addr), slog.F("name", name))
495-
496495
// ReadHeaderTimeout is purposefully not enabled. It caused some issues with
497496
// websockets over the dev tunnel.
498497
// See: https://github.com/coder/coder/pull/3730
@@ -502,9 +501,15 @@ func ServeHandler(ctx context.Context, logger slog.Logger, handler http.Handler,
502501
Handler: handler,
503502
}
504503
go func() {
505-
err := srv.ListenAndServe()
506-
if err != nil && !xerrors.Is(err, http.ErrServerClosed) {
507-
logger.Error(ctx, "http server listen", slog.F("name", name), slog.Error(err))
504+
ln, err := net.Listen("tcp", addr)
505+
if err != nil {
506+
logger.Error(ctx, "http server listen", slog.F("name", name), slog.F("addr", addr), slog.Error(err))
507+
return
508+
}
509+
defer ln.Close()
510+
logger.Info(ctx, "http server listening", slog.F("addr", ln.Addr()), slog.F("name", name))
511+
if err := srv.Serve(ln); err != nil && !xerrors.Is(err, http.ErrServerClosed) {
512+
logger.Error(ctx, "http server serve", slog.F("addr", ln.Addr()), slog.F("name", name), slog.Error(err))
508513
}
509514
}()
510515

cli/configssh.go

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,15 @@ func (r *RootCmd) configSSH() *serpent.Command {
356356
if sshConfigOpts.disableAutostart {
357357
flags += " --disable-autostart=true"
358358
}
359+
if coderdConfig.HostnamePrefix != "" {
360+
flags += " --ssh-host-prefix " + coderdConfig.HostnamePrefix
361+
}
362+
if coderdConfig.HostnameSuffix != "" {
363+
flags += " --hostname-suffix " + coderdConfig.HostnameSuffix
364+
}
359365
defaultOptions = append(defaultOptions, fmt.Sprintf(
360-
"ProxyCommand %s %s ssh --stdio%s --ssh-host-prefix %s %%h",
361-
escapedCoderBinary, rootFlags, flags, coderdConfig.HostnamePrefix,
366+
"ProxyCommand %s %s ssh --stdio%s %%h",
367+
escapedCoderBinary, rootFlags, flags,
362368
))
363369
}
364370

@@ -391,7 +397,7 @@ func (r *RootCmd) configSSH() *serpent.Command {
391397
}
392398

393399
hostBlock := []string{
394-
"Host " + coderdConfig.HostnamePrefix + "*",
400+
sshConfigHostLinePatterns(coderdConfig),
395401
}
396402
// Prefix with '\t'
397403
for _, v := range configOptions.sshOptions {
@@ -837,3 +843,19 @@ func diffBytes(name string, b1, b2 []byte, color bool) ([]byte, error) {
837843
}
838844
return b, nil
839845
}
846+
847+
func sshConfigHostLinePatterns(config codersdk.SSHConfigResponse) string {
848+
builder := strings.Builder{}
849+
// by inspection, WriteString always returns nil error
850+
_, _ = builder.WriteString("Host")
851+
if config.HostnamePrefix != "" {
852+
_, _ = builder.WriteString(" ")
853+
_, _ = builder.WriteString(config.HostnamePrefix)
854+
_, _ = builder.WriteString("*")
855+
}
856+
if config.HostnameSuffix != "" {
857+
_, _ = builder.WriteString(" *.")
858+
_, _ = builder.WriteString(config.HostnameSuffix)
859+
}
860+
return builder.String()
861+
}

cli/configssh_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,33 @@ func TestConfigSSH_FileWriteAndOptionsFlow(t *testing.T) {
611611
regexMatch: "RemoteForward 2222 192.168.11.1:2222.*\n.*RemoteForward 2223 192.168.11.1:2223",
612612
},
613613
},
614+
{
615+
name: "Hostname Suffix",
616+
args: []string{
617+
"--yes",
618+
"--hostname-suffix", "testy",
619+
},
620+
wantErr: false,
621+
hasAgent: true,
622+
wantConfig: wantConfig{
623+
ssh: []string{"Host coder.* *.testy"},
624+
regexMatch: `ProxyCommand .* ssh .* --hostname-suffix testy %h`,
625+
},
626+
},
627+
{
628+
name: "Hostname Prefix and Suffix",
629+
args: []string{
630+
"--yes",
631+
"--ssh-host-prefix", "presto.",
632+
"--hostname-suffix", "testy",
633+
},
634+
wantErr: false,
635+
hasAgent: true,
636+
wantConfig: wantConfig{
637+
ssh: []string{"Host presto.* *.testy"},
638+
regexMatch: `ProxyCommand .* ssh .* --ssh-host-prefix presto\. --hostname-suffix testy %h`,
639+
},
640+
},
614641
}
615642
for _, tt := range tests {
616643
tt := tt

cli/server.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,6 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
641641
GoogleTokenValidator: googleTokenValidator,
642642
ExternalAuthConfigs: externalAuthConfigs,
643643
RealIPConfig: realIPConfig,
644-
SecureAuthCookie: vals.SecureAuthCookie.Value(),
645644
SSHKeygenAlgorithm: sshKeygenAlgorithm,
646645
TracerProvider: tracerProvider,
647646
Telemetry: telemetry.NewNoop(),

0 commit comments

Comments
 (0)