apply, rollback: Revert to a state where IPv6 is disabled

In cases where the previous state on an interface included IPv6
disabled and the processing of the desired state caused it to be
enabled, the rollback failed to re-disable the IPv6 stack.

In case of a rollback, the previous state is processed and IPv6 is
disabled if needed.

Signed-off-by: Edward Haas <edwardh@redhat.com>
This commit is contained in:
Edward Haas 2019-07-28 13:59:43 +03:00
parent 15ac912c23
commit 6d85b859d3

View File

@ -22,6 +22,7 @@ from contextlib import contextmanager
import copy
import logging
import six
import time
from libnmstate import metadata
from libnmstate import netinfo
@ -31,6 +32,7 @@ from libnmstate import state
from libnmstate import sysctl
from libnmstate import validator
from libnmstate.error import NmstateConflictError
from libnmstate.error import NmstateError
from libnmstate.error import NmstateLibnmError
from libnmstate.error import NmstatePermissionError
from libnmstate.error import NmstateValueError
@ -150,6 +152,14 @@ def _apply_ifaces_state(
raise NmstatePermissionError('Error creating a check point')
except nm.checkpoint.NMCheckPointCreationError:
raise NmstateConflictError('Error creating a check point')
except NmstateError:
# Assume rollback occured, revert IPv6 stack state.
# Checkpoint rollback is async, there is a need to wait for it to
# finish before proceeding with other actions.
# TODO: https://nmstate.atlassian.net/browse/NMSTATE-103
time.sleep(5)
_disable_ipv6(current_state)
raise
def _create_editable_desired_state(