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

Clean the env vars of all TF_* flags #1850

Closed
wants to merge 1 commit into from

Conversation

eparis
Copy link
Member

@eparis eparis commented Jun 13, 2019

Such variables would allow a crafty user to directly manipulate terraform.
We do not want users doing that. So clear those env vars.

@openshift-ci-robot openshift-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jun 13, 2019
@stbenjam
Copy link
Member

Would it be possible to whitelist TF_LOG?

for _, env := range environ {
splits := strings.Split(env, "=")
key := splits[0]
if strings.HasPrefix(key, "TF_") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't this also unset TF_VAR_libvirt_master_memory and TF_VAR_libvirt_master_vcpu? We need a way to do that.

Copy link
Member Author

Choose a reason for hiding this comment

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

If the memory requirements are inadequate you need to fix the template. Terraform is not for users.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, we can have the right amount for memory in the template i guess. What about the VCPU? I guess it's time we implement suggestion of @cgwalters to autodetect that.

splits := strings.Split(env, "=")
key := splits[0]
if strings.HasPrefix(key, "TF_") {
os.Unsetenv(key)
Copy link
Member

Choose a reason for hiding this comment

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

Is this called early enough? Environment mutation is unsafe in the presence of threads.

@abhinavdahiya
Copy link
Contributor

The installer use aws-sdk, which allow certains envs that can be used to turn on debugging etc.. So i'm not sure why this is being forced?

This only allows vars to changes at global level, which is already very selective... so i'm not sure how preventive this is.

and we we do want to do that, can we move this to pkg/terraform/exec before we execute the terraform bindings.

TF_LOG needs to be allowed.

@abhinavdahiya
Copy link
Contributor

Looking at https://www.terraform.io/docs/configuration/variables.html#assigning-values-to-root-module-variables

When you declare variables in the root module of your configuration, you can set their values using CLI options and environment variables. When you declare them in child modules, the calling module should pass values in the module block.

the env can only be used to set the variable of the root module like variables-aws.tf, which are already exposed through install-config to the user.

So i don't see the use-case for removing the envs.

/close

@openshift-ci-robot
Copy link
Contributor

@abhinavdahiya: Closed this PR.

In response to this:

Looking at https://www.terraform.io/docs/configuration/variables.html#assigning-values-to-root-module-variables

When you declare variables in the root module of your configuration, you can set their values using CLI options and environment variables. When you declare them in child modules, the calling module should pass values in the module block.

the env can only be used to set the variable of the root module like variables-aws.tf, which are already exposed through install-config to the user.

So i don't see the use-case for removing the envs.

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign smarterclayton
You can assign the PR to them by writing /assign @smarterclayton in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@eparis
Copy link
Member Author

eparis commented May 1, 2020

/retest

@eparis
Copy link
Member Author

eparis commented May 4, 2020

/test all

@openshift openshift deleted a comment from openshift-ci-robot May 4, 2020
Such variables would allow a crafty user to directly manipulate terraform.
We do not want users doing that. Terraform is NOT an API. It is a hidden
completely internal implementation detail. So clear those env vars.
@Gal-Zaidman
Copy link
Contributor

Gal-Zaidman commented May 4, 2020

We are using TF_VAR_* on ovirt-e2e job, so this will always fail on our CI.
We will be able to use the install-config for that once [1] is done.
Can we put this one hold till [1] is done to avoid breaking ovirt tests ?

[1] #3399

@openshift-ci-robot
Copy link
Contributor

@eparis: The following tests failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/e2e-aws-scaleup-rhel7 c5a92d9 link /test e2e-aws-scaleup-rhel7
ci/prow/e2e-aws c5a92d9 link /test e2e-aws
ci/prow/e2e-aws-fips c5a92d9 link /test e2e-aws-fips
ci/prow/e2e-openstack c5a92d9 link /test e2e-openstack
ci/prow/e2e-ovirt c5a92d9 link /test e2e-ovirt
ci/prow/e2e-libvirt c5a92d9 link /test e2e-libvirt
ci/prow/e2e-aws-workers-rhel7 c5a92d9 link /test e2e-aws-workers-rhel7

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@abhinavdahiya
Copy link
Contributor

#1850 (comment)

/close

@openshift-ci-robot
Copy link
Contributor

@abhinavdahiya: Closed this PR.

In response to this:

#1850 (comment)

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants