Skip to content

support microovn installed after openstack-hypervisor#171

Merged
gboutry merged 2 commits intocanonical:stable/2024.1from
hemanthnakkina:microovn-delay-ocs-start-stable-2024.1
Apr 7, 2026
Merged

support microovn installed after openstack-hypervisor#171
gboutry merged 2 commits intocanonical:stable/2024.1from
hemanthnakkina:microovn-delay-ocs-start-stable-2024.1

Conversation

@hemanthnakkina
Copy link
Copy Markdown
Collaborator

Backport of

#167
#168

Add a network.ovs-managed-by snap config option (values: auto,
microovn, hypervisor) so the charm can declare OVS management mode
independently of the ovn-chassis plug connection state.

Previously is_ovs_external() relied solely on snapctl is-connected
ovn-chassis, which returns False until microovn is installed and the
plug is connected. This caused the snap to start its internal OVS
services even when the operator intended microovn to manage OVS.

Changes:
- Add OVS_MANAGED_BY_AUTO/MICROOVN/HYPERVISOR constants and
  _OVS_MANAGED_BY module-level cache
- Add _set_ovs_managed_by(snap) called at the top of configure() to
  read and cache network.ovs-managed-by before any is_ovs_external()
  calls; invalid values fall back to 'auto' with a warning
- Update is_ovs_external() to honour the config value first, only
  falling through to the plug check in 'auto' mode
- Add _external_ovs_ready(snap) that checks whether the microovn OVS
  socket path exists, mirroring the existing _internal_ovs_ready()
- Extend configure() deferral logic with external_ovs_deferred: when
  network.ovs-managed-by=microovn but microovn is not yet installed
  (socket absent), skip OVN TLS and networking configuration instead
  of hanging on ovs-vsctl commands; the hook retries automatically on
  the next snap set invocation
- Add unit tests for all new code paths

(cherry picked from commit b1ac96e)
When openstack-hypervisor and microovn are deployed simultaneously,
snapd fires the configure hook immediately after snap install — before
the charm has applied any snap config.  At that point
network.ovs-managed-by is still 'auto' and the ovn-chassis plug is not
yet connected, so is_ovs_external() returns False.  This caused
_ensure_internal_ovs_services to start ovs-vswitchd, which creates the
system@ovs-system kernel datapath.  When microovn subsequently tries to
initialise OVS it finds the datapath already in use and fails.

The same issue affects the second configure hook, triggered when the
charm's own install hook calls `snap set network.ovs-managed-by=auto`,
since the identity URL is still the placeholder at that point too.

Fix: before calling _ensure_internal_ovs_services, check whether the
charm has applied its identity configuration.  The guard defers OVS
startup when BOTH identity.auth-url is still the placeholder default
("http://localhost:5000/v3") AND identity.username is unset (None).
Checking both fields ensures the guard still clears correctly for
operators that legitimately run Keystone at http://localhost:5000/v3,
since those deployments will always set identity.username.  Once either
condition is no longer true the guard clears and _ensure_internal_ovs_services
runs normally.

The guard is only active when network.ovs-managed-by is 'auto'.  When
explicitly set to 'hypervisor' the operator's intent is unambiguous and
ovs-vswitchd is started immediately regardless of identity state.

(cherry picked from commit e72c732)
@hemanthnakkina hemanthnakkina marked this pull request as ready for review April 7, 2026 05:43
@gboutry gboutry merged commit 6056c4b into canonical:stable/2024.1 Apr 7, 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.

2 participants