Skip to content

Add idle_timeout_minutes as possible cs create param#4741

Merged
mislav merged 4 commits intotrunkfrom
cs-idle-timeout-minutes
Nov 18, 2021
Merged

Add idle_timeout_minutes as possible cs create param#4741
mislav merged 4 commits intotrunkfrom
cs-idle-timeout-minutes

Conversation

@reybard
Copy link
Contributor

@reybard reybard commented Nov 16, 2021

We have a friction item for allowing users to specify idle timeout overrides for their codespaces. The plan is to roll out the feature allowing a permanent override via configuration in the UI, while the CLI can optionally specify overrides for each codespace created.

In practice it looks like:

» gh cs create -r monalisa/smile -b main --idle-timeout 129m                                                                                                                                                                                                             
monalisa-smile-6vc465g

And a few various error cases:

# setting timeout above maximum
» gh cs create -r monalisa/smile -b main --idle-timeout 1000m                                                                                                                                                                                                            
error creating codespace: HTTP 400: idle_timeout_minutes must be an integer between 5 and 720 minutes (http://api.github.localhost/user/codespaces)
exit status 1

# setting timeout below minimum
» gh cs create -r monalisa/smile -b main --idle-timeout 4m                                                                                                                                                                                                               
error creating codespace: HTTP 400: idle_timeout_minutes must be an integer between 5 and 720 minutes (http://api.github.localhost/user/codespaces)
exit status 1

# invalid input
» gh cs create -r github/registry-metadata -b master --idle-timeout foobar
invalid argument "foobar" for "-i, --idle-timeout" flag: time: invalid duration "foobar"

Usage:  gh codespace create [flags]

Flags:
  -b, --branch string           repository branch
  -i, --idle-timeout duration   duration of inactivity before codespace is shutdown/stopped e.g. "3600s", "60m", "1h" (default 30m0s)
  -m, --machine string          hardware specifications for the VM
  -r, --repo string             repository name with owner: user/repo
  -s, --status                  show status of post-create command and dotfiles

exit status 1

The parameter is bubbled up to the create command which sends this value along to VSCS as the autoShutdownDelayMinutes environment option.

To test this flag you must be enabled for https://admin.github.com/devtools/feature_flags/codespaces_custom_idle_timeout otherwise it drops the param and behaves as if it were never passed at all.

Fixes https://github.com/github/cli/issues/101

@reybard reybard force-pushed the cs-idle-timeout-minutes branch from 7e07413 to 03ee9aa Compare November 16, 2021 22:34
Copy link
Contributor

@mislav mislav left a comment

Choose a reason for hiding this comment

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

This already looks pretty good! Thanks for adding the feature

@reybard reybard marked this pull request as ready for review November 17, 2021 22:31
@reybard reybard requested a review from a team as a code owner November 17, 2021 22:31
@reybard reybard requested a review from mislav November 17, 2021 22:33
Copy link
Contributor

@mislav mislav left a comment

Choose a reason for hiding this comment

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

Thank you! 🙇 I have pushed tweaks to take out the -i shorthand (I don't think it's necessary and also I would rather recommend that the idle timeout is always explicitly spelled out), to simplify the implementation slightly, and to add tests.

@mislav mislav enabled auto-merge (squash) November 18, 2021 11:45
@mislav mislav merged commit 90313fb into trunk Nov 18, 2021
@mislav mislav deleted the cs-idle-timeout-minutes branch November 18, 2021 11:47
@VictorBatta VictorBatta mentioned this pull request Dec 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants