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

Commitf5909e5

Browse files
authored
Merge branch 'main' into jakehwll/routing-ai-governance
2 parents13a0cc9 +d306a2d commitf5909e5

File tree

21 files changed

+199
-366
lines changed

21 files changed

+199
-366
lines changed

‎coderd/apidoc/docs.go‎

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

‎coderd/apidoc/swagger.json‎

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

‎coderd/coderdtest/coderdtest.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1604,7 +1604,7 @@ func (nopcloser) Close() error { return nil }
16041604
// SDKError coerces err into an SDK error.
16051605
funcSDKError(t testing.TB,errerror)*codersdk.Error {
16061606
varcerr*codersdk.Error
1607-
require.True(t,errors.As(err,&cerr),"should be SDK error, got %w",err)
1607+
require.True(t,errors.As(err,&cerr),"should be SDK error, got %s",err)
16081608
returncerr
16091609
}
16101610

‎coderd/workspacebuilds.go‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,15 @@ func (api *API) postWorkspaceBuilds(rw http.ResponseWriter, r *http.Request) {
335335
return
336336
}
337337

338+
// We want to allow a delete build for a deleted workspace, but not a start or stop build.
339+
ifworkspace.Deleted&&createBuild.Transition!=codersdk.WorkspaceTransitionDelete {
340+
httpapi.Write(ctx,rw,http.StatusConflict, codersdk.Response{
341+
Message:fmt.Sprintf("Cannot %s a deleted workspace!",createBuild.Transition),
342+
Detail:"This workspace has been deleted and cannot be modified.",
343+
})
344+
return
345+
}
346+
338347
apiBuild,err:=api.postWorkspaceBuildsInternal(
339348
ctx,
340349
apiKey,
@@ -1219,7 +1228,6 @@ func (api *API) convertWorkspaceBuild(
12191228
TemplateVersionPresetID:presetID,
12201229
HasAITask:hasAITask,
12211230
AITaskSidebarAppID:taskAppID,
1222-
TaskAppID:taskAppID,
12231231
HasExternalAgent:hasExternalAgent,
12241232
},nil
12251233
}

‎coderd/workspacebuilds_test.go‎

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1840,6 +1840,68 @@ func TestPostWorkspaceBuild(t *testing.T) {
18401840
require.NoError(t,err)
18411841
require.Equal(t,codersdk.BuildReasonDashboard,build.Reason)
18421842
})
1843+
t.Run("DeletedWorkspace",func(t*testing.T) {
1844+
t.Parallel()
1845+
1846+
// Given: a workspace that has already been deleted
1847+
var (
1848+
ctx=testutil.Context(t,testutil.WaitShort)
1849+
logger=slogtest.Make(t,&slogtest.Options{}).Leveled(slog.LevelError)
1850+
adminClient,db=coderdtest.NewWithDatabase(t,&coderdtest.Options{
1851+
Logger:&logger,
1852+
})
1853+
admin=coderdtest.CreateFirstUser(t,adminClient)
1854+
workspaceOwnerClient,member1=coderdtest.CreateAnotherUser(t,adminClient,admin.OrganizationID)
1855+
otherMemberClient,_=coderdtest.CreateAnotherUser(t,adminClient,admin.OrganizationID)
1856+
ws=dbfake.WorkspaceBuild(t,db, database.WorkspaceTable{OwnerID:member1.ID,OrganizationID:admin.OrganizationID}).
1857+
Seed(database.WorkspaceBuild{Transition:database.WorkspaceTransitionDelete}).
1858+
Do()
1859+
)
1860+
1861+
// This needs to be done separately as provisionerd handles marking the workspace as deleted
1862+
// and we're skipping provisionerd here for speed.
1863+
require.NoError(t,db.UpdateWorkspaceDeletedByID(dbauthz.AsProvisionerd(ctx), database.UpdateWorkspaceDeletedByIDParams{
1864+
ID:ws.Workspace.ID,
1865+
Deleted:true,
1866+
}))
1867+
1868+
// Assert test invariant: Workspace should be deleted
1869+
dbWs,err:=db.GetWorkspaceByID(dbauthz.AsProvisionerd(ctx),ws.Workspace.ID)
1870+
require.NoError(t,err)
1871+
require.True(t,dbWs.Deleted,"workspace should be deleted")
1872+
1873+
for_,tc:=range []struct {
1874+
user*codersdk.Client
1875+
tr codersdk.WorkspaceTransition
1876+
expectStatusint
1877+
}{
1878+
// You should not be allowed to mess with a workspace you don't own, regardless of its deleted state.
1879+
{otherMemberClient,codersdk.WorkspaceTransitionStart,http.StatusNotFound},
1880+
{otherMemberClient,codersdk.WorkspaceTransitionStop,http.StatusNotFound},
1881+
{otherMemberClient,codersdk.WorkspaceTransitionDelete,http.StatusNotFound},
1882+
// Starting or stopping a workspace is not allowed when it is deleted.
1883+
{workspaceOwnerClient,codersdk.WorkspaceTransitionStart,http.StatusConflict},
1884+
{workspaceOwnerClient,codersdk.WorkspaceTransitionStop,http.StatusConflict},
1885+
// We allow a delete just in case a retry is required. In most cases, this will be a no-op.
1886+
// Note: this is the last test case because it will change the state of the workspace.
1887+
{workspaceOwnerClient,codersdk.WorkspaceTransitionDelete,http.StatusOK},
1888+
} {
1889+
// When: we create a workspace build with the given transition
1890+
_,err=tc.user.CreateWorkspaceBuild(ctx,ws.Workspace.ID, codersdk.CreateWorkspaceBuildRequest{
1891+
Transition:tc.tr,
1892+
})
1893+
1894+
// Then: we allow ONLY a delete build for a deleted workspace.
1895+
iftc.expectStatus<http.StatusBadRequest {
1896+
require.NoError(t,err,"creating a %s build for a deleted workspace should not error",tc.tr)
1897+
}else {
1898+
varapiError*codersdk.Error
1899+
require.Error(t,err,"creating a %s build for a deleted workspace should return an error",tc.tr)
1900+
require.ErrorAs(t,err,&apiError)
1901+
require.Equal(t,tc.expectStatus,apiError.StatusCode())
1902+
}
1903+
}
1904+
})
18431905
}
18441906

18451907
funcTestWorkspaceBuildTimings(t*testing.T) {

‎codersdk/workspacebuilds.go‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,8 @@ type WorkspaceBuild struct {
8989
MatchedProvisioners*MatchedProvisioners`json:"matched_provisioners,omitempty"`
9090
TemplateVersionPresetID*uuid.UUID`json:"template_version_preset_id" format:"uuid"`
9191
HasAITask*bool`json:"has_ai_task,omitempty"`
92-
// Deprecated: This field has been replaced with `TaskAppID`
92+
// Deprecated: This field has been replaced with `Task.WorkspaceAppID`
9393
AITaskSidebarAppID*uuid.UUID`json:"ai_task_sidebar_app_id,omitempty" format:"uuid"`
94-
TaskAppID*uuid.UUID`json:"task_app_id,omitempty" format:"uuid"`
9594
HasExternalAgent*bool`json:"has_external_agent,omitempty"`
9695
}
9796

‎docs/admin/infrastructure/validated-architectures/10k-users.md‎

Lines changed: 0 additions & 124 deletions
This file was deleted.

‎docs/admin/infrastructure/validated-architectures/index.md‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,6 @@ For sizing recommendations, see the below reference architectures:
220220

221221
-[Up to 3,000 users](3k-users.md)
222222

223-
- DRAFT:[Up to 10,000 users](10k-users.md)
224-
225223
###AWS Instance Types
226224

227225
For production AWS deployments, we recommend using non-burstable instance types,

‎docs/manifest.json‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -396,11 +396,6 @@
396396
"title":"Up to 3,000 Users",
397397
"description":"Enterprise-scale architecture recommendations for Coder deployments that support up to 3,000 users",
398398
"path":"./admin/infrastructure/validated-architectures/3k-users.md"
399-
},
400-
{
401-
"title":"Up to 10,000 Users",
402-
"description":"Enterprise-scale architecture recommendations for Coder deployments that support up to 10,000 users",
403-
"path":"./admin/infrastructure/validated-architectures/10k-users.md"
404399
}
405400
]
406401
},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp