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

OpenStack: get rid of swift temp urls #2311

Merged
merged 2 commits into from
Oct 22, 2019

Conversation

Fedosin
Copy link
Contributor

@Fedosin Fedosin commented Sep 4, 2019

Since not all the configurations of OSP support Swift temp urls, we have to find another way that will work on all supported clouds.

To create a unified solution we can use the ACL mechanism to allow public access to the ignition file, but deny access to the list of container files. From a technical point of view, it looks like this: ".r:*", but no ".rlistings".
This allows anybody to download bootstrap ignition file. However, to do this, the exact name of the object must be known since users cannot list the objects in the container.

The last step is to randomize the file name so that it cannot be matched - now it is hardcoded to "bootstrap.ign"

The lifetime of such a file will be short, about 10 minutes necessary for bootstrapping. Further this file will be automatically removed by Terraform at the moment of bootstrap machine destruction.

This way we can achieve the same effect as temp url, which will work on all types of storage.

@openshift-ci-robot openshift-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 4, 2019
@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 4, 2019
@Fedosin
Copy link
Contributor Author

Fedosin commented Sep 4, 2019

/hold

we need to agree that we need this patch at 4.2

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 4, 2019
if svc.Type == "object-store" {
for _, e := range svc.Endpoints {
if e.Interface == "public" {
swiftPublicURL = e.URL
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't you break here? why going over the rest?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep, you're right

@Fedosin Fedosin changed the title OpenStack: get rid of swift temp urls Bug 1749367: OpenStack: get rid of swift temp urls Sep 5, 2019
@openshift-ci-robot openshift-ci-robot added the bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. label Sep 5, 2019
@openshift-ci-robot
Copy link
Contributor

@Fedosin: This pull request references Bugzilla bug 1749367, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker.

In response to this:

Bug 1749367: OpenStack: get rid of swift temp urls

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

@Fedosin: This pull request references Bugzilla bug 1749367, which is valid.

In response to this:

Bug 1749367: OpenStack: get rid of swift temp urls

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.

@Fedosin
Copy link
Contributor Author

Fedosin commented Sep 5, 2019

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 5, 2019
@MartijnStraatman
Copy link

I pulled this PR locally and tried to use it. First run was sucessfull. Second fails with this error:

time="2019-09-05T13:48:54-04:00" level=error msg="Error: Error creating OpenStack container object: parse https://<url>/swift/v1/<token>/os-test-tgb8j/aDAT#dtzs2%[Vm%G: invalid URL escape \"%[V\""
time="2019-09-05T13:48:54-04:00" level=error
time="2019-09-05T13:48:54-04:00" level=error msg="  on ../../../tmp/openshift-install-026823105/bootstrap/main.tf line 54, in resource \"openstack_objectstorage_object_v1\" \"ignition\":"
time="2019-09-05T13:48:54-04:00" level=error msg="  54: resource \"openstack_objectstorage_object_v1\" \"ignition\" {"
time="2019-09-05T13:48:54-04:00" level=error
time="2019-09-05T13:48:54-04:00" level=error
time="2019-09-05T13:48:54-04:00" level=fatal msg="failed to fetch Cluster: failed to generate asset \"Cluster\": failed to create cluster: failed to apply using Terraform"

@Fedosin
Copy link
Contributor Author

Fedosin commented Sep 5, 2019

I pulled this PR locally and tried to use it. First run was sucessfull. Second fails with this error:

time="2019-09-05T13:48:54-04:00" level=error msg="Error: Error creating OpenStack container object: parse https://<url>/swift/v1/<token>/os-test-tgb8j/aDAT#dtzs2%[Vm%G: invalid URL escape \"%[V\""
time="2019-09-05T13:48:54-04:00" level=error
time="2019-09-05T13:48:54-04:00" level=error msg="  on ../../../tmp/openshift-install-026823105/bootstrap/main.tf line 54, in resource \"openstack_objectstorage_object_v1\" \"ignition\":"
time="2019-09-05T13:48:54-04:00" level=error msg="  54: resource \"openstack_objectstorage_object_v1\" \"ignition\" {"
time="2019-09-05T13:48:54-04:00" level=error
time="2019-09-05T13:48:54-04:00" level=error
time="2019-09-05T13:48:54-04:00" level=fatal msg="failed to fetch Cluster: failed to generate asset \"Cluster\": failed to create cluster: failed to apply using Terraform"

yeah, we need to use alphanumeric characters for the object name. Thank you for finding this!

@openshift-ci-robot openshift-ci-robot removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 5, 2019
@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 5, 2019
@Fedosin
Copy link
Contributor Author

Fedosin commented Sep 6, 2019

/test e2e-aws-upgrade

1 similar comment
@Fedosin
Copy link
Contributor Author

Fedosin commented Sep 6, 2019

/test e2e-aws-upgrade

@Fedosin
Copy link
Contributor Author

Fedosin commented Sep 9, 2019

/test e2e-libvirt

@sdodson
Copy link
Member

sdodson commented Sep 9, 2019

@celebdor PTAL or delegate to someone else for review

@tomassedovic
Copy link
Contributor

/assign

I'm testing and reviewing it as we speak.

@tomassedovic
Copy link
Contributor

Okay, I like it. I would really prefer if we kept using Swift temp urls since their behaviour and security profile are well understood, but not supporting OSP 13 + Ceph's RADOS Gateway would cut off a significant portion of the production users.

That said, I am no security expert and as such I am a little nervous about this change -- especially this late in the game.

To the best of my abilities, I've verified that:

There are some things I can see to make it even more solid:

  1. Use the random_password resource instead of random_string. They should behave identically, but the password one is not echoed in any of the Terraform logs which means it won't leak in the CI (https://www.terraform.io/docs/providers/random/r/password.html)
  2. Consider setting a timeout (the delete_after property) on the bootstrap ignition object (https://www.terraform.io/docs/providers/openstack/r/objectstorage_object_v1.html#delete_after). This will make the ignition inaccessible even if the bootstrap resources never get deleted (e.g. in the case of a failure). Probably not a huge issue, just tightening up.

I am tentatively in favour of this but I'd like to hold off from lgtm before more people have their say.

//cc @mandre (what do you think about the risks present here) and @racedo (what do you think about the impact of not shipping this feature in 4.2)

Copy link
Contributor

@celebdor celebdor left a comment

Choose a reason for hiding this comment

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

I agree with Tomáš' suggestions.

@abhinavdahiya
Copy link
Contributor

/test e2e-gcp

DomainName: domainName,
}

serviceCatalog, err := tokens.Create(conn, &authOptions).ExtractServiceCatalog()
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, i'm not sure what this does ? but does it create some resource that needs to be cleaned up on destroy?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here we want to obtain Swift public endpoint... By design this should be done by using https://www.terraform.io/docs/providers/openstack/d/identity_endpoint_v3.html but OpenStack default policies forbid to use this API for regular users.
On the other hand when you authenticate in OpenStack (i.e. get a token) it includes the whole service catalog in the output json. So we are able to parse it and get the endpoint from there https://docs.openstack.org/api-ref/identity/v3/?expanded=token-authentication-with-scoped-authorization-detail#token-authentication-with-scoped-authorization
In short the algorithm is:

  1. Authenticate in OpenStack: tokens.Create(..)
  2. Parse the token and extract the service catalog: ExtractServiceCatalog()
  3. Iterate through the catalog and find public endpoint for object-store.

Unfortunately this feature is not supported by Terraform so I had to implement it here. No resources are created we just get endpoint data from OpenStack.

Btw, we do the same thing for Octavia service: https://github.com/openshift/installer/blob/master/pkg/asset/installconfig/openstack/openstack.go#L141-L152

return swiftPublicURL, nil
}

func getServiceCatalog(cloud string) (*tokens.ServiceCatalog, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

would love to see some comments on the function regarding what it does.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -62,3 +73,69 @@ func TFVars(masterConfig *v1alpha1.OpenstackProviderSpec, cloud string, external

return json.MarshalIndent(cfg, "", " ")
}

func getSwiftPublicURL(cloud string) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Oct 22, 2019
The new version contains random_password module required by OpenStack
Since not all the configurations of OSP support Swift temp urls, we
have to find another way that will work on all supported clouds.

To create a unified solution we can use the ACL mechanism to allow
public access to the file, but deny access to the list of container files.
From a technical point of view, it looks like this: ".r:*", but no ".rlistings".
This allows anybody to download the ignition file. However, to do this, the
exact name of the object must be known since users cannot list the objects in
the container.

The last step is to randomize the file name so that it cannot be matched - now it
is hardcoded to "bootstrap.ign"

The lifetime of such a file will be short, about 10 minutes necessary for
bootstrapping. Further this file will be automatically removed by Terraform at
the moment of bootstrap machine destruction.

This way we can achieve the same effect as temp url, which will work on all types
of storage.
@Fedosin
Copy link
Contributor Author

Fedosin commented Oct 22, 2019

/test e2e-openstack

@Fedosin
Copy link
Contributor Author

Fedosin commented Oct 22, 2019

/test e2e-aws

@Fedosin
Copy link
Contributor Author

Fedosin commented Oct 22, 2019

/test e2e-openstack

@Fedosin
Copy link
Contributor Author

Fedosin commented Oct 22, 2019

/test e2e-aws-disruptive

@openshift-ci-robot
Copy link
Contributor

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

Test name Commit Details Rerun command
ci/prow/e2e-aws-scaleup-rhel7 9a8a235 link /test e2e-aws-scaleup-rhel7
ci/prow/e2e-aws-disruptive 9a8a235 link /test e2e-aws-disruptive

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.

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

8d04568 LGTM

/approve

while the rest i'll leave upto the openstack team to review

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 22, 2019
@iamemilio
Copy link

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 22, 2019
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: abhinavdahiya, Fedosin, iamemilio, mandre

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit 9b594ab into openshift:master Oct 22, 2019
@Fedosin
Copy link
Contributor Author

Fedosin commented Oct 23, 2019

/cherrypick release-4.2

@openshift-cherrypick-robot

@Fedosin: #2311 failed to apply on top of branch "release-4.2":

Applying: OpenStack: get rid of swift temp urls
error: Failed to merge in the changes.
Using index info to reconstruct a base tree...
M	data/data/openstack/bootstrap/main.tf
M	data/data/openstack/bootstrap/variables.tf
M	data/data/openstack/main.tf
M	data/data/openstack/variables-openstack.tf
M	docs/user/openstack/README.md
M	pkg/tfvars/openstack/openstack.go
Falling back to patching base and 3-way merge...
Auto-merging pkg/tfvars/openstack/openstack.go
CONFLICT (content): Merge conflict in pkg/tfvars/openstack/openstack.go
Auto-merging docs/user/openstack/README.md
CONFLICT (content): Merge conflict in docs/user/openstack/README.md
Auto-merging data/data/openstack/variables-openstack.tf
Auto-merging data/data/openstack/main.tf
Auto-merging data/data/openstack/bootstrap/variables.tf
Auto-merging data/data/openstack/bootstrap/main.tf
Patch failed at 0002 OpenStack: get rid of swift temp urls

In response to this:

/cherrypick release-4.2

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.

@MartijnStraatman
Copy link

MartijnStraatman commented Oct 30, 2019

will this PR be available in 4.2? If we install 4.2 by compiling the 4.2 release this feature seems to be missing. Maybe due to the merge-conflict above?

@Fedosin Fedosin deleted the no_temp_urls branch November 1, 2019 11:17
alaypatel07 pushed a commit to alaypatel07/installer that referenced this pull request Nov 13, 2019
With openshift#2311 being merged, and having removed the need for Swift tempurls,
the issue is no longer afflicting OpenStack installations.

Ref.: openshift#2311
vrutkovs pushed a commit to vrutkovs/installer that referenced this pull request Dec 2, 2019
With openshift#2311 being merged, and having removed the need for Swift tempurls,
the issue is no longer afflicting OpenStack installations.

Ref.: openshift#2311
jhixson74 pushed a commit to jhixson74/installer that referenced this pull request Dec 6, 2019
With openshift#2311 being merged, and having removed the need for Swift tempurls,
the issue is no longer afflicting OpenStack installations.

Ref.: openshift#2311
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.