Skip to content

Commit f640283

Browse files
committed
Merge branch 'main' into gitprovider
2 parents 3dc1f00 + 3c40698 commit f640283

Some content is hidden

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

50 files changed

+498
-159
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Once installed, you can start a production deployment<sup>1</sup> with a single
6060
# Automatically sets up an external access URL on *.try.coder.app
6161
coder server
6262

63-
# Requires a PostgreSQL instance and external access URL
63+
# Requires a PostgreSQL instance (version 13 or higher) and external access URL
6464
coder server --postgres-url <url> --access-url <url>
6565
```
6666

@@ -95,7 +95,7 @@ Join our community on [Discord](https://coder.com/chat?utm_source=github.com/cod
9595

9696
## Contributing
9797

98-
If you're using Coder in your organization, please try to add your company name to the [ADOPTERS.md](./ADOPTERS.md). It really helps the project to gain momentum and credibility. It's a small contribution back to the project with a big impact.
98+
If you're using Coder in your organization, please try to add your company name to the [ADOPTERS.md](./ADOPTERS.md). It really helps the project to gain momentum and credibility. It's a small contribution back to the project with a big impact.
9999

100100
Read the [contributing docs](https://coder.com/docs/coder-oss/latest/CONTRIBUTING).
101101

cli/deployment/flags.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func Flags() *codersdk.DeploymentFlags {
8888
DerpServerRelayAddress: &codersdk.StringFlag{
8989
Name: "DERP Server Relay Address",
9090
Flag: "derp-server-relay-address",
91-
EnvVar: "CODER_DERP_SERVER_RELAY_ADDRESS",
91+
EnvVar: "CODER_DERP_SERVER_RELAY_URL",
9292
Description: "An HTTP address that is accessible by other replicas to relay DERP traffic. Required for high availability.",
9393
Enterprise: true,
9494
},

cli/root.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,8 @@ func (h *headerTransport) RoundTrip(req *http.Request) (*http.Response, error) {
609609

610610
// ExperimentalEnabled returns if the experimental feature flag is enabled.
611611
func ExperimentalEnabled(cmd *cobra.Command) bool {
612-
return cliflag.IsSetBool(cmd, varExperimental)
612+
enabled, _ := cmd.Flags().GetBool(varExperimental)
613+
return enabled
613614
}
614615

615616
// EnsureExperimental will ensure that the experimental feature flag is set if the given flag is set.

cli/server.go

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333
"github.com/spf13/afero"
3434
"github.com/spf13/cobra"
3535
"go.opentelemetry.io/otel/trace"
36+
"golang.org/x/mod/semver"
3637
"golang.org/x/oauth2"
3738
xgithub "golang.org/x/oauth2/github"
3839
"golang.org/x/sync/errgroup"
@@ -389,6 +390,23 @@ func Server(dflags *codersdk.DeploymentFlags, newAPI func(context.Context, *code
389390
return xerrors.Errorf("dial postgres: %w", err)
390391
}
391392
defer sqlDB.Close()
393+
// Ensure the PostgreSQL version is >=13.0.0!
394+
version, err := sqlDB.QueryContext(ctx, "SHOW server_version;")
395+
if err != nil {
396+
return xerrors.Errorf("get postgres version: %w", err)
397+
}
398+
if !version.Next() {
399+
return xerrors.Errorf("no rows returned for version select")
400+
}
401+
var versionStr string
402+
err = version.Scan(&versionStr)
403+
if err != nil {
404+
return xerrors.Errorf("scan version: %w", err)
405+
}
406+
versionStr = strings.Split(versionStr, " ")[0]
407+
if semver.Compare("v"+versionStr, "v13") < 0 {
408+
return xerrors.New("PostgreSQL version must be v13.0.0 or higher!")
409+
}
392410

393411
err = sqlDB.Ping()
394412
if err != nil {
@@ -476,14 +494,13 @@ func Server(dflags *codersdk.DeploymentFlags, newAPI func(context.Context, *code
476494
), dflags.PromAddress.Value, "prometheus")()
477495
}
478496

479-
// We use a separate closer so the Enterprise API
497+
// We use a separate coderAPICloser so the Enterprise API
480498
// can have it's own close functions. This is cleaner
481499
// than abstracting the Coder API itself.
482-
coderAPI, closer, err := newAPI(ctx, options)
500+
coderAPI, coderAPICloser, err := newAPI(ctx, options)
483501
if err != nil {
484502
return err
485503
}
486-
defer closer.Close()
487504

488505
client := codersdk.New(localURL)
489506
if dflags.TLSEnable.Value {
@@ -663,7 +680,7 @@ func Server(dflags *codersdk.DeploymentFlags, newAPI func(context.Context, *code
663680
wg.Wait()
664681

665682
cmd.Println("Waiting for WebSocket connections to close...")
666-
_ = coderAPI.Close()
683+
_ = coderAPICloser.Close()
667684
cmd.Println("Done waiting for WebSocket connections")
668685

669686
// Close tunnel after we no longer have in-flight connections.

cli/server_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ func TestServer(t *testing.T) {
6060
"--postgres-url", connectionURL,
6161
"--cache-dir", t.TempDir(),
6262
)
63+
pty := ptytest.New(t)
64+
root.SetOutput(pty.Output())
65+
root.SetErr(pty.Output())
6366
errC := make(chan error, 1)
6467
go func() {
6568
errC <- root.ExecuteContext(ctx)

coder.service

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ AmbientCapabilities=CAP_IPC_LOCK CAP_NET_BIND_SERVICE
2020
CacheDirectory=coder
2121
CapabilityBoundingSet=CAP_SYSLOG CAP_IPC_LOCK CAP_NET_BIND_SERVICE
2222
KillSignal=SIGINT
23+
KillMode=mixed
2324
NoNewPrivileges=yes
2425
ExecStart=/usr/bin/coder server
2526
Restart=on-failure
2627
RestartSec=5
27-
TimeoutStopSec=30
28+
TimeoutStopSec=90
2829

2930
[Install]
3031
WantedBy=multi-user.target

coderd/coderdtest/coderdtest.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ type Options struct {
7272
AppHostname string
7373
AWSCertificates awsidentity.Certificates
7474
Authorizer rbac.Authorizer
75+
Experimental bool
7576
AzureCertificates x509.VerifyOptions
7677
GithubOAuth2Config *coderd.GithubOAuth2Config
7778
OIDCConfig *coderd.OIDCConfig
@@ -229,6 +230,7 @@ func NewOptions(t *testing.T, options *Options) (func(http.Handler), context.Can
229230
CacheDir: t.TempDir(),
230231
Database: options.Database,
231232
Pubsub: options.Pubsub,
233+
Experimental: options.Experimental,
232234

233235
Auditor: options.Auditor,
234236
AWSCertificates: options.AWSCertificates,

coderd/database/databasefake/databasefake.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2784,6 +2784,7 @@ func (q *fakeQuerier) UpdateGroupByID(_ context.Context, arg database.UpdateGrou
27842784
for i, group := range q.groups {
27852785
if group.ID == arg.ID {
27862786
group.Name = arg.Name
2787+
group.AvatarURL = arg.AvatarURL
27872788
q.groups[i] = group
27882789
return group, nil
27892790
}
@@ -3135,6 +3136,7 @@ func (q *fakeQuerier) InsertGroup(_ context.Context, arg database.InsertGroupPar
31353136
ID: arg.ID,
31363137
Name: arg.Name,
31373138
OrganizationID: arg.OrganizationID,
3139+
AvatarURL: arg.AvatarURL,
31383140
}
31393141

31403142
q.groups = append(q.groups, group)

coderd/database/dump.sql

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

coderd/database/migrations/000059_file_id.up.sql

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ BEGIN;
1414
-- Drop the primary key on hash.
1515
ALTER TABLE files DROP CONSTRAINT files_pkey;
1616

17-
-- This extension is required by gen_random_uuid
18-
CREATE EXTENSION IF NOT EXISTS pgcrypto;
19-
2017
-- Add an 'id' column and designate it the primary key.
2118
ALTER TABLE files ADD COLUMN
2219
id uuid NOT NULL PRIMARY KEY DEFAULT gen_random_uuid ();
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
BEGIN;
2+
3+
ALTER TABLE groups DROP COLUMN avatar_url;
4+
5+
COMMIT;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
BEGIN;
2+
3+
ALTER TABLE groups ADD COLUMN avatar_url text NOT NULL DEFAULT '';
4+
5+
COMMIT;

coderd/database/models.go

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

coderd/database/queries.sql.go

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

0 commit comments

Comments
 (0)