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

Add support for Updating Container Image #12607

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
5 changes: 5 additions & 0 deletions mmv1/products/workbench/Instance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -543,3 +543,8 @@ properties:
Optional. Labels to apply to this instance. These can be later modified
by the UpdateInstance method.
diff_suppress_func: 'WorkbenchInstanceLabelsDiffSuppress'
- name: 'enableThirdPartyIdentity'
type: Boolean
description: |
Flag that specifies that a notebook can be accessed with third party
identity provider.
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,6 @@ resource "google_workbench_instance" "{{$.PrimaryResourceId}}" {

desired_state = "ACTIVE"

enable_third_party_identity = "true"

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ if d.HasChange("gce_setup.0.metadata") {
if d.HasChange("effective_labels") {
newUpdateMask = append(newUpdateMask, "labels")
}
if d.HasChange("gce_setup.0.container_image") {
newUpdateMask = append(newUpdateMask, "gce_setup.container_image")
stopInstance = true
}
updateMask = newUpdateMask
// Overwrite the previously set mask.
url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(newUpdateMask, ",")})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -690,3 +690,75 @@ resource "google_workbench_instance" "instance" {
}
`, context)
}


func TestAccWorkbenchInstance_updateCustomContainers(t *testing.T) {
t.Parallel()

context := map[string]interface{}{
"random_suffix": acctest.RandString(t, 10),
}

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccWorkbenchInstance_customcontainer(context),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"google_workbench_instance.instance", "state", "ACTIVE"),
),
},
{
ResourceName: "google_workbench_instance.instance",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"name", "instance_owners", "location", "instance_id", "request_id", "labels", "terraform_labels","desired_state"},
},
{
Config: testAccWorkbenchInstance_updatedcustomcontainer(context),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"google_workbench_instance.instance", "state", "ACTIVE"),
),
},
{
ResourceName: "google_workbench_instance.instance",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"name", "instance_owners", "location", "instance_id", "request_id", "labels", "terraform_labels","desired_state"},
},
},
})
}

func testAccWorkbenchInstance_customcontainer(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_workbench_instance" "instance" {
name = "tf-test-workbench-instance%{random_suffix}"
location = "us-central1-a"
gce_setup {
container_image {
repository = "us-docker.pkg.dev/deeplearning-platform-release/gcr.io/base-cu113.py310"
tag = "latest"
}
}
}
`, context)
}

func testAccWorkbenchInstance_updatedcustomcontainer(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_workbench_instance" "instance" {
name = "tf-test-workbench-instance%{random_suffix}"
location = "us-central1-a"
gce_setup {
container_image {
repository = "gcr.io/deeplearning-platform-release/workbench-container"
tag = "20241117-2200-rc0"
}
}
}
`, context)
}
Loading