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

feat(coderd): add matched provisioner daemons information to more places#15688

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 16 commits intomainfromcj/more-matching-provisioners
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
16 commits
Select commitHold shift + click to select a range
ba944ab
feat(coderd/wsbuilder): return provisioners available at time of insert
johnstcnNov 29, 2024
4e51f20
feat(coderd): add matched provisioner daemons information to addition…
johnstcnNov 29, 2024
47036e8
fix linter complaint re nil ptr deref
johnstcnDec 1, 2024
16be03b
add test coverage for matched provisioners with workspace build creation
johnstcnDec 1, 2024
4304a06
skip for non-postgres
johnstcnDec 1, 2024
9ef68dd
add tests for workspace creation
johnstcnDec 1, 2024
38788d5
revert fe changes in this pr
johnstcnDec 1, 2024
1c95ffe
coderd/wsbuilder: use dbauthz.AsSystemReadProvisionerDaemons instead …
johnstcnDec 1, 2024
98521be
refactor: extract WarnMatchedProvisioners to cliutil
johnstcnDec 1, 2024
e1423f5
fixup! refactor: extract WarnMatchedProvisioners to cliutil
johnstcnDec 1, 2024
517a505
feat(cli): add provisioner warning to create/start/stop commands
johnstcnDec 1, 2024
c4295ef
Apply suggestions from code review
johnstcnDec 2, 2024
c5fb83b
feat(coderd): add endpoint for matched provisioners of template versi…
johnstcnDec 2, 2024
3bd62fd
feat(cli): delete: warn on no matched provisioners
johnstcnDec 2, 2024
2f625bc
address linter complaint
johnstcnDec 2, 2024
848338e
add test for cli/delete
johnstcnDec 2, 2024
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
PrevPrevious commit
NextNext commit
add tests for workspace creation
  • Loading branch information
@johnstcn
johnstcn committedDec 1, 2024
commit9ef68dd61b222875cc4c4d4091cb2fa63e8d36b5
16 changes: 10 additions & 6 deletionscoderd/workspacebuilds_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1218,6 +1218,7 @@ func TestPostWorkspaceBuild(t *testing.T) {
Pubsub: ps,
IncludeProvisionerDaemon: true,
})
defer closeDaemon.Close()
// Given: a user, template, and workspace
user := coderdtest.CreateFirstUser(t, client)
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil)
Expand All@@ -1244,9 +1245,10 @@ func TestPostWorkspaceBuild(t *testing.T) {
require.Equal(t, codersdk.ProvisionerJobPending, build.Job.Status)
// Then: the response should indicate no provisioners are available.
if assert.NotNil(t, build.MatchedProvisioners) {
require.Zero(t, build.MatchedProvisioners.Count)
require.Zero(t, build.MatchedProvisioners.Available)
require.Zero(t, build.MatchedProvisioners.MostRecentlySeen.Time)
assert.Zero(t, build.MatchedProvisioners.Count)
assert.Zero(t, build.MatchedProvisioners.Available)
assert.Zero(t, build.MatchedProvisioners.MostRecentlySeen.Time)
assert.False(t, build.MatchedProvisioners.MostRecentlySeen.Valid)
}
})

Expand All@@ -1262,6 +1264,7 @@ func TestPostWorkspaceBuild(t *testing.T) {
Pubsub: ps,
IncludeProvisionerDaemon: true,
})
defer closeDaemon.Close()
// Given: a user, template, and workspace
user := coderdtest.CreateFirstUser(t, client)
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil)
Expand DownExpand Up@@ -1292,9 +1295,10 @@ func TestPostWorkspaceBuild(t *testing.T) {
require.Equal(t, codersdk.ProvisionerJobPending, build.Job.Status)
// Then: the response should indicate no provisioners are available
if assert.NotNil(t, build.MatchedProvisioners) {
require.Zero(t, build.MatchedProvisioners.Available)
require.Equal(t, 1, build.MatchedProvisioners.Count)
require.Equal(t, newLastSeenAt.UTC(), build.MatchedProvisioners.MostRecentlySeen.Time.UTC())
assert.Zero(t, build.MatchedProvisioners.Available)
assert.Equal(t, 1, build.MatchedProvisioners.Count)
assert.Equal(t, newLastSeenAt.UTC(), build.MatchedProvisioners.MostRecentlySeen.Time.UTC())
assert.True(t, build.MatchedProvisioners.MostRecentlySeen.Valid)
}
})
}
Expand Down
88 changes: 88 additions & 0 deletionscoderd/workspaces_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -766,6 +766,94 @@ func TestPostWorkspacesByOrganization(t *testing.T) {
require.NoError(t, err)
require.EqualValues(t, exp, *ws.TTLMillis)
})

t.Run("NoProvisionersAvailable", func(t *testing.T) {
t.Parallel()
if !dbtestutil.WillUsePostgres() {
t.Skip("this test requires postgres")
}
// Given: a coderd instance with a provisioner daemon
store, ps, db := dbtestutil.NewDBWithSQLDB(t)
client, closeDaemon := coderdtest.NewWithProvisionerCloser(t, &coderdtest.Options{
Database: store,
Pubsub: ps,
IncludeProvisionerDaemon: true,
})
defer closeDaemon.Close()

// Given: a user, template, and workspace
user := coderdtest.CreateFirstUser(t, client)
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil)
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)

// Given: all the provisioner daemons disappear
ctx := testutil.Context(t, testutil.WaitLong)
_, err := db.ExecContext(ctx, `DELETE FROM provisioner_daemons;`)
require.NoError(t, err)

// When: a new workspace is created
ws, err := client.CreateUserWorkspace(ctx, codersdk.Me, codersdk.CreateWorkspaceRequest{
TemplateID: template.ID,
Name: "testing",
})
// Then: the request succeeds
require.NoError(t, err)
// Then: the workspace build is pending
require.Equal(t, codersdk.ProvisionerJobPending, ws.LatestBuild.Job.Status)
// Then: the workspace build has no matched provisioners
if assert.NotNil(t, ws.LatestBuild.MatchedProvisioners) {
assert.Zero(t, ws.LatestBuild.MatchedProvisioners.Count)
assert.Zero(t, ws.LatestBuild.MatchedProvisioners.Available)
assert.Zero(t, ws.LatestBuild.MatchedProvisioners.MostRecentlySeen.Time)
assert.False(t, ws.LatestBuild.MatchedProvisioners.MostRecentlySeen.Valid)
}
})

t.Run("AllProvisionersStale", func(t *testing.T) {
t.Parallel()
if !dbtestutil.WillUsePostgres() {
t.Skip("this test requires postgres")
}

// Given: a coderd instance with a provisioner daemon
store, ps, db := dbtestutil.NewDBWithSQLDB(t)
client, closeDaemon := coderdtest.NewWithProvisionerCloser(t, &coderdtest.Options{
Database: store,
Pubsub: ps,
IncludeProvisionerDaemon: true,
})
defer closeDaemon.Close()

// Given: a user, template, and workspace
user := coderdtest.CreateFirstUser(t, client)
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil)
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)

// Given: all the provisioner daemons have not been seen for a while
ctx := testutil.Context(t, testutil.WaitLong)
newLastSeenAt := dbtime.Now().Add(-time.Hour)
_, err := db.ExecContext(ctx, `UPDATE provisioner_daemons SET last_seen_at = $1;`, newLastSeenAt)
require.NoError(t, err)

// When: a new workspace is created
ws, err := client.CreateUserWorkspace(ctx, codersdk.Me, codersdk.CreateWorkspaceRequest{
TemplateID: template.ID,
Name: "testing",
})
// Then: the request succeeds
require.NoError(t, err)
// Then: the workspace build is pending
require.Equal(t, codersdk.ProvisionerJobPending, ws.LatestBuild.Job.Status)
// Then: we can see that there are some provisioners that are stale
if assert.NotNil(t, ws.LatestBuild.MatchedProvisioners) {
assert.Equal(t, 1, ws.LatestBuild.MatchedProvisioners.Count)
assert.Zero(t, ws.LatestBuild.MatchedProvisioners.Available)
assert.Equal(t, newLastSeenAt.UTC(), ws.LatestBuild.MatchedProvisioners.MostRecentlySeen.Time.UTC())
assert.True(t, ws.LatestBuild.MatchedProvisioners.MostRecentlySeen.Valid)
}
})
}

func TestWorkspaceByOwnerAndName(t *testing.T) {
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp