Skip to content

merge main into groups #4439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 47 commits into from
Oct 10, 2022
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
a6bb3b2
docs: add quotas (#4366)
ammario Oct 4, 2022
f295200
fix: Ensure WebSockets routinely transfer data (#4367)
kylecarbs Oct 4, 2022
06d7e36
fix: Ignore hidden folders when archiving (#4370)
kylecarbs Oct 4, 2022
5870176
feat: Also log out of apps if they are hosted on the same domain (#4334)
Emyrk Oct 4, 2022
8940ea1
fix: Always set `DisconnectedAt` if the agent isn't connected (#4328)
kylecarbs Oct 5, 2022
504cd46
fix: Check for a response body when dialing the Tailnet WebSocket (#4…
kylecarbs Oct 5, 2022
3759bb2
docs: fixed a typo (#4374)
matifali Oct 5, 2022
8d14076
fix: move quotas above inputs (#4376)
f0ssel Oct 5, 2022
b65c555
fix: warn user if not entitled feature is enabled (#4377)
f0ssel Oct 5, 2022
4f3958c
docs: link all enterprise features (#4368)
ammario Oct 5, 2022
2a66395
feat: use app wildcards for apps if configured (#4263)
deansheather Oct 5, 2022
9a670b9
chore: refactor frontend to use workspace status directly (#4361)
presleyp Oct 5, 2022
3ad5e11
feat: add warning if workspace page becomes stale (#4375)
Kira-Pilot Oct 5, 2022
bbe2baf
fix: Ignore all hidden files and folders in archive (#4382)
kylecarbs Oct 6, 2022
1386465
feat: add endpoint to get listening ports in agent (#4260)
deansheather Oct 6, 2022
93b8121
fix: Change use of 1337 to 13337 in example templates (#4386)
mafredri Oct 6, 2022
29a2fe4
fix: fix builds on windows_arm64 (#4388)
deansheather Oct 6, 2022
d275331
fix: Remove audit warning if unlicensed (#4387)
kylecarbs Oct 6, 2022
0ebcb7d
fix: Remove reliance of `relative_path` on subdomains (#4390)
kylecarbs Oct 6, 2022
ea42212
chore: add icons to quickstarts (#4379)
bpmct Oct 6, 2022
9b1ff43
fix: Don't run CI for releases (#4393)
kylecarbs Oct 6, 2022
3b15f13
fix: fix apps being unavailable until rebuild (#4395)
deansheather Oct 6, 2022
9cf3e10
chore: Pin typos to fix CI (#4396)
kylecarbs Oct 6, 2022
fe7c9f8
chore: Stop building images on tag pushes (#4397)
kylecarbs Oct 6, 2022
f5df548
feat: tokens (#4380)
f0ssel Oct 6, 2022
a89d690
fix: show help on wraper commands (#4402)
f0ssel Oct 6, 2022
32bb1e7
fix: add back missing postAPIKey route (#4406)
f0ssel Oct 6, 2022
05670d1
fix: Spelling in audit log docs (#4384)
ntimo Oct 6, 2022
915bb41
feat: Add trial property to licenses (#4372)
kylecarbs Oct 7, 2022
3049a56
fix: Use the maximum number of users for a license warning (#4410)
kylecarbs Oct 7, 2022
3cc77d9
feat: Add tunnel by default (#4399)
kylecarbs Oct 7, 2022
e8e095e
feat: redesign error alert (#4403)
Kira-Pilot Oct 7, 2022
adcf883
fix: Ensure GitHub OAuth2 users are active in organization (#4416)
mafredri Oct 7, 2022
2b6586d
chore: add ignoreRestSiblings to no-unused-vars ESLint rule (#4404)
jsjoeio Oct 7, 2022
257df81
chore: replace old ErrorSummary component (#4417)
Kira-Pilot Oct 7, 2022
34f7992
refactor: Remove user roles from dropdown (#4419)
BrunoQuaresma Oct 7, 2022
50966c4
fix: Fix keyboard focus styles on buttons (#4418)
BrunoQuaresma Oct 7, 2022
3ad27b5
chore: Rename context in `cli/agent` (#4422)
mafredri Oct 7, 2022
0ad8e77
fix(ci): use correct `retention-days` in e2e (#4424)
coadler Oct 7, 2022
c01910f
docs: use enterprise badges (#4428)
ammario Oct 8, 2022
dd5173b
fix: apply loadBalancerIP and externalTrafficPolicy values in helm ch…
andrei-nefeli Oct 8, 2022
eefc26c
Hide build logs older than 30 days (#4436)
ammario Oct 9, 2022
6266895
Merge branch 'main' into mergemain
sreya Oct 9, 2022
99868f2
remove migration conflict
sreya Oct 9, 2022
c46eba4
fix license woes
sreya Oct 9, 2022
33a5599
fix coderd/license
sreya Oct 9, 2022
20a89eb
Update error banner
BrunoQuaresma Oct 10, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/workflows/coder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ on:
push:
branches:
- main
tags:
- "*"

pull_request:

Expand Down Expand Up @@ -36,7 +34,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v2
- name: typos-action
uses: crate-ci/typos@master
uses: crate-ci/typos@v1.12.8
with:
config: .github/workflows/typos.toml
- name: Fix Helper
Expand Down Expand Up @@ -630,7 +628,7 @@ jobs:
with:
name: failed-test-videos
path: ./site/test-results/**/*.webm
retention:days: 7
retention-days: 7

chromatic:
# REMARK: this is only used to build storybook and deploy it to Chromatic.
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/dogfood.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ on:
push:
branches:
- main
tags:
- "*"
paths:
- "dogfood/**"
pull_request:
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"cliflag",
"cliui",
"codecov",
"Codespaces",
"coderd",
"coderdenttest",
"coderdtest",
"codersdk",
"cronstrue",
Expand All @@ -24,6 +24,7 @@
"drpcmux",
"drpcserver",
"Dsts",
"enablements",
"fatih",
"Formik",
"gitsshkey",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Once installed, you can start a production deployment<sup>1</sup> with a single

```sh
# Automatically sets up an external access URL on *.try.coder.app
coder server --tunnel
coder server

# Requires a PostgreSQL instance and external access URL
coder server --postgres-url <url> --access-url <url>
Expand Down
28 changes: 28 additions & 0 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"fmt"
"io"
"net"
"net/http"
"net/netip"
"os"
"os/exec"
Expand Down Expand Up @@ -206,6 +207,7 @@ func (a *agent) runTailnet(ctx context.Context, derpMap *tailcfg.DERPMap) {
go a.sshServer.HandleConn(a.stats.wrapConn(conn))
}
}()

reconnectingPTYListener, err := a.network.Listen("tcp", ":"+strconv.Itoa(codersdk.TailnetReconnectingPTYPort))
if err != nil {
a.logger.Critical(ctx, "listen for reconnecting pty", slog.Error(err))
Expand Down Expand Up @@ -240,6 +242,7 @@ func (a *agent) runTailnet(ctx context.Context, derpMap *tailcfg.DERPMap) {
go a.handleReconnectingPTY(ctx, msg, conn)
}
}()

speedtestListener, err := a.network.Listen("tcp", ":"+strconv.Itoa(codersdk.TailnetSpeedtestPort))
if err != nil {
a.logger.Critical(ctx, "listen for speedtest", slog.Error(err))
Expand All @@ -261,6 +264,31 @@ func (a *agent) runTailnet(ctx context.Context, derpMap *tailcfg.DERPMap) {
}()
}
}()

statisticsListener, err := a.network.Listen("tcp", ":"+strconv.Itoa(codersdk.TailnetStatisticsPort))
if err != nil {
a.logger.Critical(ctx, "listen for statistics", slog.Error(err))
return
}
go func() {
defer statisticsListener.Close()
server := &http.Server{
Handler: a.statisticsHandler(),
ReadTimeout: 20 * time.Second,
ReadHeaderTimeout: 20 * time.Second,
WriteTimeout: 20 * time.Second,
ErrorLog: slog.Stdlib(ctx, a.logger.Named("statistics_http_server"), slog.LevelInfo),
}
go func() {
<-ctx.Done()
_ = server.Close()
}()

err = server.Serve(statisticsListener)
if err != nil && !xerrors.Is(err, http.ErrServerClosed) && !strings.Contains(err.Error(), "use of closed network connection") {
a.logger.Critical(ctx, "serve statistics HTTP server", slog.Error(err))
}
}()
}

// runCoordinator listens for nodes and updates the self-node as it changes.
Expand Down
64 changes: 64 additions & 0 deletions agent/ports_supported.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//go:build linux || (windows && amd64)

package agent

import (
"time"

"github.com/cakturk/go-netstat/netstat"
"golang.org/x/xerrors"

"github.com/coder/coder/codersdk"
)

func (lp *listeningPortsHandler) getListeningPorts() ([]codersdk.ListeningPort, error) {
lp.mut.Lock()
defer lp.mut.Unlock()

if time.Since(lp.mtime) < time.Second {
// copy
ports := make([]codersdk.ListeningPort, len(lp.ports))
copy(ports, lp.ports)
return ports, nil
}

tabs, err := netstat.TCPSocks(func(s *netstat.SockTabEntry) bool {
return s.State == netstat.Listen
})
if err != nil {
return nil, xerrors.Errorf("scan listening ports: %w", err)
}

seen := make(map[uint16]struct{}, len(tabs))
ports := []codersdk.ListeningPort{}
for _, tab := range tabs {
if tab.LocalAddr == nil || tab.LocalAddr.Port < uint16(codersdk.MinimumListeningPort) {
continue
}

// Don't include ports that we've already seen. This can happen on
// Windows, and maybe on Linux if you're using a shared listener socket.
if _, ok := seen[tab.LocalAddr.Port]; ok {
continue
}
seen[tab.LocalAddr.Port] = struct{}{}

procName := ""
if tab.Process != nil {
procName = tab.Process.Name
}
ports = append(ports, codersdk.ListeningPort{
ProcessName: procName,
Network: codersdk.ListeningPortNetworkTCP,
Port: tab.LocalAddr.Port,
})
}

lp.ports = ports
lp.mtime = time.Now()

// copy
ports = make([]codersdk.ListeningPort, len(lp.ports))
copy(ports, lp.ports)
return ports, nil
}
12 changes: 12 additions & 0 deletions agent/ports_unsupported.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//go:build !linux && !(windows && amd64)

package agent

import "github.com/coder/coder/codersdk"

func (lp *listeningPortsHandler) getListeningPorts() ([]codersdk.ListeningPort, error) {
// Can't scan for ports on non-linux or non-windows_amd64 systems at the
// moment. The UI will not show any "no ports found" message to the user, so
// the user won't suspect a thing.
return []codersdk.ListeningPort{}, nil
}
49 changes: 49 additions & 0 deletions agent/statsendpoint.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package agent

import (
"net/http"
"sync"
"time"

"github.com/go-chi/chi"

"github.com/coder/coder/coderd/httpapi"
"github.com/coder/coder/codersdk"
)

func (*agent) statisticsHandler() http.Handler {
r := chi.NewRouter()
r.Get("/", func(rw http.ResponseWriter, r *http.Request) {
httpapi.Write(r.Context(), rw, http.StatusOK, codersdk.Response{
Message: "Hello from the agent!",
})
})

lp := &listeningPortsHandler{}
r.Get("/api/v0/listening-ports", lp.handler)

return r
}

type listeningPortsHandler struct {
mut sync.Mutex
ports []codersdk.ListeningPort
mtime time.Time
}

// handler returns a list of listening ports. This is tested by coderd's
// TestWorkspaceAgentListeningPorts test.
func (lp *listeningPortsHandler) handler(rw http.ResponseWriter, r *http.Request) {
ports, err := lp.getListeningPorts()
if err != nil {
httpapi.Write(r.Context(), rw, http.StatusInternalServerError, codersdk.Response{
Message: "Could not scan for listening ports.",
Detail: err.Error(),
})
return
}

httpapi.Write(r.Context(), rw, http.StatusOK, codersdk.ListeningPortsResponse{
Ports: ports,
})
}
12 changes: 6 additions & 6 deletions cli/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,15 @@ func workspaceAgent() *cobra.Command {
}
}

ctx, cancelFunc := context.WithTimeout(cmd.Context(), time.Hour)
defer cancelFunc()
for retry.New(100*time.Millisecond, 5*time.Second).Wait(ctx) {
err := client.PostWorkspaceAgentVersion(cmd.Context(), version)
retryCtx, cancelRetry := context.WithTimeout(cmd.Context(), time.Hour)
defer cancelRetry()
for retrier := retry.New(100*time.Millisecond, 5*time.Second); retrier.Wait(retryCtx); {
err := client.PostWorkspaceAgentVersion(retryCtx, version)
if err != nil {
logger.Warn(cmd.Context(), "post agent version: %w", slog.Error(err), slog.F("version", version))
logger.Warn(retryCtx, "post agent version: %w", slog.Error(err), slog.F("version", version))
continue
}
logger.Info(ctx, "updated agent version", slog.F("version", version))
logger.Info(retryCtx, "updated agent version", slog.F("version", version))
break
}

Expand Down
8 changes: 6 additions & 2 deletions cli/cliui/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,14 @@ func DisplayTable(out any, sort string, filterColumns []string) (string, error)
// Special type formatting.
switch val := v.(type) {
case time.Time:
v = val.Format(time.Stamp)
v = val.Format(time.RFC3339)
case *time.Time:
if val != nil {
v = val.Format(time.Stamp)
v = val.Format(time.RFC3339)
}
case *int64:
if val != nil {
v = *val
}
case fmt.Stringer:
if val != nil {
Expand Down
22 changes: 11 additions & 11 deletions cli/cliui/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ func Test_DisplayTable(t *testing.T) {
t.Parallel()

expected := `
NAME AGE ROLES SUB 1 NAME SUB 1 AGE SUB 2 NAME SUB 2 AGE SUB 3 INNER NAME SUB 3 INNER AGE SUB 4 TIME TIME PTR
foo 10 [a b c] foo1 11 foo2 12 foo3 13 {foo4 14 } Aug 2 15:49:10 Aug 2 15:49:10
bar 20 [a] bar1 21 <nil> <nil> bar3 23 {bar4 24 } Aug 2 15:49:10 <nil>
baz 30 [] baz1 31 <nil> <nil> baz3 33 {baz4 34 } Aug 2 15:49:10 <nil>
NAME AGE ROLES SUB 1 NAME SUB 1 AGE SUB 2 NAME SUB 2 AGE SUB 3 INNER NAME SUB 3 INNER AGE SUB 4 TIME TIME PTR
foo 10 [a b c] foo1 11 foo2 12 foo3 13 {foo4 14 } 2022-08-02T15:49:10Z 2022-08-02T15:49:10Z
bar 20 [a] bar1 21 <nil> <nil> bar3 23 {bar4 24 } 2022-08-02T15:49:10Z <nil>
baz 30 [] baz1 31 <nil> <nil> baz3 33 {baz4 34 } 2022-08-02T15:49:10Z <nil>
`

// Test with non-pointer values.
Expand All @@ -158,10 +158,10 @@ baz 30 [] baz1 31 <nil> <nil> baz3
t.Parallel()

expected := `
NAME AGE ROLES SUB 1 NAME SUB 1 AGE SUB 2 NAME SUB 2 AGE SUB 3 INNER NAME SUB 3 INNER AGE SUB 4 TIME TIME PTR
bar 20 [a] bar1 21 <nil> <nil> bar3 23 {bar4 24 } Aug 2 15:49:10 <nil>
baz 30 [] baz1 31 <nil> <nil> baz3 33 {baz4 34 } Aug 2 15:49:10 <nil>
foo 10 [a b c] foo1 11 foo2 12 foo3 13 {foo4 14 } Aug 2 15:49:10 Aug 2 15:49:10
NAME AGE ROLES SUB 1 NAME SUB 1 AGE SUB 2 NAME SUB 2 AGE SUB 3 INNER NAME SUB 3 INNER AGE SUB 4 TIME TIME PTR
bar 20 [a] bar1 21 <nil> <nil> bar3 23 {bar4 24 } 2022-08-02T15:49:10Z <nil>
baz 30 [] baz1 31 <nil> <nil> baz3 33 {baz4 34 } 2022-08-02T15:49:10Z <nil>
foo 10 [a b c] foo1 11 foo2 12 foo3 13 {foo4 14 } 2022-08-02T15:49:10Z 2022-08-02T15:49:10Z
`

out, err := cliui.DisplayTable(in, "name", nil)
Expand All @@ -175,9 +175,9 @@ foo 10 [a b c] foo1 11 foo2 12 foo3

expected := `
NAME SUB 1 NAME SUB 3 INNER NAME TIME
foo foo1 foo3 Aug 2 15:49:10
bar bar1 bar3 Aug 2 15:49:10
baz baz1 baz3 Aug 2 15:49:10
foo foo1 foo3 2022-08-02T15:49:10Z
bar bar1 bar3 2022-08-02T15:49:10Z
baz baz1 baz3 2022-08-02T15:49:10Z
`

out, err := cliui.DisplayTable(in, "", []string{"name", "sub_1_name", "sub_3 inner name", "time"})
Expand Down
3 changes: 3 additions & 0 deletions cli/parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ func parameters() *cobra.Command {
// constructing curl requests.
Hidden: true,
Aliases: []string{"params"},
RunE: func(cmd *cobra.Command, args []string) error {
return cmd.Help()
},
}
cmd.AddCommand(
parameterList(),
Expand Down
1 change: 1 addition & 0 deletions cli/resetpassword_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func TestResetPassword(t *testing.T) {
serverCmd, cfg := clitest.New(t,
"server",
"--address", ":0",
"--access-url", "example.com",
"--postgres-url", connectionURL,
"--cache-dir", t.TempDir(),
)
Expand Down
1 change: 1 addition & 0 deletions cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func Core() []*cobra.Command {
users(),
versionCmd(),
workspaceAgent(),
tokens(),
}
}

Expand Down
3 changes: 3 additions & 0 deletions cli/schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ func schedules() *cobra.Command {
Annotations: workspaceCommand,
Use: "schedule { show | start | stop | override } <workspace>",
Short: "Schedule automated start and stop times for workspaces",
RunE: func(cmd *cobra.Command, args []string) error {
return cmd.Help()
},
}

scheduleCmd.AddCommand(
Expand Down
Loading