Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(enterprise/coderd): make primary workspace proxy always be updated now#11499

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
johnstcn merged 1 commit intomainfromcj/healthcheck-wsproxy-zero-time
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
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: 5 additions & 1 deletionenterprise/coderd/workspaceproxy.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -930,6 +930,7 @@ func convertRegion(proxy database.WorkspaceProxy, status proxyhealth.ProxyStatus
}

func convertProxy(p database.WorkspaceProxy, status proxyhealth.ProxyStatus) codersdk.WorkspaceProxy {
now := dbtime.Now()
if p.IsPrimary() {
// Primary is always healthy since the primary serves the api that this
// is returned from.
Expand All@@ -939,8 +940,11 @@ func convertProxy(p database.WorkspaceProxy, status proxyhealth.ProxyStatus) cod
ProxyHost: u.Host,
Status: proxyhealth.Healthy,
Report: codersdk.ProxyHealthReport{},
CheckedAt:time.Now(),
CheckedAt:now,
}
// For primary, created at / updated at are always 'now'
p.CreatedAt = now
p.UpdatedAt = now
}
if status.Status == "" {
status.Status = proxyhealth.Unknown
Expand Down
18 changes: 17 additions & 1 deletionenterprise/coderd/workspaceproxy_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,6 +19,7 @@ import (
"github.com/coder/coder/v2/coderd/coderdtest"
"github.com/coder/coder/v2/coderd/database"
"github.com/coder/coder/v2/coderd/database/dbtestutil"
"github.com/coder/coder/v2/coderd/database/dbtime"
"github.com/coder/coder/v2/coderd/workspaceapps"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/enterprise/coderd/coderdenttest"
Expand DownExpand Up@@ -93,11 +94,16 @@ func TestRegions(t *testing.T) {
deploymentID, err := db.GetDeploymentID(ctx)
require.NoError(t, err, "get deployment ID")

// The default proxy is always called "primary".
primary, err := client.WorkspaceProxyByName(ctx, "primary")
require.NoError(t, err)

const proxyName = "hello"
_ = coderdenttest.NewWorkspaceProxy(t, api, client, &coderdenttest.ProxyOptions{
Name: proxyName,
AppHostname: appHostname + ".proxy",
})
approxCreateTime := dbtime.Now()
proxy, err := db.GetWorkspaceProxyByName(ctx, proxyName)
require.NoError(t, err)

Expand DownExpand Up@@ -135,7 +141,7 @@ func TestRegions(t *testing.T) {
require.NoError(t, err)
require.Len(t, regions, 2)

// Region 0 is the primaryrequire.Len(t, regions, 1)
// Region 0 is the primary
require.NotEqual(t, uuid.Nil, regions[0].ID)
require.Equal(t, regions[0].ID.String(), deploymentID)
require.Equal(t, "primary", regions[0].Name)
Expand All@@ -145,6 +151,11 @@ func TestRegions(t *testing.T) {
require.Equal(t, client.URL.String(), regions[0].PathAppURL)
require.Equal(t, appHostname, regions[0].WildcardHostname)

// Ensure non-zero fields of the default proxy
require.NotZero(t, primary.Name)
require.NotZero(t, primary.CreatedAt)
require.NotZero(t, primary.UpdatedAt)

// Region 1 is the proxy.
require.NotEqual(t, uuid.Nil, regions[1].ID)
require.Equal(t, proxy.ID, regions[1].ID)
Expand All@@ -154,6 +165,11 @@ func TestRegions(t *testing.T) {
require.True(t, regions[1].Healthy)
require.Equal(t, proxy.Url, regions[1].PathAppURL)
require.Equal(t, proxy.WildcardHostname, regions[1].WildcardHostname)

// Unfortunately need to wait to assert createdAt/updatedAt
<-time.After(testutil.WaitShort / 10)
require.WithinDuration(t, approxCreateTime, proxy.CreatedAt, testutil.WaitShort/10)
require.WithinDuration(t, approxCreateTime, proxy.UpdatedAt, testutil.WaitShort/10)
})

t.Run("RequireAuth", func(t *testing.T) {
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp