Skip to content

Commit a73ddcd

Browse files
committed
script/stackenv: Don't set 'OS_SYSTEM_SCOPE' until necessary
We were setting OS_SYSTEM_SCOPE in some of the functional ironic tests. This was resulting in the following errors when attempting to create resources: Authentication cannot be scoped to multiple targets. Pick one of: project, domain, trust, system or unscoped Unfortunately, because we weren't setting 'errexit' ('set -e') this wasn't being noticed, but we can "correct" things now. I say "correct" because, adding to the misfortune, how we fix this is technically incorrect - you should have project-scoped configuration *or* system-scoped, not both - but since we don't yet have the infrastructure to switch between sets of auth info on a test-by-test basis, we need to do a Bad Thing. Hopefully this will be a short-lived thing. Signed-off-by: Stephen Finucane <[email protected]>
1 parent 930d18c commit a73ddcd

2 files changed

Lines changed: 27 additions & 13 deletions

File tree

.github/workflows/functional-baremetal.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,24 @@ jobs:
1515
openstack_version: "master"
1616
ubuntu_version: "22.04"
1717
# NOTE(dtantsur): this forces running tests with a system scope
18-
# token, which is required for certain actions. Use "all" on
19-
# versions starting with 2024.1.
20-
os_system_scope: "all"
18+
# token, which is required for certain actions. Use it on versions
19+
# starting with 2024.1.
20+
use_system_scope: true
2121
additional_services: "openstack-cli-server"
2222
- name: "caracal"
2323
openstack_version: "stable/2024.1"
2424
ubuntu_version: "22.04"
25-
os_system_scope: "all"
25+
use_system_scope: true
2626
additional_services: ""
2727
- name: "bobcat"
2828
openstack_version: "stable/2023.2"
2929
ubuntu_version: "22.04"
30-
os_system_scope: ""
30+
use_system_scope: false
3131
additional_services: ""
3232
- name: "antelope"
3333
openstack_version: "stable/2023.1"
3434
ubuntu_version: "22.04"
35-
os_system_scope: ""
35+
use_system_scope: false
3636
additional_services: ""
3737
runs-on: ubuntu-${{ matrix.ubuntu_version }}
3838
name: Deploy OpenStack ${{ matrix.name }} with Ironic and run baremetal acceptance tests
@@ -98,8 +98,8 @@ jobs:
9898
DEVSTACK_PATH: ${{ github.workspace }}/devstack
9999
PACKAGE: "./internal/acceptance/openstack/baremetal/..."
100100
OS_BRANCH: ${{ matrix.openstack_version }}
101-
# TODO(dtantsur): default to "all" when no longer supporting versions before 2024.1
102-
OS_SYSTEM_SCOPE: ${{ matrix.os_system_scope }}
101+
# TODO(dtantsur): default to true when no longer supporting versions before 2024.1
102+
USE_SYSTEM_SCOPE: ${{ matrix.use_system_scope }}
103103
- name: Generate logs on failure
104104
run: ./script/collectlogs
105105
if: failure()

script/stackenv

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,25 @@
77
DEVSTACK_PATH=${DEVSTACK_PATH:-/opt/stack/new/devstack}
88
pushd $DEVSTACK_PATH
99
source openrc admin admin
10+
11+
if [[ "${USE_SYSTEM_SCOPE:-}" == "true" ]]; then
12+
# use system-scoped tokens
13+
echo export OS_SYSTEM_SCOPE=all >> openrc
14+
fi
15+
# TODO: This should only be set when using project-scoped tokens (and we should
16+
# unsetting things like OS_PROJECT_NAME and OS_PROJECT_DOMAIN_ID when not using
17+
# these) but our tests require both which means we need to export both. This
18+
# causes OSC to (correctly) fail since keystoneauth (which is handling
19+
# authentication for OSC and most other clients) can't tell if we want project-
20+
# or system-scoped tokens. As such, post running this script, the 'openrc' file
21+
# will no longer be usable with OSC or other clients.
22+
#
23+
# The long-term fix for this likely involves a mechanism to switch between
24+
# different sets of auth info on a test-by-test basis. Achieving this almost
25+
# certainly means switching our tests to use clouds.yaml with well-known cloud
26+
# names rather than openrc file currently used.
27+
echo export OS_DOMAIN_ID=default >> openrc
28+
1029
openstack flavor create m1.acctest --id 99 --ram 512 --disk 10 --vcpu 1 --ephemeral 10
1130
openstack flavor create m1.resize --id 98 --ram 512 --disk 11 --vcpu 1 --ephemeral 10
1231
openstack keypair create magnum
@@ -28,12 +47,7 @@ echo export OS_EXTGW_ID="$_EXTGW_ID" >> openrc
2847
echo export OS_POOL_NAME="public" >> openrc
2948
echo export OS_FLAVOR_ID=99 >> openrc
3049
echo export OS_FLAVOR_ID_RESIZE=98 >> openrc
31-
echo export OS_DOMAIN_ID=default >> openrc
3250
echo export OS_MAGNUM_IMAGE_ID="$_MAGNUM_IMAGE_ID" >> openrc
3351
echo export OS_MAGNUM_KEYPAIR=magnum >> openrc
3452
source openrc admin admin
35-
if [[ "${OS_SYSTEM_SCOPE:-}" == "all" ]]; then
36-
unset PROJECT_NAME
37-
unset TENANT_NAME
38-
fi
3953
popd

0 commit comments

Comments
 (0)