Skip to content

Modernize vaultlocker for python 3.12+ and current hvac APIs - #24

Merged
freyes merged 3 commits into
openstack-charmers:masterfrom
Raven-182:vaultlocker-updates
Jul 21, 2026
Merged

Modernize vaultlocker for python 3.12+ and current hvac APIs#24
freyes merged 3 commits into
openstack-charmers:masterfrom
Raven-182:vaultlocker-updates

Conversation

@Raven-182

@Raven-182 Raven-182 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Updates vaultlocker to support python 3.12+ and current hvac releases.
Context: HVAC is the official python client library for HashiCorp Vault, used to authenticate Vault and interact with its API.

Changes

hvac

  • Replace Client.auth_approle() with Client.auth.approle.login().
    The old auth_approle() method is not available in hvac 1.x or 2.x. hvac 0.10.6 introduced the namespaced AppRole API used here.

    The other hvac calls currently used by vaultlocker still work with hvac 2.x. KV API changes will be handled separately as part of the KV v2 work.

  • Set hvac>=0.10.6 as the minimum supported version.

  • Add a regression test for the AppRole login call.

  • Remove the undeclared six dependency. A clean installation was failing with with ModuleNotFoundError: No module named 'six'

Tests

  • Remove old python 2 and 3 test environments.
  • Add noble, resolute, and latest dependency test environments.
  • Test each dependency profile against Vault 1.8, 1.18, and 2.0.
  • Update the GitHub Actions versions.
  • Update the functional tests to use the namespaced hvac sys and auth.approle APIs and remove deprecated functions hvac.v1
  • Configure the Vault address and root token in CI so the functional tests run against the Vault service container instead of being skipped.
  • Remove the localhost-only AppRole CIDR restriction from the functional test
    • The GitHub Actions runner is reaching the vault service through docker networking rather than directly via 127.0.0.1, so restricting secret IDs to 127.0.0.1/32 cause authentication failures in the CI

Manual Testing

Manually verified the vaultlocker encrypt and decrypt flows against a vault instance.

OPEN-4605

- Replace deprecated `Client.auth_approle()` call with
`Client.auth.approle.login()`.
- Require `hvac>=0.10.6` at minimum, this adds support for `Client.auth.approle.login()`.
- Replace `six.moves.configparser` with `configparser`.

Signed-off-by: Raven Kaur <raven.kaur@canonical.com>
- Drop python 2 and legacy python 3 test environments and require Python
3.12 or newer.
- Add tox and CI coverage for noble, resolute, and latest dependencies on python 3.12 and 3.14
- Remove the OpenStack upper constraints for dependencies
- Test each dependency set against Vault 1.8, 1.18, and 2.0
- Update github action versions

Signed-off-by: Raven Kaur <raven.kaur@canonical.com>
@Raven-182
Raven-182 force-pushed the vaultlocker-updates branch from 02b7194 to c4e8617 Compare July 17, 2026 17:38
@Raven-182
Raven-182 marked this pull request as draft July 17, 2026 17:41
- Replace testcase.TestSkipped(), removed from testtools, with the
  standard self.skipTest().
- Replace deprecated Client methods with supported sys and auth.approle APRs
- Remove approle CIDR restriction causing jobs to fail with `InvalidRequest unauthorized CIDR`
- Set PIFPAF_VAULT_ADDR and PIFPAF_ROOT_TOKEN so functional tests are
 exercised instead of skipping

Assisted by: Claude Sonnet 5
Signed-off-by: Raven Kaur <raven.kaur@canonical.com>
@Raven-182
Raven-182 force-pushed the vaultlocker-updates branch from 01cc41e to d52a799 Compare July 17, 2026 19:25
@Raven-182
Raven-182 marked this pull request as ready for review July 17, 2026 19:38
@freyes
freyes self-requested a review July 17, 2026 22:00

@freyes freyes left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Waiting for the CI results

Comment thread tox.ini
deps = -r{toxinidir}/test-requirements.txt
commands = stestr run "^vaultlocker.tests.unit.*" {posargs}

[testenv:noble]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍

- name: "run functional tests"
env:
PIFPAF_VAULT_ADDR: "http://127.0.0.1:8200"
PIFPAF_ROOT_TOKEN: "testing"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍

Comment thread requirements.txt

pbr>=2.0 # Apache-2.0
hvac
hvac>=0.10.6 # client.auth.approle.login() requires this API

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ubuntu versions have this

 python3-hvac | 0.5.0-0ubuntu1~ubuntu18.04.1 | bionic-backports/universe | all
 python3-hvac | 0.5.0-0ubuntu3               | focal/universe            | all
 python3-hvac | 0.11.2-1                     | jammy/universe            | all
 python3-hvac | 0.11.2-3                     | noble/universe            | all
 python3-hvac | 2.3.0-5                      | resolute/universe         | all
 python3-hvac | 2.4.0-2                      | stonking/universe         | all

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I pinned 0.10.6 as the minimum because it's the first release that introduced client.auth.approle.login() which is the only new API this PR relies on. The distro specific versions are pinned already in distro specific requirements files.
That said, I can raise the general minimum to 0.11.2 if we'd prefer it to align with the oldest supported Ubuntu package rather than the earliest compatible upstream release.

@Raven-182

Copy link
Copy Markdown
Contributor Author

@freyes The current CI jobs have completed, but the remaining checks are from the previous test matrix. Do we need to update the Required checks in the repo to match the new workflow?

@freyes
freyes merged commit 93a600b into openstack-charmers:master Jul 21, 2026
9 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