-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
asset/cluster: Invoke terraform in a temp dir. #319
asset/cluster: Invoke terraform in a temp dir. #319
Conversation
Does this mean we won't have the Terraform state around for cluster deletion? |
if err != nil { | ||
return nil, fmt.Errorf("failed to create temp dir: %v", err) | ||
} | ||
defer os.RemoveAll(tmpDir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really want to unconditionally remove the terraform state? We could gate this with an option to keep tempfiles if someone wishes to, so we can use it for destruction later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@steveej We still have the tfstate file in the assets dir, it will be persisted by the store
https://github.com/openshift/installer/blob/master/cmd/openshift-install/main.go#L47
https://github.com/openshift/installer/blob/master/cmd/openshift-install/main.go#L66
pkg/asset/cluster/cluster.go
Outdated
@@ -65,11 +72,11 @@ func (c *Cluster) Generate(parents map[asset.Asset]*asset.State) (*asset.State, | |||
} | |||
|
|||
// This runs the terraform in the terraform template directory. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this comment is not true anymore with this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the comment also mention that the tfstate file will be persisted on the disk.
@wking No, the terraform.state will be persisted into the cluster dir too, but it's done by the asset store when it's resolving the dependency. |
In order to be able to use openshift-install to launch multiple clusters we need to create a working dir for each invocation. Here we create a tmp dir that has the terraform.tfvars file and invoke the cluster within the dir. The dir will be removed after the invocation is done.
7f3ae0a
to
408c066
Compare
/approve (assuming the tests are a flake but haven't checked) |
/retest |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: abhinavdahiya, steveeJ, yifan-gu The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
From [1]: If dir is the empty string, TempDir uses the default directory for temporary files (see os.TempDir). so there's no point in us calling TempDir() directly. The explicit call is from 408c066 (asset/cluster: Invoke terraform in a temp dir, 2018-09-24, openshift#319). [1]: https://golang.org/pkg/io/ioutil/#TempDir
In order to be able to use openshift-install to launch multiple
clusters we need to create a working dir for each invocation.
Here we create a tmp dir that has the terraform.tfvars file and
invoke the cluster within the dir.
The dir will be removed after the invocation is done.