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

Composer fix scheduler count update #6159

Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,21 @@ func resourceComposerEnvironmentUpdate(d *schema.ResourceData, meta interface{})
}
<% end -%>

if d.HasChange("config.0.software_config.0.scheduler_count") {
patchObj := &composer.Environment{
Config: &composer.EnvironmentConfig{
SoftwareConfig: &composer.SoftwareConfig{},
},
}
if config != nil && config.SoftwareConfig != nil {
patchObj.Config.SoftwareConfig.SchedulerCount = config.SoftwareConfig.SchedulerCount
}
err = resourceComposerEnvironmentPatchField("config.softwareConfig.schedulerCount", userAgent, patchObj, d, tfConfig)
if err != nil {
return err
}
}

if d.HasChange("config.0.software_config.0.airflow_config_overrides") {
patchObj := &composer.Environment{
Config: &composer.EnvironmentConfig{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -719,8 +719,11 @@ func TestAccComposerEnvironmentAirflow2_withSoftwareConfig(t *testing.T) {
Config: testAccComposerEnvironment_airflow2SoftwareCfg(envName, network, subnetwork),
},
{
ResourceName: "google_composer_environment.test",
ImportState: true,
Config: testAccComposerEnvironmentUpdate_airflow2SoftwareCfg(envName, network, subnetwork),
kubasieron marked this conversation as resolved.
Show resolved Hide resolved
},
{
ResourceName: "google_composer_environment.test",
ImportState: true,
ImportStateVerify: true,
},
// This is a terrible clean-up step in order to get destroy to succeed,
Expand All @@ -729,8 +732,8 @@ func TestAccComposerEnvironmentAirflow2_withSoftwareConfig(t *testing.T) {
{
PlanOnly: true,
ExpectNonEmptyPlan: false,
Config: testAccComposerEnvironment_airflow2SoftwareCfg(envName, network, subnetwork),
Check: testAccCheckClearComposerEnvironmentFirewalls(t, network),
Config: testAccComposerEnvironmentUpdate_airflow2SoftwareCfg(envName, network, subnetwork),
Check: testAccCheckClearComposerEnvironmentFirewalls(t, network),
kubasieron marked this conversation as resolved.
Show resolved Hide resolved
},
},
})
Expand Down Expand Up @@ -1716,6 +1719,40 @@ resource "google_compute_subnetwork" "test" {
`, name, network, subnetwork)
}

func testAccComposerEnvironmentUpdate_airflow2SoftwareCfg(name, network, subnetwork string) string {
return fmt.Sprintf(`
resource "google_composer_environment" "test" {
name = "%s"
region = "us-central1"
config {
node_config {
network = google_compute_network.test.self_link
subnetwork = google_compute_subnetwork.test.self_link
zone = "us-central1-a"
}
software_config {
image_version = "composer-1-airflow-2"
scheduler_count = 3
}
}
}

// use a separate network to avoid conflicts with other tests running in parallel
// that use the default network/subnet
resource "google_compute_network" "test" {
name = "%s"
auto_create_subnetworks = false
}

resource "google_compute_subnetwork" "test" {
name = "%s"
ip_cidr_range = "10.2.0.0/16"
region = "us-central1"
network = google_compute_network.test.self_link
}
`, name, network, subnetwork)
}

/**
* CLEAN UP HELPER FUNCTIONS
* Because the environments are flaky and bucket deletion rates can be
Expand Down