Skip to content
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

Auto-upgrade for colab runtimes #12931

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a966f6c
update documentation for instance_owners field
bcreddy-gcp Oct 31, 2024
71e2553
update documentation for instance_owners field
bcreddy-gcp Oct 31, 2024
6a7ddbb
lint fix
bcreddy-gcp Oct 31, 2024
85b523e
Merge branch 'GoogleCloudPlatform:main' into main
bcreddy-gcp Nov 6, 2024
b4f50e3
Merge branch 'GoogleCloudPlatform:main' into main
bcreddy-gcp Dec 5, 2024
268e2ae
gcs-data-bucket is now modifiable by the customer
bcreddy-gcp Dec 5, 2024
c9e07e6
Add suport for Third Party Identity
bcreddy-gcp Dec 18, 2024
b5377ef
Merge branch 'GoogleCloudPlatform:main' into main
bcreddy-gcp Dec 18, 2024
609f8ad
Merge branch 'GoogleCloudPlatform:main' into main
bcreddy-gcp Dec 23, 2024
90e2d72
Merge branch 'GoogleCloudPlatform:main' into main
bcreddy-gcp Jan 6, 2025
505400c
Merge branch 'GoogleCloudPlatform:main' into main
bcreddy-gcp Jan 10, 2025
52ed31f
Merge branch 'GoogleCloudPlatform:main' into main
bcreddy-gcp Jan 13, 2025
6b4d5e9
Merge branch 'GoogleCloudPlatform:main' into main
bcreddy-gcp Jan 22, 2025
9f4aec7
Merge branch 'GoogleCloudPlatform:main' into main
bcreddy-gcp Jan 28, 2025
e21b14e
draft
bcreddy-gcp Jan 29, 2025
54fcc25
remove workbench changes
bcreddy-gcp Jan 29, 2025
1e9729e
draft
bcreddy-gcp Jan 29, 2025
dc6c16d
Merge branch 'GoogleCloudPlatform:main' into runtime-state
bcreddy-gcp Jan 30, 2025
a1e848b
draft
bcreddy-gcp Jan 30, 2025
9e3cfd9
Add update test
bcreddy-gcp Jan 30, 2025
ee87f59
working example
bcreddy-gcp Jan 30, 2025
884938c
Also make the runtime upgradable
bcreddy-gcp Jan 30, 2025
f343fc7
remove upgrade changes
bcreddy-gcp Jan 30, 2025
8bf23e2
Merge branch 'GoogleCloudPlatform:main' into runtime-state
bcreddy-gcp Jan 30, 2025
d196576
resolve merge
bcreddy-gcp Jan 30, 2025
67c1cfa
Enable auto-upgrade for runtimes
bcreddy-gcp Jan 31, 2025
0f3e6bb
Upgrade runtime automatically if a USER_DEFINED runtime is expired
bcreddy-gcp Feb 3, 2025
6144027
Merge branch 'main' into colab-upgrade-runtime
bcreddy-gcp Feb 3, 2025
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
20 changes: 20 additions & 0 deletions mmv1/products/colab/Runtime.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,17 @@ examples:
key_name: 'acctest.BootstrapKMSKeyInLocation(t, "us-central1").CryptoKey.Name'
ignore_read_extra:
- 'desired_state'
- 'auto_upgrade'
virtual_fields:
- name: 'desired_state'
description: |
Desired state of the Colab Runtime. Set this field to `RUNNING` to start the runtime, and `STOPPED` to stop it.
type: String
default_value: "RUNNING"
- name: 'auto_upgrade'
description: |
Triggers an upgrade anytime the runtime is started if it is upgradable.
type: Boolean
parameters:
- name: 'location'
type: String
Expand Down Expand Up @@ -110,3 +115,18 @@ properties:
description: |
Output only. The state of the runtime.
output: true
- name: isUpgradable
type: Boolean
description: |
Output only. Checks if the NotebookRuntime is upgradable.
output: true
- name: expirationTime
type: String
description: |
Output only. Timestamp when this NotebookRuntime will be expired.
output: true
- name: notebookRuntimeType
type: String
description: |
Output only. The type of the notebook runtime.
output: true
21 changes: 21 additions & 0 deletions mmv1/templates/terraform/custom_update/colab_runtime.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,25 @@ if desired_state != "" && state != desired_state {
log.Printf("[DEBUG] Colab runtime %q has state %q.", name, state)
}

var upgrade_runtime bool
if d.Get("auto_upgrade").(bool) && d.Get("is_upgradable").(bool) {
upgrade_runtime = true
}

expiration_time_string := d.Get("expiration_time").(string)
expiration_time, err := time.Parse(time.RFC3339Nano, expiration_time_string)
if err != nil {
return err
}

if expiration_time.Before(time.Now()) && d.Get("notebook_runtime_type").(string) == "USER_DEFINED" {
upgrade_runtime = true
}

if upgrade_runtime {
if err := ModifyColabRuntime(config, d, project, billingProject, userAgent, "upgrade"); err != nil {
return err
}
}

return nil
2 changes: 2 additions & 0 deletions mmv1/templates/terraform/examples/colab_runtime_full.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ resource "google_colab_runtime" "{{$.PrimaryResourceId}}" {

desired_state = "ACTIVE"

auto_upgrade = true

depends_on = [
google_colab_runtime_template.my_template
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestAccColabRuntime_update(t *testing.T) {
ResourceName: "google_colab_runtime.runtime",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"desired_state", "location", "name"},
ImportStateVerifyIgnore: []string{"desired_state", "location", "name", "auto_upgrade"},
},
{
Config: testAccColabRuntime_no_state(context),
Expand All @@ -38,7 +38,7 @@ func TestAccColabRuntime_update(t *testing.T) {
ResourceName: "google_colab_runtime.runtime",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"desired_state", "location", "name"},
ImportStateVerifyIgnore: []string{"desired_state", "location", "name", "auto_upgrade"},
},
{
Config: testAccColabRuntime_stopped(context),
Expand All @@ -52,7 +52,21 @@ func TestAccColabRuntime_update(t *testing.T) {
ResourceName: "google_colab_runtime.runtime",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"desired_state", "location", "name"},
ImportStateVerifyIgnore: []string{"desired_state", "location", "name", "auto_upgrade"},
},
{
Config: testAccColabRuntime_full(context),
ConfigPlanChecks: resource.ConfigPlanChecks{
PreApply: []plancheck.PlanCheck{
plancheck.ExpectResourceAction("google_colab_runtime.runtime", plancheck.ResourceActionUpdate),
},
},
},
{
ResourceName: "google_colab_runtime.runtime",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"desired_state", "location", "name", "auto_upgrade"},
},
},
})
Expand Down Expand Up @@ -115,7 +129,9 @@ resource "google_colab_runtime" "runtime" {
runtime_user = "[email protected]"
description = "Full runtime"

desired_state = "ACTIVE"
desired_state = "RUNNING"

auto_upgrade = true

depends_on = [
google_colab_runtime_template.my_template
Expand Down
Loading