-
Notifications
You must be signed in to change notification settings - Fork 1.5k
*: include terraform in the installer binary #797
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
Conversation
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: crawford The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
What's the final size? |
|
Size after this change: v.s. before: |
|
Well within reason. I assume having a vendor tree you splice in as an |
|
I didn't bother looking at vendoring Terraform because I was almost certain that was going to be painful and would take much longer to accomplish. We can always revisit this approach later. |
|
Yeah that's fine. I only bring it up because of previous discussion around OSBS, all I care about right now is something that works. |
|
Curious if this actually passes the tests... /retest |
|
I'm fine with this approach in the short term. 👍 |
|
/retest |
|
|
Instead of requiring that the user has Terraform installed, this now includes the pre-built Terraform binary within the installer. At runtime, the installer unpacks Terraform into the temporary directory and executes it from that location. This also simplifies the version output - since the Terraform version is known at build-time, there is no need to show the user. Lastly, this cleans up some of the log messages so that they don't explicitly refer to Terraform. Including Terraform in the installer adds 18MB to the binary size, bringing the total up to 82MB.
We also need to address the "caching" logic. It's currently just checking to see that terraform exists. It doesn't verify that it is the correct version or architecture. I think if we solve that, it also solves the issue you brought up. |
| fi && | ||
| mkdir -p data/data/bin && | ||
| rm -f data/data/bin/terraform && | ||
| ln -s "../../../${TERRAFORM_BINARY}" data/data/bin/terraform |
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.
@wking do you know a good way of calculating "../../.." from "data/data/bin/terraform"?
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.
I came up with the following, but it may be more effort than it is worth:
diff --git a/hack/get-terraform.sh b/hack/get-terraform.sh
index aae1b69cd..c47aaa11e 100755
--- a/hack/get-terraform.sh
+++ b/hack/get-terraform.sh
@@ -25,6 +25,7 @@ fi &&
TERRAFORM_VERSION="0.11.8" &&
TERRAFORM_URL="https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_${OS}_${ARCH}.zip" &&
TERRAFORM_BINARY=".cache/terraform_${TERRAFORM_VERSION}_${OS}_${ARCH}"
+TERRAFORM_SYMLINK="data/data/bin/terraform"
cd "$(dirname "$0")/.." &&
if [ ! -x "${TERRAFORM_BINARY}" ]
then
@@ -33,6 +34,6 @@ then
curl -L "${TERRAFORM_URL}" | "${FUNZIP}" >"${TERRAFORM_BINARY}" &&
chmod +x "${TERRAFORM_BINARY}"
fi &&
-mkdir -p data/data/bin &&
-rm -f data/data/bin/terraform &&
-ln -s "../../../${TERRAFORM_BINARY}" data/data/bin/terraform
+mkdir -p "$(dirname "${TERRAFORM_SYMLINK}")" &&
+rm -f "${TERRAFORM_SYMLINK}" &&
+ln -s "$(dirname "${TERRAFORM_SYMLINK}" | sed 's_[^/]*_.._g')/${TERRAFORM_BINARY}" "${TERRAFORM_SYMLINK}"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 you know a good way of calculating
"../../.."from"data/data/bin/terraform"?
Well, one way would be to use hardlinks instead of symlinks:
$ rm -f data/data/bin/terraform
$ ls -l .cache/terraform_0.11.8_linux_amd64
-rwxr-xr-x. 1 trking trking 76422048 Dec 6 21:54 .cache/terraform_0.11.8_linux_amd64
$ ln .cache/terraform_0.11.8_linux_amd64 data/data/bin/terraform
$ ls -l .cache/terraform_0.11.8_linux_amd64
-rwxr-xr-x. 2 trking trking 76422048 Dec 6 21:54 .cache/terraform_0.11.8_linux_amd64
$ ls -l data/data/bin/terraform
-rwxr-xr-x. 2 trking trking 76422048 Dec 6 21:54 data/data/bin/terraformSee the <number of links> field changing from 1 to 2 after the ln call.
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.
I assume all of this will always be on the same filesystem, so a hardlink should work. I'll go with that instead.
|
@crawford: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. DetailsInstructions 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. |
| return errors.Wrap(err, "failed to unpack Terraform binary") | ||
| } | ||
|
|
||
| err = os.Chmod(filepath.Join(dir, executablePath), 0555) |
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 will need FromSlash too, and so will exec.Command(filepath.Join(clusterDir, executablePath), args...). In fact, why are we bothering with bin at all? This would be easier if we just had executableFilename = "terraform", or some such. And since we have CI to catch us if we typo an instance, I'd be fine hard-coding "terraform"everywhere and skipping the variable altogether (although I'm also fine with a slash-lessexecutableFilename`).
| // Terraform call itself failed, in which case, details can be found in the | ||
| // output. | ||
| func (ex *executor) execute(clusterDir string, args ...string) error { | ||
| func Execute(clusterDir string, args ...string) error { |
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.
No need to make this public. Can we change this (and the name in the godoc above) to execute?
|
I left a few minor suggestions inline, but I'm fine landing this as-is (after you squash the WIP commit in) and iterating afterwards if you don't want to pick up the suggestions now. |
|
Closing in favor of #822. /close |
|
@crawford: Closed this PR. DetailsIn response to this:
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. |
Instead of requiring that the user has Terraform installed, this now
includes the pre-built Terraform binary within the installer. At
runtime, the installer unpacks Terraform into the temporary directory
and executes it from that location. This also simplifies the version
output - since the Terraform version is known at build-time, there is
no need to show the user. Lastly, this cleans up some of the log
messages so that they don't explicitly refer to Terraform.
Including Terraform in the installer adds 18MB to the binary size,
bringing the total up to 82MB.