Skip to content

Commit e3ca7c6

Browse files
committed
Add OSC plugins to container
This commit changes our container image because it's currently missing almost all the OSC plugins, unlike the `openstackclient` image. In this patch we ensure the image includes the plugins by: * Adding the plugins to the project dependencies in the `osc-plugin` dependency group. * Changing the source for all our openstack related packages, so instead of using PyPi to install them we use RPMs by using the `openstackclient` container image as the base. * We use the Centos 10 base image of the `openstackclient` container so it has Python 3.12 instead of 3.9 that is in the Centos 9 container (quay.io/podified-antelope-centos9/openstack-openstackclient:current-podified) because the MCP python library has a minimum requirement of Python 3.10. This not only resolves the missing plugins, but also ensures that the packages used are not coming from PyPi, facilitating a more secure downstream release. Available plugins are sent as part of the `openstack-cli` MCP tool description to help LLMs know what is installed, as they may assume only basic commands are available. We also update the allowed commands on read-only mode.
1 parent b18c4c7 commit e3ca7c6

6 files changed

Lines changed: 1984 additions & 1489 deletions

File tree

Containerfile

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
FROM registry.access.redhat.com/ubi9/python-312:latest AS builder
1+
# Use this base image so everything comes from RPM packages (including OSC plugins)
2+
ARG BUILDER_IMAGE=quay.rdoproject.org/podified-master-centos10/openstack-openstackclient:current-tested
3+
ARG BASE_IMAGE=quay.rdoproject.org/podified-master-centos10/openstack-openstackclient:current-tested
4+
5+
FROM $BUILDER_IMAGE AS builder
26

37
WORKDIR /app
48

@@ -7,7 +11,30 @@ COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
711

812
# Copy dependency manifests and README first (build backend needs README.md).
913
# Dependency layer is reused when only application code changes.
10-
COPY pyproject.toml uv.lock README.md ./
14+
COPY --chown=cloud-admin:cloud-admin pyproject.toml uv.lock README.md ./
15+
16+
# Using `--no-install-package` in `uv sync` for these 3 packages only prevents
17+
# the top level package from installing, not their dependencies, installing
18+
# incompatible versions of the dependencies.
19+
RUN cat <<EOF >> pyproject.toml
20+
[tool.uv]
21+
exclude-dependencies = [
22+
"openstackclient",
23+
"python-openstackclient",
24+
"stevedore"
25+
]
26+
EOF
27+
28+
# This should be safe because uv’s resolver is highly conservative and should
29+
# keep every existing package pinned to its current locked version.
30+
# Checked this with `uv lock --dry-run`
31+
RUN uv lock
32+
33+
# Create the virtual environment enabling system's site-packages (RPM packages
34+
# from base container) since `uv sync` doesn't support it.
35+
RUN uv venv --system-site-packages /app/.venv
36+
37+
# Install dependencies but without the packages that come from the base image
1138
RUN uv sync --frozen --no-dev --no-editable --no-install-project
1239

1340
# Copy application code and install the package into the venv.
@@ -20,7 +47,7 @@ RUN curl -o oc.tar.gz https://mirror.openshift.com/pub/openshift-v4/clients/ocp/
2047
rm oc.tar.gz
2148

2249
# Final stage: smaller image without uv or build tools.
23-
FROM registry.access.redhat.com/ubi9/python-312:latest
50+
FROM $BASE_IMAGE
2451

2552
LABEL com.redhat.component="rhos-ls-mcps" \
2653
name="openstack-lightspeed/rhos-mcps" \

pyproject.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,22 @@ dev = [
2525
"pre-commit>=4.6.0"
2626
]
2727

28+
osc-plugins = [
29+
"osc-placement",
30+
"python-barbicanclient",
31+
"python-designateclient",
32+
"python-glanceclient",
33+
"python-heatclient",
34+
"python-ironicclient",
35+
"python-ironic-inspector-client",
36+
"python-manilaclient",
37+
"python-observabilityclient",
38+
"python-octaviaclient",
39+
"aodhclient",
40+
"python-cloudkittyclient",
41+
"python-watcherclient",
42+
]
43+
2844
[build-system]
2945
requires = ["uv_build>=0.11.16,<0.12"]
3046
build-backend = "uv_build"

scripts/allow-deny-list.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,11 @@
151151
"metric_benchmark measures add",
152152
"metric_measures_batch-metrics",
153153
"metric_measures_batch-resources-metrics",
154+
"metric_clean-tombstones",
155+
"metric_snapshot",
156+
"rating_scope_patch",
157+
"share_service_ensure_shares",
158+
"share_replica_resync",
154159
# This sounds intrusive: https://docs.openstack.org/senlin/rocky/user/nodes.html#checking-a-node
155160
"cluster_node_check",
156161
}
@@ -183,6 +188,11 @@
183188
"workflow_engine_",
184189
"data_processing_",
185190
"orchestration_",
191+
"observabilityclient_",
192+
"placement_",
193+
"share_",
194+
"alarm_",
195+
"rating_",
186196
}
187197

188198

0 commit comments

Comments
 (0)