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

Update export_disk_ext.sh #1687

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

eeaton
Copy link

@eeaton eeaton commented Jun 30, 2021

The test on line 22 introduces unexpected errors by testing for access to something different than what's actually needed. I've modified it to test reachability to the Storage API, not www.googleapis.com.

Most enterprise GCP customers will configure firewall and DNS controls for the Restricted VIP. In that environment, the attempt to curl www.googleapis.com will fail, even though Storage and other APIs can be accessed. This forces a weird workaround to change DNS and firewall rules to allow some limited egress to the private VIP, which adds complexity and compromises security. Improving the test condition allows this code to run without forcing weird workarounds.

The test on line 22 introduces unexpected errors by testing for access to something different than what's actually needed. I've modified it to test reachability to the Storage API, not www.googleapis.com.

Most enterprise GCP customers will configure firewall and DNS controls for the Restricted VIP. In that environment, the attempt to curl www.googleapis.com will fail, even though Storage and other APIs can be accessed. This forces a weird workaround to change DNS and firewall rules to allow some limited egress to the private VIP, which adds complexity and compromises security. Improving the test condition allows this code to run without forcing weird workarounds.
@google-oss-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: eeaton
To complete the pull request process, please assign hopkiw after the PR has been reviewed.
You can assign the PR to them by writing /assign @hopkiw 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

@google-oss-robot
Copy link
Collaborator

Hi @eeaton. Thanks for your PR.

I'm waiting for a GoogleCloudPlatform member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

On further review, I realized my initial solution could be brittle because it assumes a GCP public bucket will never change.

In this version, "gsutil ls" is a simple check to list buckets that doesn't take any parameters, but if it fails will indicate that network access or permissions to list buckets are not available.
@zoran15 zoran15 requested review from dntczdx and EricEdens and removed request for gaohannk July 1, 2021 08:34
@zoran15 zoran15 closed this Jul 1, 2021
@zoran15 zoran15 reopened this Jul 1, 2021
@zoran15
Copy link
Contributor

zoran15 commented Jul 1, 2021

The test on line 22 introduces unexpected errors by testing for access to something different than what's actually needed. I've modified it to test reachability to the Storage API, not www.googleapis.com.

Most enterprise GCP customers will configure firewall and DNS controls for the Restricted VIP. In that environment, the attempt to curl www.googleapis.com will fail, even though Storage and other APIs can be accessed. This forces a weird workaround to change DNS and firewall rules to allow some limited egress to the private VIP, which adds complexity and compromises security. Improving the test condition allows this code to run without forcing weird workarounds.

Thanks for the contribution.

In addition to accessing GCS, image export script also does GCE operations. In particular, disk resize using gcloud compute disks resize. This is for temporary disks that hold exported image file before it's being copied to GCS. With this workflow, we still need to ensure we can access GCE API, not only GCS. We can look at doing a more focused API check, i.e. only for Compute Engine.

Added a more robust test condition and error message for both Storage and Compute endpoints.

This test removes the original curl to the Discovery API, which can be accessed without authentication but tests access to an unrelated API.
Instead, this test now checks HTTP Statuscodes for these endpoints. Without specific parameters, the endpoints will return 4XX; that is acceptable because we're yet not testing permission to reach a specific resource. Returning any status code equal to or greater than 200 indicates that at least the VM can communicate to this endpoint.

I've also changed the error message to be more useful. The previous message over-emphasized Private Google Access, which made troubleshooting difficult.
@eeaton
Copy link
Author

eeaton commented Jul 15, 2021

I've suggested a more robust test that checks both compute.googleapis.com and storage.googleapis.com endpoints by checking HTTP status codes. This test will work regardless of whether an enterprise client has configured Firewall and DNS settings for the Restricted VIP. It also doesn't assume the hack of the public bucket as in my earlier commit. Please review, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants