Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions latest/openstack-2024.1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ infrastructure_projects:
redis:
tgtd:

# Sources container-images-kolla builds from besides openstack_projects:
# kolla is the git ref of openstack/kolla it checks out, requirements the
# tarball ref of openstack/requirements, named like openstack_projects.
kolla_build:
kolla: unmaintained/2024.1
requirements: unmaintained-2024.1

openstack_projects:
aodh: unmaintained-2024.1
barbican: unmaintained-2024.1
Expand Down
7 changes: 7 additions & 0 deletions latest/openstack-2024.2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ infrastructure_projects:
redis:
tgtd:

# Sources container-images-kolla builds from besides openstack_projects:
# kolla is the git ref of openstack/kolla it checks out, requirements the
# tarball ref of openstack/requirements, named like openstack_projects.
kolla_build:
kolla: 2024.2-eol
requirements: stable-2024.2

openstack_projects:
aodh: stable-2024.2
barbican: stable-2024.2
Expand Down
7 changes: 7 additions & 0 deletions latest/openstack-2025.1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ infrastructure_projects:
tgtd:
valkey:

# Sources container-images-kolla builds from besides openstack_projects:
# kolla is the git ref of openstack/kolla it checks out, requirements the
# tarball ref of openstack/requirements, named like openstack_projects.
kolla_build:
kolla: unmaintained/2025.1
requirements: unmaintained-2025.1

openstack_projects:
aodh: unmaintained-2025.1
barbican: unmaintained-2025.1
Expand Down
7 changes: 7 additions & 0 deletions latest/openstack-2025.2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ infrastructure_projects:
tgtd:
valkey:

# Sources container-images-kolla builds from besides openstack_projects:
# kolla is the git ref of openstack/kolla it checks out, requirements the
# tarball ref of openstack/requirements, named like openstack_projects.
kolla_build:
kolla: stable/2025.2
requirements: stable-2025.2

openstack_projects:
aodh: stable-2025.2
barbican: stable-2025.2
Expand Down
7 changes: 7 additions & 0 deletions latest/openstack-2026.1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ infrastructure_projects:
tgtd:
valkey:

# Sources container-images-kolla builds from besides openstack_projects:
# kolla is the git ref of openstack/kolla it checks out, requirements the
# tarball ref of openstack/requirements, named like openstack_projects.
kolla_build:
kolla: stable/2026.1
requirements: stable-2026.1

openstack_projects:
aodh: stable-2026.1
barbican: stable-2026.1
Expand Down
2 changes: 1 addition & 1 deletion src/osism_drift/drift/kolla_build_conf_unknown_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def run(config, allowlist, verbose: bool = False) -> list[DriftEntry]:
)
template_path = _TEMPLATE.format(r=release)
template = source.read("container_images_kolla", template_path, config)
ref = source.release_to_ref("kolla", release, config)
ref = enablement.kolla_ref(release, config)
keys = kolla_source_keys(
source.read_at_ref("kolla", _SOURCES_PY, ref, config).decode()
)
Expand Down
4 changes: 2 additions & 2 deletions src/osism_drift/drift/kolla_enablement_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
The upstream docker/ universe is the scope filter, so feature flags (which have
no image) are out of scope and no alias table is needed.

Range-aware: the upstream ref per release comes from source.release_to_ref. The
Range-aware: the upstream ref per release comes from enablement.kolla_ref. The
remote is consulted only for the docker/ listing and the ref probe; defaults and
release are read at their pins.
"""
Expand Down Expand Up @@ -44,7 +44,7 @@ def run(config, allowlist, verbose: bool = False) -> list[DriftEntry]:
enabled = enablement.truthy_enables(enablement.osism_enable_flags(config))
drifts = []
for release in enablement.release_range(config):
ref = source.release_to_ref("kolla", release, config)
ref = enablement.kolla_ref(release, config)
buildable = {
enablement.canon(d)
for d in source.list_dir_at_ref(
Expand Down
130 changes: 99 additions & 31 deletions src/osism_drift/drift/kolla_source_ref_phase.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
publishes a tarball for. A later phase being available means the configured
artifact is frozen and the build no longer receives upstream fixes.

The same holds for the two refs in kolla_build: the requirements tarball, and
the openstack/kolla branch container-images-kolla checks out. That branch is
renamed with the release, and opendev publishes a kolla-<phase>-<release>
tarball for it, so the same probe answers it once the branch name
(unmaintained/<R>) is read in tarball form (unmaintained-<R>). A tag such as
2024.2-eol names no phase and is skipped, like a project on its own branch
scheme.

Artifact-driven rather than branch-driven on purpose. The question is which
tarball the build consumes, and probing the published set answers it directly:
no upstream repository owner is needed for every project, and the check
Expand Down Expand Up @@ -131,6 +139,45 @@ def remediation_for(release: str, latest: str) -> str:
)


def build_remediation_for(release: str, latest: str) -> str:
"""Remediation for kolla_build refs, shared per (release, phase).

Names both target spellings, since kolla takes a git branch and
requirements a tarball ref, but no entry name, so kolla and requirements
moving together render as one block.
"""
phase = latest[: -len(release) - 1]
return (
f"set kolla_build in release/latest/openstack-{release}.yml to the "
f"{phase} phase (kolla: {phase}/{release}, requirements: "
f"{phase}-{release}), and drop any downstream patch the newer sources "
f"already carry. Once the release moves on, upstream freezes the old "
f"branch and its tarball, and nothing breaks until the branch is "
f"deleted, so the {phase} phase has to be set deliberately."
)


def _build_refs_as_tarball_refs(build_refs: dict) -> dict:
"""kolla_build in the tarball form scan() compares.

kolla is a git ref (unmaintained/<R>); its tarball is kolla-unmaintained-<R>.
requirements is already a tarball ref. Anything else in the block is not a
source and is ignored.
"""
out = {}
for name in ("kolla", "requirements"):
ref = build_refs.get(name)
if name == "kolla" and ref:
ref = ref.replace("/", "-", 1)
out[name] = ref
return out


def _declared_form(name: str, ref: str) -> str:
"""A tarball-form phase back in the spelling kolla_build.<name> takes."""
return ref.replace("-", "/", 1) if name == "kolla" else ref


def unresolved_remediation(kind: str) -> str:
"""Remediation for refs a failed probe left unverified.

Expand Down Expand Up @@ -218,36 +265,57 @@ def run(config, allowlist, verbose: bool = False) -> list[DriftEntry]:
one entry per ref a failed probe left unverified."""
drifts = []
for release in enablement.release_range(config):
refs = enablement.parse_source_refs(
source.read("release", f"latest/openstack-{release}.yml", config)
)
body = source.read("release", f"latest/openstack-{release}.yml", config)
found_src = f"osism/release latest/openstack-{release}.yml"
result = scan(refs, release, tarball_exists)
for project, configured, latest in result.stale:
d = DriftEntry(
plugin=NAME,
image=project,
alias=project,
expected=latest,
found=configured,
expected_src=EXPECTED_SRC,
found_src=found_src,
remediation=remediation_for(release, latest),
)
drifts.append(allowlist.apply(d))
for project, configured, kind, detail in result.unresolved:
if verbose:
print(f"warning: {detail}", file=sys.stderr)
d = DriftEntry(
plugin=NAME,
image=project,
alias=project,
expected=UNRESOLVED_EXPECTED,
found=configured,
expected_src=EXPECTED_SRC,
found_src=found_src,
summary=UNRESOLVED_SUMMARY,
remediation=unresolved_remediation(kind),
)
drifts.append(allowlist.apply(d))
projects = scan(enablement.parse_source_refs(body), release, tarball_exists)
drifts += _entries(projects, release, found_src, allowlist, verbose)
build = enablement.parse_kolla_build_refs(body)
result = scan(_build_refs_as_tarball_refs(build), release, tarball_exists)
drifts += _entries(
result, release, f"{found_src} kolla_build", allowlist, verbose, build
)
return drifts


def _entries(result, release, found_src, allowlist, verbose, build=None) -> list:
"""DriftEntries for one scan. `build` is the kolla_build block when the
scan covered it: entries then name the key, report the refs in the
spelling the block takes, and carry the kolla_build remediation."""
out = []
for project, configured, latest in result.stale:
if build is None:
image, found, expected = project, configured, latest
remediation = remediation_for(release, latest)
else:
image = f"kolla_build.{project}"
found = build[project]
expected = _declared_form(project, latest)
remediation = build_remediation_for(release, latest)
d = DriftEntry(
plugin=NAME,
image=image,
alias=image,
expected=expected,
found=found,
expected_src=EXPECTED_SRC,
found_src=found_src,
remediation=remediation,
)
out.append(allowlist.apply(d))
for project, configured, kind, detail in result.unresolved:
if verbose:
print(f"warning: {detail}", file=sys.stderr)
image = project if build is None else f"kolla_build.{project}"
d = DriftEntry(
plugin=NAME,
image=image,
alias=image,
expected=UNRESOLVED_EXPECTED,
found=configured if build is None else build[project],
expected_src=EXPECTED_SRC,
found_src=found_src,
summary=UNRESOLVED_SUMMARY,
remediation=unresolved_remediation(kind),
)
out.append(allowlist.apply(d))
return out
3 changes: 2 additions & 1 deletion src/osism_drift/drift/kolla_version_chain_upstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"kolla-ansible template (unwired pins)."
)
INPUT_FILES = [
("release", "latest/openstack-<release>.yml"),
("kolla", "docker (newest resolved ref)"),
("container_image_kolla_ansible", "files/src/templates/versions.yml.j2"),
]
Expand All @@ -41,7 +42,7 @@
def run(config, allowlist, verbose: bool = False) -> list[DriftEntry]:
"""Return unwired-pin drifts: upstream services with no template key."""
newest = sorted(enablement.release_range(config))[-1]
ref = source.release_to_ref("kolla", newest, config)
ref = enablement.kolla_ref(newest, config)
expected_src = f"openstack/kolla/docker/ @ {ref}"
docker_names = source.list_dir_at_ref("kolla", _DOCKER, ref, config, dirs_only=True)
upstream = kolla_docker.parse(docker_names)
Expand Down
31 changes: 31 additions & 0 deletions src/osism_drift/enablement.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,37 @@ def parse_source_refs(body: bytes) -> dict:
return dict(data.get("openstack_projects") or {})


def parse_kolla_build_refs(body: bytes) -> dict:
"""kolla_build as {"kolla": git ref, "requirements": tarball ref}.

These are the two sources container-images-kolla builds from besides
openstack_projects: the openstack/kolla checkout and the
openstack/requirements tarball. A manifest without the block yields {}.
"""
data = yaml.safe_load(body) or {}
return dict(data.get("kolla_build") or {})


def kolla_ref(release: str, config) -> str:
"""The openstack/kolla ref container-images-kolla builds `release` from.

A release_refs override wins, so a pinned snapshot stays pinned. Otherwise
the kolla_build.kolla ref declared in latest/openstack-<release>.yml, which
is what the build checks out. source.release_to_ref() is only the fallback
for a manifest without the key: it probes stable/ first, so during an
unmaintained transition it resolves the frozen stable branch.
"""
override = (config.release_refs.get("kolla") or {}).get(release)
if override:
return override
declared = parse_kolla_build_refs(
source.read("release", f"latest/openstack-{release}.yml", config)
).get("kolla")
if declared:
return declared
return source.release_to_ref("kolla", release, config)


def release_range(config) -> list:
"""Supported releases: config.releases override, else derived from the
osism/release latest/openstack-*.yml file set (sorted)."""
Expand Down
54 changes: 54 additions & 0 deletions tests/kolla_drift/test_enablement.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,3 +564,57 @@ def test_upstream_groupvars_are_read_once_per_ref():
if "/contents/ansible/group_vars/all" in c.request.url
]
assert len(listings) == 1, listings


def test_parse_kolla_build_refs_reads_the_block():
body = b"kolla_build:\n kolla: unmaintained/2025.1\n requirements: unmaintained-2025.1\n"
assert enablement.parse_kolla_build_refs(body) == {
"kolla": "unmaintained/2025.1",
"requirements": "unmaintained-2025.1",
}


def test_parse_kolla_build_refs_is_empty_without_the_block():
assert enablement.parse_kolla_build_refs(b"openstack_projects: {}\n") == {}


def _kolla_ref_stubs(monkeypatch, manifest, release_refs=None):
"""kolla_ref with the release manifest stubbed and release_to_ref recorded."""
from osism_drift import source

probed = []
monkeypatch.setattr(source, "read", lambda repo, path, config: manifest)

def release_to_ref(repo, release, config):
probed.append((repo, release))
return f"stable/{release}"

monkeypatch.setattr(source, "release_to_ref", release_to_ref)
cfg = type("Cfg", (), {"release_refs": release_refs or {}})()
return cfg, probed


def test_kolla_ref_is_the_declared_kolla_build_ref(monkeypatch):
"""What container-images-kolla checks out, not the stable-first probe."""
cfg, probed = _kolla_ref_stubs(
monkeypatch, b"kolla_build:\n kolla: unmaintained/B\n"
)
assert enablement.kolla_ref("B", cfg) == "unmaintained/B"
assert probed == []


def test_kolla_ref_override_wins_over_the_declared_ref(monkeypatch):
"""A pinned snapshot stays pinned."""
cfg, probed = _kolla_ref_stubs(
monkeypatch,
b"kolla_build:\n kolla: unmaintained/B\n",
release_refs={"kolla": {"B": "B-eol"}},
)
assert enablement.kolla_ref("B", cfg) == "B-eol"
assert probed == []


def test_kolla_ref_falls_back_to_the_probe_without_the_key(monkeypatch):
cfg, probed = _kolla_ref_stubs(monkeypatch, b"openstack_projects: {}\n")
assert enablement.kolla_ref("B", cfg) == "stable/B"
assert probed == [("kolla", "B")]
Loading
Loading