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 Cloud Composer Environments resource #2001

Merged
merged 5 commits into from
Sep 11, 2018

Conversation

emilymye
Copy link
Contributor

@emilymye emilymye commented Sep 6, 2018

Fixes #1588

Deleted initial code from when I thought I would use MM to do this. We aren't because:

  • Update can require more than one API call and various formats per call (one PATCH per field)
  • Some fields can only be added in Create through a post-create PATCH

@ghost ghost added the size/xxl label Sep 6, 2018
@emilymye emilymye changed the title Cloud Composer Environment Add Cloud Composer Environments resource Sep 6, 2018
@emilymye
Copy link
Contributor Author

emilymye commented Sep 6, 2018

Basic Test Run:
$ make testacc TEST=./google TESTARGS='--run="(TestAccComposerEnvironment_update|TestAccComposerEnvironment_basic)"'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 TF_SCHEMA_PANIC_ON_ERROR=1 go test ./google -v --run="TestAccComposerEnvironment_basic" -timeout 120m
=== RUN TestAccComposerEnvironment_basic
=== PAUSE TestAccComposerEnvironment_basic
=== CONT TestAccComposerEnvironment_basic
--- PASS: TestAccComposerEnvironment_basic (1216.31s)

Update Test Run: TODO
Node Config Test Run: TODO
Software Config Test Run: TODO

@ghost ghost added the size/xxl label Sep 6, 2018
@ghost ghost added the size/xxl label Sep 7, 2018
Copy link
Contributor

@danawillow danawillow left a comment

Choose a reason for hiding this comment

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

Thanks for dealing with this! It sucks that we can't use MM as-is, and we probably could add some functionality into it that would help, but I agree that right now probably the best thing is to get something working, and then we can backport it later if we can.

},

Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(3600 * time.Second),
Copy link
Contributor

Choose a reason for hiding this comment

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

Mind adding a quick comment here that this is indeed the default timeout because composer takes so long and not because this is a typo?

Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"state": {
Copy link
Contributor

Choose a reason for hiding this comment

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

I could be wrong, but these last four probably aren't necessary to include, unless you think people will want to check their values with terraform show or use them for interpolation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can remove them.

return handleNotFoundError(err, d, fmt.Sprintf("ComposerEnvironment %q", d.Id()))
}

// Set from d.GetProject
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: d.GetProject isn't a thing, probably just getProject

google/resource_composer_environment.go Show resolved Hide resolved
}

if d.HasChange("config.0.software_config.0.env_variables") {
patchObj := &composer.Environment{
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious- what happens if we specify a patch object with all the fields set via the same expander we use in create, and then here we only worry about setting the correct mask? would that work or would it complain that we set fields that weren't in the mask?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TBH I'm not sure - I am using expandComposerEnvironmentConfig above so there is a little reuse? I didn't want to deal with the case that they might not enjoy a particular field being included somewhere, so I thought it would be overall less to worry about if I used the expander and then created "immutable" throwaway object with only the fields being updated, in case.


// Checks that all updatable fields can be updated in one apply
// (PATCH for Environments only is per-field) and that reverting
// config force-updates back to default.
Copy link
Contributor

Choose a reason for hiding this comment

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

Which is the part of the test that reverts config?

Copy link
Contributor Author

@emilymye emilymye Sep 7, 2018

Choose a reason for hiding this comment

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

I removed it after I realized we don't force-update back to default unless explicitly set to, will update comment

(Optional)
The set of Google API scopes to be made available on all node
VMs. Cannot be updated. If empty, defaults to
["https://www.googleapis.com/auth/cloud-platform"]
Copy link
Contributor

Choose a reason for hiding this comment

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

can you put this in `s so it doesn't show up as a link?


* `env_variables` -
(Optional)
Additional environment variables to provide to the Apache Airflow scheduler, worker, and webserver processes. Environment variable names must match the regular expression [a-zA-Z_][a-zA-Z0-9_]*. They cannot specify Apache Airflow software configuration overrides (they cannot match the regular expression AIRFLOW__[A-Z0-9_]+__[A-Z0-9_]+), and they cannot match any of the following reserved names:
Copy link
Contributor

Choose a reason for hiding this comment

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

can you put regexes in `s? GH is previewing things funny because of underscores :(

This resource provides the following
[Timeouts](/docs/configuration/resources.html#timeouts) configuration options:

- `create` - Default is 6 minutes.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think these need to be updated

Composer service may only detect config errors several (e.g. ~40-50 minutes) into
the creation process and may only have limited error reporting. If you encounter confusing
or uninformative errors, please verify your config, especially Airflow properties in `software_config` or
[shared VPC config](#Configuring-Kubernetes-Engine-and-Shared-VPC) in `node_config`.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you need a full link here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just removed this part so nvm

@ghost ghost added the size/xxl label Sep 10, 2018
@emilymye
Copy link
Contributor Author

Up-to-date test runs as of Monday EOD:
--- PASS: TestAccComposerEnvironment_basic (1168.93s)
--- PASS: TestAccComposerEnvironment_update (2539.89s)
--- PASS: TestAccComposerEnvironment_withNodeConfig (1245.89s)
--- PASS: TestAccComposerEnvironment_withUpdateOnCreate (2358.59s)

HUZZAH

Copy link
Contributor

@danawillow danawillow left a comment

Choose a reason for hiding this comment

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

HUZZAH INDEED

google/resource_composer_environment_test.go Outdated Show resolved Hide resolved
google/resource_composer_environment_test.go Outdated Show resolved Hide resolved
google/resource_composer_environment_test.go Show resolved Hide resolved
website/docs/r/composer_environment.html.markdown Outdated Show resolved Hide resolved
website/docs/r/composer_environment.html.markdown Outdated Show resolved Hide resolved
website/docs/r/composer_environment.html.markdown Outdated Show resolved Hide resolved
@ghost ghost added the size/xxl label Sep 11, 2018
@emilymye emilymye merged commit 017f2f9 into hashicorp:master Sep 11, 2018
@alan-ma-umg
Copy link

@emilymye by any chance you have example terraform config for us to follow? thanks!

chrisst pushed a commit to chrisst/terraform-provider-google that referenced this pull request Nov 9, 2018
Adds Cloud Composer Environment resource and test sweeper
@ghost
Copy link

ghost commented Nov 16, 2018

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Nov 16, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants