Skip to content

Commit

Permalink
fix: Prevent duplicate '/v3' in Keystone URL for Heat and update Helm…
Browse files Browse the repository at this point in the history
… overrides with new Heat image (rackerlabs#532)

* Add username to RabbitMQ secrets for Magnum and Barbican

* Adjust layout to correctly position Application Credentials tab

* fix: Avoid duplicate '/v3' in Keystone endpoint URL for Heat
  • Loading branch information
sowm9802 authored Nov 8, 2024
1 parent af9efa3 commit 37d0282
Show file tree
Hide file tree
Showing 5 changed files with 183 additions and 7 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/release-heat-rxt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#
name: Create and Publish a Heat RXT Image

on:
push:
paths:
- '.github/workflows/release-heat-rxt.yml'
- 'Containerfiles/HeatRXT-Containerfile'
branches:
- development
- main
workflow_dispatch:
inputs:
imageTag:
description: 'Set tag for the image'
required: true
default: '2024.1-ubuntu_jammy'
type: choice
options:
- 2024.1-ubuntu_jammy

# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
jobs:
build-and-push-image:
runs-on: ubuntu-latest
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
- name: Dynamically set MY_DATE environment variable
run: echo "MY_DATE=$(date +%s)" >> $GITHUB_ENV
- name: Build and push Docker image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
file: Containerfiles/HeatRXT-Containerfile
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/heat-rxt:${{ github.event.inputs.imageTag }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/heat-rxt:${{ github.event.inputs.imageTag }}-${{ env.MY_DATE }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ github.event.inputs.imageTag }}
41 changes: 41 additions & 0 deletions .github/workflows/smoke-heat-rxt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#
name: Run build check for the Heat RXT image

on:
pull_request:
paths:
- Containerfiles/HeatRXT-Containerfile

# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
jobs:
build-and-push-image:
runs-on: ubuntu-latest
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Docker image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
file: Containerfiles/HeatRXT-Containerfile
push: false
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/heat-rxt:2024.1-ubuntu_jammy
build-args: |
VERSION=2024.1-ubuntu_jammy
13 changes: 13 additions & 0 deletions Containerfiles/HeatRXT-Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ARG VERSION=master-ubuntu_jammy
FROM openstackhelm/heat:${VERSION} as build
RUN apt-get update && apt-get install -y git && apt clean
RUN /var/lib/openstack/bin/pip install git+https://opendev.org/openstack/heat.git@stable/2024.1
RUN /var/lib/openstack/bin/pip install --upgrade --force-reinstall pip
RUN find /var/lib/openstack -regex '^.*\(__pycache__\|\.py[co]\)$' -delete

FROM openstackhelm/heat:${VERSION}
COPY --from=build /var/lib/openstack/. /var/lib/openstack/
COPY Containerfiles/patches/heat_keystone_v3_patch.diff /tmp/heat_keystone_v3_patch.diff
RUN apt-get update && apt-get install -y git
RUN cd /var/lib/openstack/lib/python3.10/site-packages/ && git apply /tmp/heat_keystone_v3_patch.diff
RUN rm /tmp/heat_keystone_v3_patch.diff
55 changes: 55 additions & 0 deletions Containerfiles/patches/heat_keystone_v3_patch.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
diff --git a/heat/engine/clients/os/keystone/heat_keystoneclient.py b/heat/engine/clients/os/keystone/heat_keystoneclient.py
index 2cf8ee997..cf6d88b9d 100644
--- a/heat/engine/clients/os/keystone/heat_keystoneclient.py
+++ b/heat/engine/clients/os/keystone/heat_keystoneclient.py
@@ -600,14 +600,14 @@ class KsClientWrapper(object):
auth_ref = self.context.auth_plugin.get_access(
self.session)
if hasattr(auth_ref, "service_catalog"):
- unversioned_sc_auth_uri = (
- auth_ref.service_catalog.get_urls(
- service_type='identity',
- interface=ks_endpoint_type))
- if len(unversioned_sc_auth_uri) > 0:
- sc_auth_uri = (
- unversioned_sc_auth_uri[0] + "/v3")
- return sc_auth_uri
+ keystone_urls = auth_ref.service_catalog.get_urls(
+ service_type='identity',
+ interface=ks_endpoint_type)
+ if keystone_urls:
+ keystone_url = keystone_urls[0].rstrip('/')
+ if not keystone_url.endswith('/v3'):
+ keystone_url += "/v3"
+ return keystone_url
except ks_exception.Unauthorized:
LOG.error("Keystone client authentication failed")
return fallback_endpoint
diff --git a/heat/tests/clients/test_heat_client.py b/heat/tests/clients/test_heat_client.py
index a72e49cc3..49c985a26 100644
--- a/heat/tests/clients/test_heat_client.py
+++ b/heat/tests/clients/test_heat_client.py
@@ -1528,6 +1528,23 @@ class KeystoneClientTest(common.HeatTestCase):
'http://server.public.test:5000/v3')
cfg.CONF.clear_override('server_keystone_endpoint_type')

+ def test_server_keystone_endpoint_url_config_with_version(self):
+ """Return non fallback url path."""
+ cfg.CONF.set_override('server_keystone_endpoint_type', 'public')
+ ctx = utils.dummy_context()
+ ctx.trust_id = None
+ heat_ks_client = heat_keystoneclient.KeystoneClient(ctx)
+ fallback_url = 'http://server.fallback.test:5000/v3'
+ auth_ref = heat_ks_client.context.auth_plugin.get_access(
+ heat_ks_client.session)
+ auth_ref.service_catalog.get_urls = mock.MagicMock()
+ auth_ref.service_catalog.get_urls.return_value = [
+ 'http://server.public.test:5000/v3']
+ self.assertEqual(
+ heat_ks_client.server_keystone_endpoint_url(fallback_url),
+ 'http://server.public.test:5000/v3')
+ cfg.CONF.clear_override('server_keystone_endpoint_type')
+
def test_server_keystone_endpoint_url_no_config(self):
"""Return fallback as no config option specified."""
ctx = utils.dummy_context()
14 changes: 7 additions & 7 deletions base-helm-configs/heat/heat-helm-overrides.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ images:
ks_user: "docker.io/openstackhelm/heat:2024.1-ubuntu_jammy"
ks_service: "docker.io/openstackhelm/heat:2024.1-ubuntu_jammy"
ks_endpoints: "docker.io/openstackhelm/heat:2024.1-ubuntu_jammy"
heat_db_sync: "docker.io/openstackhelm/heat:2024.1-ubuntu_jammy"
heat_api: "docker.io/openstackhelm/heat:2024.1-ubuntu_jammy"
heat_cfn: "docker.io/openstackhelm/heat:2024.1-ubuntu_jammy"
heat_cloudwatch: "docker.io/openstackhelm/heat:2024.1-ubuntu_jammy"
heat_engine: "docker.io/openstackhelm/heat:2024.1-ubuntu_jammy"
heat_engine_cleaner: "docker.io/openstackhelm/heat:2024.1-ubuntu_jammy"
heat_purge_deleted: "docker.io/openstackhelm/heat:2024.1-ubuntu_jammy"
heat_db_sync: "ghcr.io/rackerlabs/genestack/heat-rxt:2024.1-ubuntu_jammy"
heat_api: "ghcr.io/rackerlabs/genestack/heat-rxt:2024.1-ubuntu_jammy"
heat_cfn: "ghcr.io/rackerlabs/genestack/heat-rxt:2024.1-ubuntu_jammy"
heat_cloudwatch: "ghcr.io/rackerlabs/genestack/heat-rxt:2024.1-ubuntu_jammy"
heat_engine: "ghcr.io/rackerlabs/genestack/heat-rxt:2024.1-ubuntu_jammy"
heat_engine_cleaner: "ghcr.io/rackerlabs/genestack/heat-rxt:2024.1-ubuntu_jammy"
heat_purge_deleted: "ghcr.io/rackerlabs/genestack/heat-rxt:2024.1-ubuntu_jammy"
test: docker.io/xrally/xrally-openstack:2.0.0
rabbit_init: docker.io/rabbitmq:3.7-management
dep_check: quay.io/airshipit/kubernetes-entrypoint:v1.0.0
Expand Down

0 comments on commit 37d0282

Please sign in to comment.