Skip to content

feat: Add shutdown_script_timeout #96

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions docs/data-sources/parameter.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Optional:
- `error` (String) An error message to display if the value doesn't match the provided regex.
- `max` (Number) The maximum of a number parameter.
- `min` (Number) The minimum of a number parameter.
- `monotonic` (String) Number monotonicity, either increasing or decreasing.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

nit: we may want to improve the Makefile to detect discrepancies.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is done via make gen, we should probably verify in CI that there are no changes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's what I meant.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll toss up a PR 👍🏻

- `regex` (String) A regex for the input parameter to match against.


3 changes: 2 additions & 1 deletion docs/resources/agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ resource "kubernetes_pod" "dev" {
- `login_before_ready` (Boolean) This option defines whether or not the user can (by default) login to the workspace before it is ready. Ready means that e.g. the startup_script is done and has exited. When enabled, users may see an incomplete workspace when logging in.
- `motd_file` (String) The path to a file within the workspace containing a message to display to users when they login via SSH. A typical value would be /etc/motd.
- `shutdown_script` (String) A script to run before the agent is stopped. The script should exit when it is done to signal that the workspace can be stopped.
- `shutdown_script_timeout` (Number) Time in seconds until the agent lifecycle status is marked as timed out during shutdown, this happens when the shutdown script has not completed (exited) in the given time.
- `startup_script` (String) A script to run after the agent starts. The script should exit when it is done to signal that the agent is ready.
- `startup_script_timeout` (Number) Time in seconds until the agent ready status is marked as timed out, this happens when the startup script has not completed (exited) in the given time.
- `startup_script_timeout` (Number) Time in seconds until the agent lifecycle status is marked as timed out during start, this happens when the startup script has not completed (exited) in the given time.
- `troubleshooting_url` (String) A URL to a document with instructions for troubleshooting problems with the agent.

### Read-Only
Expand Down
10 changes: 9 additions & 1 deletion provider/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func agentResource() *schema.Resource {
Default: 300,
ForceNew: true,
Optional: true,
Description: "Time in seconds until the agent ready status is marked as timed out, this happens when the startup script has not completed (exited) in the given time.",
Description: "Time in seconds until the agent lifecycle status is marked as timed out during start, this happens when the startup script has not completed (exited) in the given time.",
ValidateFunc: validation.IntAtLeast(1),
},
"shutdown_script": {
Expand All @@ -95,6 +95,14 @@ func agentResource() *schema.Resource {
Optional: true,
Description: "A script to run before the agent is stopped. The script should exit when it is done to signal that the workspace can be stopped.",
},
"shutdown_script_timeout": {
Type: schema.TypeInt,
Default: 300,
ForceNew: true,
Optional: true,
Description: "Time in seconds until the agent lifecycle status is marked as timed out during shutdown, this happens when the shutdown script has not completed (exited) in the given time.",
ValidateFunc: validation.IntAtLeast(1),
},
"token": {
ForceNew: true,
Sensitive: true,
Expand Down
2 changes: 2 additions & 0 deletions provider/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func TestAgent(t *testing.T) {
troubleshooting_url = "https://example.com/troubleshoot"
motd_file = "/etc/motd"
shutdown_script = "echo bye bye"
shutdown_script_timeout = 120
login_before_ready = false
}
`,
Expand All @@ -56,6 +57,7 @@ func TestAgent(t *testing.T) {
"troubleshooting_url",
"motd_file",
"shutdown_script",
"shutdown_script_timeout",
"login_before_ready",
} {
value := resource.Primary.Attributes[key]
Expand Down