Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1c8b44f

Browse files
committed
Merge branch 'main' into 3522-autogenerate-docs-2
2 parents 14a659e + d170d27 commit 1c8b44f

39 files changed

+406
-363
lines changed

.github/workflows/coder.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ jobs:
338338
else
339339
echo ::set-output name=cover::false
340340
fi
341-
gotestsum --junitfile="gotests.xml" --jsonfile="gotestsum.json" --packages="./..." --debug -- -parallel=8 -timeout=3m -short -failfast $COVERAGE_FLAGS
341+
gotestsum --junitfile="gotests.xml" --jsonfile="gotestsum.json" --packages="./..." --debug -- -parallel=8 -timeout=5m -short -failfast $COVERAGE_FLAGS
342342
ret=$?
343343
if ((ret)); then
344344
# Eternalize test timeout logs because "re-run failed" erases

agent/agent.go

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,25 @@ func (a *agent) run(ctx context.Context) error {
226226
_ = network.Close()
227227
return xerrors.New("agent is closed")
228228
}
229+
230+
// Report statistics from the created network.
231+
cl, err := a.client.AgentReportStats(ctx, a.logger, func() *codersdk.AgentStats {
232+
stats := network.ExtractTrafficStats()
233+
return convertAgentStats(stats)
234+
})
235+
if err != nil {
236+
a.logger.Error(ctx, "report stats", slog.Error(err))
237+
} else {
238+
if err = a.trackConnGoroutine(func() {
239+
// This is OK because the agent never re-creates the tailnet
240+
// and the only shutdown indicator is agent.Close().
241+
<-a.closed
242+
_ = cl.Close()
243+
}); err != nil {
244+
a.logger.Debug(ctx, "report stats goroutine", slog.Error(err))
245+
_ = cl.Close()
246+
}
247+
}
229248
} else {
230249
// Update the DERP map!
231250
network.SetDERPMap(metadata.DERPMap)
@@ -561,28 +580,6 @@ func (a *agent) init(ctx context.Context) {
561580
}
562581

563582
go a.runLoop(ctx)
564-
cl, err := a.client.AgentReportStats(ctx, a.logger, func() *codersdk.AgentStats {
565-
stats := map[netlogtype.Connection]netlogtype.Counts{}
566-
a.closeMutex.Lock()
567-
if a.network != nil {
568-
stats = a.network.ExtractTrafficStats()
569-
}
570-
a.closeMutex.Unlock()
571-
return convertAgentStats(stats)
572-
})
573-
if err != nil {
574-
a.logger.Error(ctx, "report stats", slog.Error(err))
575-
return
576-
}
577-
578-
if err = a.trackConnGoroutine(func() {
579-
<-a.closed
580-
_ = cl.Close()
581-
}); err != nil {
582-
a.logger.Error(ctx, "report stats goroutine", slog.Error(err))
583-
_ = cl.Close()
584-
return
585-
}
586583
}
587584

588585
func convertAgentStats(counts map[netlogtype.Connection]netlogtype.Counts) *codersdk.AgentStats {

agent/apphealth.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ func NewWorkspaceAppHealthReporter(logger slog.Logger, apps []codersdk.Workspace
3434
hasHealthchecksEnabled := false
3535
health := make(map[uuid.UUID]codersdk.WorkspaceAppHealth, 0)
3636
for _, app := range apps {
37-
health[app.ID] = app.Health
38-
if !hasHealthchecksEnabled && app.Health != codersdk.WorkspaceAppHealthDisabled {
39-
hasHealthchecksEnabled = true
37+
if app.Health == codersdk.WorkspaceAppHealthDisabled {
38+
continue
4039
}
40+
health[app.ID] = app.Health
41+
hasHealthchecksEnabled = true
4142
}
4243

4344
// no need to run this loop if no health checks are configured.
@@ -77,7 +78,7 @@ func NewWorkspaceAppHealthReporter(logger slog.Logger, apps []codersdk.Workspace
7778
return err
7879
}
7980
// successful healthcheck is a non-5XX status code
80-
res.Body.Close()
81+
_ = res.Body.Close()
8182
if res.StatusCode >= http.StatusInternalServerError {
8283
return xerrors.Errorf("error status code: %d", res.StatusCode)
8384
}

cli/root.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"net/http"
99
"net/url"
1010
"os"
11+
"runtime"
1112
"strings"
1213
"text/template"
1314
"time"
@@ -583,12 +584,17 @@ func checkVersions(cmd *cobra.Command, client *codersdk.Client) error {
583584
}
584585

585586
fmtWarningText := `version mismatch: client %s, server %s
586-
download the server version with: 'curl -L https://coder.com/install.sh | sh -s -- --version %s'
587587
`
588+
// Our installation script doesn't work on Windows, so instead we direct the user
589+
// to the GitHub release page to download the latest installer.
590+
if runtime.GOOS == "windows" {
591+
fmtWarningText += `download the server version from: https://github.com/coder/coder/releases/v%s`
592+
} else {
593+
fmtWarningText += `download the server version with: 'curl -L https://coder.com/install.sh | sh -s -- --version %s'`
594+
}
588595

589596
if !buildinfo.VersionsMatch(clientVersion, info.Version) {
590597
warn := cliui.Styles.Warn.Copy().Align(lipgloss.Left)
591-
// Trim the leading 'v', our install.sh script does not handle this case well.
592598
_, _ = fmt.Fprintf(cmd.ErrOrStderr(), warn.Render(fmtWarningText), clientVersion, info.Version, strings.TrimPrefix(info.CanonicalVersion(), "v"))
593599
_, _ = fmt.Fprintln(cmd.ErrOrStderr())
594600
}

coderd/database/databasefake/databasefake.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2193,19 +2193,6 @@ func (q *fakeQuerier) GetWorkspaceResourceMetadataCreatedAfter(ctx context.Conte
21932193
return metadata, nil
21942194
}
21952195

2196-
func (q *fakeQuerier) GetWorkspaceResourceMetadataByResourceID(_ context.Context, id uuid.UUID) ([]database.WorkspaceResourceMetadatum, error) {
2197-
q.mutex.RLock()
2198-
defer q.mutex.RUnlock()
2199-
2200-
metadata := make([]database.WorkspaceResourceMetadatum, 0)
2201-
for _, metadatum := range q.workspaceResourceMetadata {
2202-
if metadatum.WorkspaceResourceID == id {
2203-
metadata = append(metadata, metadatum)
2204-
}
2205-
}
2206-
return metadata, nil
2207-
}
2208-
22092196
func (q *fakeQuerier) GetWorkspaceResourceMetadataByResourceIDs(_ context.Context, ids []uuid.UUID) ([]database.WorkspaceResourceMetadatum, error) {
22102197
q.mutex.RLock()
22112198
defer q.mutex.RUnlock()
@@ -2549,19 +2536,31 @@ func (q *fakeQuerier) InsertWorkspaceResource(_ context.Context, arg database.In
25492536
return resource, nil
25502537
}
25512538

2552-
func (q *fakeQuerier) InsertWorkspaceResourceMetadata(_ context.Context, arg database.InsertWorkspaceResourceMetadataParams) (database.WorkspaceResourceMetadatum, error) {
2539+
func (q *fakeQuerier) InsertWorkspaceResourceMetadata(_ context.Context, arg database.InsertWorkspaceResourceMetadataParams) ([]database.WorkspaceResourceMetadatum, error) {
25532540
q.mutex.Lock()
25542541
defer q.mutex.Unlock()
25552542

2556-
//nolint:gosimple
2557-
metadatum := database.WorkspaceResourceMetadatum{
2558-
WorkspaceResourceID: arg.WorkspaceResourceID,
2559-
Key: arg.Key,
2560-
Value: arg.Value,
2561-
Sensitive: arg.Sensitive,
2543+
metadata := make([]database.WorkspaceResourceMetadatum, 0)
2544+
id := int64(1)
2545+
if len(q.workspaceResourceMetadata) > 0 {
2546+
id = q.workspaceResourceMetadata[len(q.workspaceResourceMetadata)-1].ID
25622547
}
2563-
q.workspaceResourceMetadata = append(q.workspaceResourceMetadata, metadatum)
2564-
return metadatum, nil
2548+
for index, key := range arg.Key {
2549+
id++
2550+
value := arg.Value[index]
2551+
metadata = append(metadata, database.WorkspaceResourceMetadatum{
2552+
ID: id,
2553+
WorkspaceResourceID: arg.WorkspaceResourceID,
2554+
Key: key,
2555+
Value: sql.NullString{
2556+
String: value,
2557+
Valid: value != "",
2558+
},
2559+
Sensitive: arg.Sensitive[index],
2560+
})
2561+
}
2562+
q.workspaceResourceMetadata = append(q.workspaceResourceMetadata, metadata...)
2563+
return metadata, nil
25652564
}
25662565

25672566
func (q *fakeQuerier) InsertUser(_ context.Context, arg database.InsertUserParams) (database.User, error) {
@@ -2743,6 +2742,7 @@ func (q *fakeQuerier) InsertWorkspaceApp(_ context.Context, arg database.InsertW
27432742
Icon: arg.Icon,
27442743
Command: arg.Command,
27452744
Url: arg.Url,
2745+
External: arg.External,
27462746
Subdomain: arg.Subdomain,
27472747
SharingLevel: arg.SharingLevel,
27482748
HealthcheckUrl: arg.HealthcheckUrl,

coderd/database/dump.sql

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

coderd/database/migrations/000086_no_org_admins.down.sql

Whitespace-only changes.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
UPDATE
2+
organization_members
3+
SET
4+
roles = ARRAY [] :: text[]
5+
WHERE
6+
'organization-admin:'||organization_id = ANY(roles);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ALTER TABLE workspace_resource_metadata DROP COLUMN id;
2+
ALTER TABLE workspace_resource_metadata DROP CONSTRAINT workspace_resource_metadata_name;
3+
ALTER TABLE workspace_resource_metadata ADD CONSTRAINT workspace_resource_metadata_pkey PRIMARY KEY (workspace_resource_id, key);
4+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ALTER TABLE workspace_resource_metadata DROP CONSTRAINT workspace_resource_metadata_pkey;
2+
3+
ALTER TABLE workspace_resource_metadata ADD COLUMN id BIGSERIAL PRIMARY KEY;
4+
5+
ALTER TABLE workspace_resource_metadata ADD CONSTRAINT workspace_resource_metadata_name UNIQUE(workspace_resource_id, key);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE workspace_apps DROP COLUMN external;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE workspace_apps ADD COLUMN external boolean NOT NULL DEFAULT false;

coderd/database/models.go

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

coderd/database/querier.go

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)