Bug 2190308

Summary: [OSP 16.2] upload-swift-artifacts not able to properly fetch Swift's internal endpoint url
Product: Red Hat OpenStack Reporter: Flavio Piccioni <fpiccion>
Component: openstack-tripleo-commonAssignee: Takashi Kajinami <tkajinam>
Status: ON_QA --- QA Contact: David Rosenfeld <drosenfe>
Severity: medium Docs Contact:
Priority: medium    
Version: 16.2 (Train)CC: jslagle, mburns, slinaber, tkajinam
Target Milestone: z6Keywords: Triaged
Target Release: 16.2 (Train on RHEL 8.4)   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: openstack-tripleo-common-11.7.1-2.20230711015219.6371211.el8ost Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Flavio Piccioni 2023-04-27 21:26:55 UTC
Description of problem:

/usr/bin/upload-swift-artifacts fetches Swift's internal endpoint url by using following syntax:

# This works with newer openstackclient which displays the endpoints in list
SWIFT_INTERNAL_URL=$(openstack endpoint list | grep swift | grep internal | sed -e "s|.*\(http.*\)://\([^/]*\)/.*|\1://\2|" || true)

if [ -z "$SWIFT_INTERNAL_URL" ]; then
    # fallback to old openstack client 'show' which displays all the URLs
    SWIFT_INTERNAL_URL=$(openstack endpoint show swift | grep internalurl | sed -e "s|.*\(http.*\)://\([^/]*\)/.*|\1://\2|")
fi

This will lead to problems (with newer openstackclient which displays the endpoints in list) in case endpoints urls contain "internal" string, like in the example:

(undercloud) [stack@undercloud ~]$ openstack endpoint list | grep swift | grep internal
| 78e4f1f5225a413b92eaf1e589bda3e8 | regionOne | swift            | object-store              | True    | internal  | http://ip:8080/v1/AUTH_%(tenant_id)s                              |
| 87c0880f07b045f1a473e1a1051b30bf | regionOne | swift            | object-store              | True    | public    | https://public.undercloud.internal:13808/v1/AUTH_%(tenant_id)s |



Version-Release number of selected component (if applicable):
RHOSP 16.2
python3-tripleo-common-11.7.1-2.20230308005004.99d0f05.el8ost.noarch


Steps to Reproduce:
1. configure different swift's endpoints containing "internal" string 
2. invoke 'upload-swift-artifacts' (in this specific case customer is running 'upload-puppet module' to install a 3d party tool like TrilioVault)
3. verify the DeployArtifactURLs section in the created /home/stack/.tripleo/environments/puppet-modules-url.yaml

Actual results:
an invalid /home/stack/.tripleo/environments/puppet-modules-url.yaml will be created

Expected results:
/usr/bin/upload-swift-artifacts being able to properly get SWIFT_INTERNAL_URL

Additional info:

maybe this could be a possible workaround:
SWIFT_INTERNAL_URL=$(openstack endpoint list --interface internal --service swift -c URL -f value | sed -e "s|.*\(http.*\)://\([^/]*\)/.*|\1://\2|" || true)