Skip to content

Allow microovn to install alongside OVS#319

Draft
crypticC0der wants to merge 1 commit intocanonical:mainfrom
crypticC0der:handleaptovs
Draft

Allow microovn to install alongside OVS#319
crypticC0der wants to merge 1 commit intocanonical:mainfrom
crypticC0der:handleaptovs

Conversation

@crypticC0der
Copy link
Copy Markdown
Contributor

If Open vSwitch is installed do not block microovn installation. When microovn.switch is started check if non-snap Open vSwitch is running, if it is shut it down and then prompt the user to disable the non-snap OVS services.

Also expands the switchstart test to ensure this works properly.

@crypticC0der crypticC0der requested a review from a team as a code owner March 20, 2026 16:24
fi
fi;

set -eu
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.

We likely want to keep set -eu at the top, so that it can affect the additions above?

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.

with set -eu if one of the appctl command fails instead of continuing and explaining to the user, it will just fail

Running multiple instances of Open vSwitch in the same namespace is not
supported.
supported. Starting microovn.switch will attempt to shut down the
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.

Due to not returning with an error below, this message will never be printed or logged anywhere. We should likely move the check and message elsewhere.

Comment on lines +3 to +6
if [ "$(ovs-vsctl show)" ]; then
ovs-appctl exit
rc=$?
ovs-appctl -t ovsdb-server exit
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.

  1. Using ovs-vsctl show alone as a check for whether an instance of OVS already exists in the system appears brittle to me. The above command would fail for instances of OVS in unexpected state or locations (e.g. in a foreign snap, installed to /usr/local from upstream sources, partially running OVS e.g. only ovs-vswitchd and no ovsdb-server, and so on).

    Checking for the kernel datapath previously being initialized is a fairly bullet proof check, so I think we need that as one of the checks here, perhaps move it here from the install hook?

  2. If someone already has an instance of OVS installed, it is likely that it is there for a reason, and with some configuration, possibly in use for connectivity to the system itself or services running on it.

    Presumably this change is made in an attempt at helping with migration, but is it really safe and desirable to unsolicitedly shut down the running service without also ensuring the success of remaining migration steps?

  3. It took me a moment to remember that we do not have global environment variables nor snap layouts that influence execution of the standard OVS binaries. So this works because by default these tools will reach into default system locations, for which access is granted by the openvswitch-support snapd interface.

    I think it would be worth adding a comment about why this works, and/or possibly adding explicit path to the socket we expect to use in the system to make it even more clear what is going on.

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.

Presumably this change is made in an attempt at helping with migration, but is it really safe and desirable to unsolicitedly shut down the running service without also ensuring the success of remaining migration steps?

I could expand the check to ensure there's conf.db somewhere which means its presumably been moved over but I feel setting up microovn while OVS is present and starting microovn, switch without doing the one migration step is a user error

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.

but I feel setting up microovn while OVS is present and starting microovn, switch without doing the one migration step is a user error

Sure, and users do make those errors. I have recent memories of the team spending an extended period of time finding the root cause of issues caused by multiple instances of ovs-vswitchd running.

Unless you are a OVS/OVN developer, you may have no knowledge of the danger in doing this, and it is a really subtle and non-obvious condition to find.

Happy to see the check moved from the install hook if that helps migration, but we need to retain its function for the casual user about to fire a footgun.

I could expand the check to ensure there's conf.db somewhere which means its presumably been moved over

We definitively want stopping of system services to be a conscious choice by the human operator of the snap, presence of some file required to complete migration could indeed serve as such conscious choice.

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.

We definitively want stopping of system services to be a conscious choice by the human operator of the snap, presence of some file required to complete migration could indeed serve as such conscious choice.

I personally dont like enforcing conf.db to be there as it seems somewhat specific, so ive added a check for a file the user will need to create explicitly accepting this, inspired slightly by pips --break-system-packages flag

If Open vSwitch is installed do not block microovn installation. When
microovn.switch is started check if non-snap Open vSwitch is running,
if it is shut it down and then prompt the user to disable the non-snap
OVS services.

Also expands the switchstart test to ensure this works properly.

Signed-off-by: MJ Ponsonby <mj.ponsonby@canonical.com>
@crypticC0der
Copy link
Copy Markdown
Contributor Author

interesting thing about the openvswitch interface, along with not giving us access to conf.db it also doesnt give us access to /var/run/openvswitch/ovsdb-server.pid so we cant actually stop ovsdb within the snap which is really quite frustrating.
I am going to put this PR as a draft and move this functionality into the charm

@crypticC0der crypticC0der marked this pull request as draft March 26, 2026 17:11
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