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(agent): Add shutdown lifecycle states and shutdown_script support#6139

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
mafredri merged 21 commits intomainfrommafredri/feat-shutdown-script
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
21 commits
Select commitHold shift + click to select a range
5455c58
WIP
mtojekNov 24, 2022
5e8b150
Implement database model
mtojekNov 25, 2022
4a0888c
More code
mtojekNov 25, 2022
3ee962f
Run script
mtojekNov 25, 2022
739b680
Generate terraform testdata
mafredriFeb 1, 2023
82159e4
Fix rebase
mafredriFeb 9, 2023
5e41bcb
Add shutdown script timeout
mafredriFeb 9, 2023
e7ca1b2
Add agent shutdown lifecycle states
mafredriFeb 9, 2023
a57877a
Add notes/todos
mafredriFeb 10, 2023
bf42f4e
feat(site): Support new agent lifecycle states
mafredriFeb 10, 2023
292a878
Fix startup/shutdown script log messaging
mafredriFeb 10, 2023
e711909
Only wait for 5 seconds to report lifecycle at end
mafredriFeb 10, 2023
b362811
Fix site
mafredriFeb 10, 2023
5d0212a
Remove TODOs in favor of issues
mafredriFeb 13, 2023
867795c
Update terraform testdata
mafredriFeb 13, 2023
eff8915
Fix migrations
mafredriFeb 20, 2023
22ad8b9
Fix migrations
mafredriMar 6, 2023
019cf07
Add expected field for shutdown script timeout seconds
mafredriMar 6, 2023
1a1e38d
Fix proto not updated by make gen
mafredriMar 6, 2023
f51eab5
Fix lint
mafredriMar 6, 2023
57bc338
Merge branch 'main' into mafredri/feat-shutdown-script
mafredriMar 6, 2023
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
Fix rebase
  • Loading branch information
@mafredri
mafredri committedMar 6, 2023
commit82159e4544f17b87d83862b50e00e69d3a9d2bf2
22 changes: 9 additions & 13 deletionsagent/agent.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1301,19 +1301,15 @@ func (a *agent) Close() error {
close(a.closed)
a.closeCancel()

rawMetadata := a.metadata.Load()
if rawMetadata == nil {
return xerrors.Errorf("no metadata was provided")
}
metadata, valid := rawMetadata.(codersdk.WorkspaceAgentMetadata)
if !valid {
return xerrors.Errorf("metadata is the wrong type: %T", metadata)
}

ctx := context.Background()
err := a.runShutdownScript(ctx, metadata.ShutdownScript)
if err != nil {
a.logger.Error(ctx, "shutdown script failed", slog.Error(err))
if metadata, ok := a.metadata.Load().(agentsdk.Metadata); ok {
ctx := context.Background()
err := a.runShutdownScript(ctx, metadata.ShutdownScript)
if err != nil {
a.logger.Error(ctx, "shutdown script failed", slog.Error(err))
}
} else {
// No metadata.. halt?
_ = false
}

if a.network != nil {
Expand Down
4 changes: 2 additions & 2 deletionsagent/agent_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -834,12 +834,12 @@ func TestAgent_Lifecycle(t *testing.T) {
client := &client{
t: t,
agentID: uuid.New(),
metadata:codersdk.WorkspaceAgentMetadata{
metadata:agentsdk.Metadata{
DERPMap: tailnettest.RunDERPAndSTUN(t),
StartupScript: "echo 1",
ShutdownScript: "echo " + expected,
},
statsChan: make(chan *codersdk.AgentStats),
statsChan: make(chan *agentsdk.Stats),
coordinator: tailnet.NewCoordinator(),
}

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp