Skip to content

fix: compare libvirt ceph secret with the decoded key - #230

Merged
gboutry merged 1 commit into
canonical:mainfrom
Guno327:fix/ensure-secret-compare
Nov 19, 2026
Merged

gboutry merged 1 commit into
canonical:mainfrom
Guno327:fix/ensure-secret-compare

Conversation

@Guno327

@Guno327 Guno327 commented Oct 7, 2026 •

Copy link
Copy Markdown

_set_secret stores the ceph key in libvirt base64-decoded, because nova
encodes it itself. _ensure_secret then compared that stored value against
base64.b64encode(secret_value.encode()), which is base64 applied twice. The
check could never match, so every configure hook took the "wrong value,
replacing" path: it undefined the secret and defined it again.

This compares against base64.b64decode(secret_value), the same form
_set_secret stores. The three _ensure_secret unit tests used a key that is
not valid base64 and a stored value that is not decoded. They matched the
faulty comparison rather than real data, and are corrected.

Assisted-By: Claude Opus 5.5

QA steps

  1. tox -e py3 (the three _ensure_secret tests now use a valid base64 key
    and the decoded stored value), tox -e pep8.
  2. On a hypervisor with a ceph backend, run the configure hook again
    (sudo snap set openstack-hypervisor ceph-access.<backend>.uuid=<same uuid>)
    and check sudo snap logs openstack-hypervisor: the secret is logged as
    having the desired value, not "replacing". sudo openstack-hypervisor.virsh secret-list
    shows the same uuid.

Tested

Live on Sunbeam 2026.1: across snap installs and refreshes, the existing
libvirt secret kept its uuid and was not redefined.

@Guno327
Guno327 force-pushed the fix/ensure-secret-compare branch 3 times, most recently from 8bf7ea8 to 911c357 Compare October 7, 2026 21:50
@Guno327
Guno327 force-pushed the fix/ensure-secret-compare branch 2 times, most recently from 2b4008c to fceb4de Compare November 13, 2026 22:05
Comment thread openstack_hypervisor/hooks.py Resolved
Signed-off-by: guno327 <gunnar.hovik@canonical.com>
@Guno327
Guno327 force-pushed the fix/ensure-secret-compare branch from fceb4de to 98dc25d Compare November 18, 2026 18:56
@Guno327
Guno327 requested a review from Raven-182 November 18, 2026 18:58

@Raven-182 Raven-182 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM

@gboutry
gboutry merged commit e08b3ad into canonical:main Nov 19, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants