[ovs-dev] [PATCH 2/2] fedora: Handle upgrades from rhel package.
Guru Shetty
guru at ovn.org
Fri May 10 21:00:40 UTC 2019
On Thu, 9 May 2019 at 17:37, Ansis Atteka <ansisatteka at gmail.com> wrote:
> On Fri, 3 May 2019 at 11:19, Gurucharan Shetty <guru at ovn.org> wrote:
> >
> > Currently we have rhel/openvswitch.spec.in that provides
> > sysv scripts. The fedora package provides systemd scripts.
> > If one upgrades openvswitch package from sysv to systemd,
> > you will end up in a situation where old OVS daemons are
> > running, but systemd does not know about it. One "restart"
> > is needed for systemd to see the old daemons. Another "restart"
> > or "force-reload-kmod" is needed to actually use the new
> > daemons.
> >
> > This commit, just takes care of the first restart. The "real"
> > restart/force-reload-kmod will still have to be done outside
> > the package installation.
> >
> > Signed-off-by: Gurucharan Shetty <guru at ovn.org>
>
> Do I understand correctly that Aaron has concern whether the
> autoenable build flag that you introduced in patch 1/2 should
> automatically enable openvswitch on every installation (opposed to
> only first installation)? Did you look into how other fedora packages
> that enable services on installation behave?
Fedora packages seem to look at system-preset files in
/etc/systemd/system-preset/ to decide whether a package needs to be
enabled. But we don't provide such a file.
> I kinda see the point
> that if admin explicitly disabled openvswitch then we should not
> blindly re-enable openvswitch back...
>
The openvswitch rhel rpm so far has always enabled it after installation or
upgrade (from 2011). So there is some compatibility there. What we can do
here is that after a few releases, only enable openvswitch for a fresh
installation and not upgrade - unless we want it right now and special case
upgrades from pre-systemd to systemd. I don't see what we are doing as a
particularly bad behavior as this is not a default option and will only
happen if someone actually builds the RPM with a specfic non-default option.
>
> > ---
> > rhel/openvswitch-fedora.spec.in | 14 ++++++++++++++
> > 1 file changed, 14 insertions(+)
> >
> > diff --git a/rhel/openvswitch-fedora.spec.in b/rhel/
> openvswitch-fedora.spec.in
> > index e8165f9..d41d11c 100644
> > --- a/rhel/openvswitch-fedora.spec.in
> > +++ b/rhel/openvswitch-fedora.spec.in
> > @@ -364,6 +364,12 @@ getent passwd openvswitch >/dev/null || \
> > usermod -a -G hugetlbfs openvswitch
> > %endif
> > %endif
> > +
> > +%if %{with autoenable}
> > + if [ -x "/etc/init.d/openvswitch" ]; then
> > + touch %{_tmppath}/ovs-upgrade-from-sysv
> > + fi
> > +%endif
> > exit 0
> >
> > %post
> > @@ -397,6 +403,14 @@ fi
> > %if %{with autoenable}
> > systemctl daemon-reload
> > systemctl enable openvswitch
> > + # Handle upgrades to this package from the OVS repo's rhel packages.
> > + # One "restart" is needed for newer systemd files to see the old
> running
>
> The double restart thingy seems kinda weird to me as well, but I don't
> have insight why systemd behaves that way.
This is the behavior broken down into steps
1. Old OVS daemons are running and new systemd unit files are installed.
2. "systemctl status openvswitch" - says that it is inactive as it has
never been started.
3. "systemctl stop openvswitch" - does not attempt to stop anything because
openvswitch is "inactive"
4. "systemctl start openvswitch" - will try to attempt to start openvswitch
- but does not do anything - likely because it notices that the PID file is
active and daemons are still running. Now "openvswitch" is active.
5. "systemctl stop openvswitch" - will stop old daemons.
6. "systemctl start openvswitch" - will start new daemons.
> Would calling systemctl
> stop before daemon-reload and then systemctl [re]start after
> daemon-reload solve the problem in a more elegant way? If not probably
> this is not worth something worth to bother with.
>
I tried your suggestion and that does not work.
>
> > + # daemons. Another "restart" (outside the package postinst script)
> is
> > + # needed to actually run new daemons.
> > + if [ -e "%{_tmppath}/ovs-upgrade-from-sysv" ]; then
> t seems that if rpm package that was built from rhel spec file was
> removed (without upgrade) and then you do fresh install, then you hit
> this upgrade path too. Unless the whole host was rebooted before fresh
> install and all contents of /tmp directory were purged. Though this
> may not be an issue after invoking the "sytemctl enable", right?
>
You are correct. I had not thought about it. The end result is that we have
a start of openvswitch daemons. I think I can fix this by making this code
only run during an upgrade. I will send a v2.
>
> Do you think it may make sense to commit to remove this migration code
> after couple releases? I kinda see this as a temporary solution that
> is supposed to help admins with migrating from rhel spec files to
> fedora spec files. Once everyone has migrated, then this code becomes
> clutter.
>
Yes. We can get rid of this code after a few releases.
> > + systemctl restart openvswitch
> > + rm "%{_tmppath}/ovs-upgrade-from-sysv"
> > + fi
> > %endif
> >
> > %post selinux-policy
> > --
> > 1.9.1
> >
> > _______________________________________________
> > dev mailing list
> > dev at openvswitch.org
> > https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
More information about the dev
mailing list