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

Commita25e14b

Browse files
committed
Merge remote-tracking branch 'origin/main' into ssncferreira/feat-add-provisioner-daemon-name
2 parents98f3f4d +a07298a commita25e14b

File tree

41 files changed

+1280
-604
lines changed

Some content is hidden

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

41 files changed

+1280
-604
lines changed

‎.github/workflows/scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ jobs:
4747

4848
# Upload the results to GitHub's code scanning dashboard.
4949
-name:"Upload to code-scanning"
50-
uses:github/codeql-action/upload-sarif@60168efe1c415ce0f5521ea06d5c2062adbeed1b# v3.28.17
50+
uses:github/codeql-action/upload-sarif@ff0a06e83cb2de871e5a09832bc6a81e7276941f# v3.28.18
5151
with:
5252
sarif_file:results.sarif

‎.github/workflows/security.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
uses:./.github/actions/setup-go
3939

4040
-name:Initialize CodeQL
41-
uses:github/codeql-action/init@60168efe1c415ce0f5521ea06d5c2062adbeed1b# v3.28.17
41+
uses:github/codeql-action/init@ff0a06e83cb2de871e5a09832bc6a81e7276941f# v3.28.18
4242
with:
4343
languages:go, javascript
4444

@@ -48,7 +48,7 @@ jobs:
4848
rm Makefile
4949
5050
-name:Perform CodeQL Analysis
51-
uses:github/codeql-action/analyze@60168efe1c415ce0f5521ea06d5c2062adbeed1b# v3.28.17
51+
uses:github/codeql-action/analyze@ff0a06e83cb2de871e5a09832bc6a81e7276941f# v3.28.18
5252

5353
-name:Send Slack notification on failure
5454
if:${{ failure() }}
@@ -150,7 +150,7 @@ jobs:
150150
severity:"CRITICAL,HIGH"
151151

152152
-name:Upload Trivy scan results to GitHub Security tab
153-
uses:github/codeql-action/upload-sarif@60168efe1c415ce0f5521ea06d5c2062adbeed1b# v3.28.17
153+
uses:github/codeql-action/upload-sarif@ff0a06e83cb2de871e5a09832bc6a81e7276941f# v3.28.18
154154
with:
155155
sarif_file:trivy-results.sarif
156156
category:"Trivy"

‎agent/agentcontainers/acmock/acmock.go

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

‎agent/agentcontainers/acmock/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// Package acmock contains a mock implementation of agentcontainers.Lister for use in tests.
22
package acmock
33

4-
//go:generate mockgen -destination ./acmock.go -package acmock .. Lister
4+
//go:generate mockgen -destination ./acmock.go -package acmock .. Lister,DevcontainerCLI

‎agent/agentcontainers/api.go

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,15 @@ func WithClock(clock quartz.Clock) Option {
6969
}
7070
}
7171

72+
// WithCacheDuration sets the cache duration for the API.
73+
// This is used to control how often the API refreshes the list of
74+
// containers. The default is 10 seconds.
75+
funcWithCacheDuration(d time.Duration)Option {
76+
returnfunc(api*API) {
77+
api.cacheDuration=d
78+
}
79+
}
80+
7281
// WithExecer sets the agentexec.Execer implementation to use.
7382
funcWithExecer(execer agentexec.Execer)Option {
7483
returnfunc(api*API) {
@@ -336,14 +345,29 @@ func (api *API) getContainers(ctx context.Context) (codersdk.WorkspaceAgentListC
336345
}
337346

338347
// Check if the container is running and update the known devcontainers.
339-
for_,container:=rangeupdated.Containers {
348+
fori:=rangeupdated.Containers {
349+
container:=&updated.Containers[i]
340350
workspaceFolder:=container.Labels[DevcontainerLocalFolderLabel]
341351
configFile:=container.Labels[DevcontainerConfigFileLabel]
342352

343353
ifworkspaceFolder=="" {
344354
continue
345355
}
346356

357+
container.DevcontainerDirty=dirtyStates[workspaceFolder]
358+
ifcontainer.DevcontainerDirty {
359+
lastModified,hasModTime:=api.configFileModifiedTimes[configFile]
360+
ifhasModTime&&container.CreatedAt.After(lastModified) {
361+
api.logger.Info(ctx,"new container created after config modification, not marking as dirty",
362+
slog.F("container",container.ID),
363+
slog.F("created_at",container.CreatedAt),
364+
slog.F("config_modified_at",lastModified),
365+
slog.F("file",configFile),
366+
)
367+
container.DevcontainerDirty=false
368+
}
369+
}
370+
347371
// Check if this is already in our known list.
348372
ifknownIndex:=slices.IndexFunc(api.knownDevcontainers,func(dc codersdk.WorkspaceAgentDevcontainer)bool {
349373
returndc.WorkspaceFolder==workspaceFolder
@@ -356,7 +380,7 @@ func (api *API) getContainers(ctx context.Context) (codersdk.WorkspaceAgentListC
356380
}
357381
}
358382
api.knownDevcontainers[knownIndex].Running=container.Running
359-
api.knownDevcontainers[knownIndex].Container=&container
383+
api.knownDevcontainers[knownIndex].Container=container
360384

361385
// Check if this container was created after the config
362386
// file was modified.
@@ -395,28 +419,14 @@ func (api *API) getContainers(ctx context.Context) (codersdk.WorkspaceAgentListC
395419
}
396420
}
397421

398-
dirty:=dirtyStates[workspaceFolder]
399-
ifdirty {
400-
lastModified,hasModTime:=api.configFileModifiedTimes[configFile]
401-
ifhasModTime&&container.CreatedAt.After(lastModified) {
402-
api.logger.Info(ctx,"new container created after config modification, not marking as dirty",
403-
slog.F("container",container.ID),
404-
slog.F("created_at",container.CreatedAt),
405-
slog.F("config_modified_at",lastModified),
406-
slog.F("file",configFile),
407-
)
408-
dirty=false
409-
}
410-
}
411-
412422
api.knownDevcontainers=append(api.knownDevcontainers, codersdk.WorkspaceAgentDevcontainer{
413423
ID:uuid.New(),
414424
Name:name,
415425
WorkspaceFolder:workspaceFolder,
416426
ConfigPath:configFile,
417427
Running:container.Running,
418-
Dirty:dirty,
419-
Container:&container,
428+
Dirty:container.DevcontainerDirty,
429+
Container:container,
420430
})
421431
}
422432

@@ -510,6 +520,13 @@ func (api *API) handleDevcontainerRecreate(w http.ResponseWriter, r *http.Reques
510520
slog.F("name",api.knownDevcontainers[i].Name),
511521
)
512522
api.knownDevcontainers[i].Dirty=false
523+
// TODO(mafredri): This should be handled by a service that
524+
// updates the devcontainer state periodically and on-demand.
525+
api.knownDevcontainers[i].Container=nil
526+
// Set the modified time to the zero value to indicate that
527+
// the containers list must be refreshed. This will see to
528+
// it that the new container is re-assigned.
529+
api.mtime= time.Time{}
513530
}
514531
return
515532
}
@@ -579,6 +596,9 @@ func (api *API) markDevcontainerDirty(configPath string, modifiedAt time.Time) {
579596
slog.F("modified_at",modifiedAt),
580597
)
581598
api.knownDevcontainers[i].Dirty=true
599+
ifapi.knownDevcontainers[i].Container!=nil {
600+
api.knownDevcontainers[i].Container.DevcontainerDirty=true
601+
}
582602
}
583603
}
584604
})

‎agent/agentcontainers/api_internal_test.go

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp