Implementation of deferred restarts
Add deferred restart actions and config. Change-Id: I06bea08c19c4aef40c2aae1ad5e8e21d2ef66579
This commit is contained in:
parent
78710b50d2
commit
66edeaaea3
27
src/actions.yaml
Normal file
27
src/actions.yaml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
restart-services:
|
||||||
|
description: |
|
||||||
|
Restarts services this charm manages.
|
||||||
|
params:
|
||||||
|
deferred-only:
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
description: |
|
||||||
|
Restart all deferred services.
|
||||||
|
services:
|
||||||
|
type: string
|
||||||
|
default: ""
|
||||||
|
description: |
|
||||||
|
List of services to restart.
|
||||||
|
run-hooks:
|
||||||
|
type: boolean
|
||||||
|
default: true
|
||||||
|
description: |
|
||||||
|
Run any hooks which have been deferred.
|
||||||
|
run-deferred-hooks:
|
||||||
|
description: |
|
||||||
|
Run deferable hooks and restart services.
|
||||||
|
.
|
||||||
|
NOTE: Service will be restarted as needed irrespective of enable-auto-restarts
|
||||||
|
show-deferred-events:
|
||||||
|
descrpition: |
|
||||||
|
Show the outstanding restarts
|
26
src/actions/restart-services
Executable file
26
src/actions/restart-services
Executable file
@ -0,0 +1,26 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# Copyright 2021 Canonical Ltd
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
sys.path.append('actions')
|
||||||
|
|
||||||
|
|
||||||
|
import os_deferred_event_actions
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(os_deferred_event_actions.main(sys.argv))
|
26
src/actions/run-deferred-hooks
Executable file
26
src/actions/run-deferred-hooks
Executable file
@ -0,0 +1,26 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# Copyright 2021 Canonical Ltd
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
sys.path.append('actions')
|
||||||
|
|
||||||
|
|
||||||
|
import os_deferred_event_actions
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(os_deferred_event_actions.main(sys.argv))
|
26
src/actions/show-deferred-events
Executable file
26
src/actions/show-deferred-events
Executable file
@ -0,0 +1,26 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# Copyright 2021 Canonical Ltd
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
sys.path.append('actions')
|
||||||
|
|
||||||
|
|
||||||
|
import os_deferred_event_actions
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(os_deferred_event_actions.main(sys.argv))
|
@ -13,3 +13,9 @@ options:
|
|||||||
type: string
|
type: string
|
||||||
description: |
|
description: |
|
||||||
Comma separated list of nagios servicegroups for the service checks.
|
Comma separated list of nagios servicegroups for the service checks.
|
||||||
|
enable-auto-restarts:
|
||||||
|
type: boolean
|
||||||
|
default: True
|
||||||
|
description: |
|
||||||
|
Allow the charm and packages to restart services automatically when
|
||||||
|
required.
|
||||||
|
@ -31,7 +31,8 @@ class OVNDedicatedChassisConfigurationAdapter(
|
|||||||
enable_hardware_offload = False
|
enable_hardware_offload = False
|
||||||
|
|
||||||
|
|
||||||
class TrainOVNChassisCharm(charms.ovn_charm.BaseTrainOVNChassisCharm):
|
class TrainOVNChassisCharm(charms.ovn_charm.DeferredEventMixin,
|
||||||
|
charms.ovn_charm.BaseTrainOVNChassisCharm):
|
||||||
# OpenvSwitch and OVN is distributed as part of the Ubuntu Cloud Archive
|
# OpenvSwitch and OVN is distributed as part of the Ubuntu Cloud Archive
|
||||||
# Pockets get their name from OpenStack releases
|
# Pockets get their name from OpenStack releases
|
||||||
source_config_key = 'source'
|
source_config_key = 'source'
|
||||||
@ -40,12 +41,13 @@ class TrainOVNChassisCharm(charms.ovn_charm.BaseTrainOVNChassisCharm):
|
|||||||
configuration_class = OVNDedicatedChassisConfigurationAdapter
|
configuration_class = OVNDedicatedChassisConfigurationAdapter
|
||||||
|
|
||||||
# NOTE(fnordahl): Add this to ``layer-ovn``
|
# NOTE(fnordahl): Add this to ``layer-ovn``
|
||||||
def install(self):
|
def install(self, check_deferred_events=True):
|
||||||
self.configure_source()
|
self.configure_source()
|
||||||
super().install()
|
super().install(check_deferred_events=check_deferred_events)
|
||||||
|
|
||||||
|
|
||||||
class UssuriOVNChassisCharm(charms.ovn_charm.BaseUssuriOVNChassisCharm):
|
class UssuriOVNChassisCharm(charms.ovn_charm.DeferredEventMixin,
|
||||||
|
charms.ovn_charm.BaseUssuriOVNChassisCharm):
|
||||||
# OpenvSwitch and OVN is distributed as part of the Ubuntu Cloud Archive
|
# OpenvSwitch and OVN is distributed as part of the Ubuntu Cloud Archive
|
||||||
# Pockets get their name from OpenStack releases
|
# Pockets get their name from OpenStack releases
|
||||||
source_config_key = 'source'
|
source_config_key = 'source'
|
||||||
@ -54,6 +56,6 @@ class UssuriOVNChassisCharm(charms.ovn_charm.BaseUssuriOVNChassisCharm):
|
|||||||
configuration_class = OVNDedicatedChassisConfigurationAdapter
|
configuration_class = OVNDedicatedChassisConfigurationAdapter
|
||||||
|
|
||||||
# NOTE(fnordahl): Add this to ``layer-ovn``
|
# NOTE(fnordahl): Add this to ``layer-ovn``
|
||||||
def install(self):
|
def install(self, check_deferred_events=True):
|
||||||
self.configure_source()
|
self.configure_source()
|
||||||
super().install()
|
super().install(check_deferred_events=check_deferred_events)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import charms.reactive as reactive
|
import charms.reactive as reactive
|
||||||
|
|
||||||
from . import ovn_chassis_charm_handlers
|
from . import ovn_chassis_charm_handlers
|
||||||
|
import charms_openstack.charm as charm
|
||||||
|
|
||||||
|
|
||||||
# NOTE: code shared among the chassis charms can be found in the 'ovn' layer.
|
# NOTE: code shared among the chassis charms can be found in the 'ovn' layer.
|
||||||
@ -8,3 +9,9 @@ from . import ovn_chassis_charm_handlers
|
|||||||
def enable_ovn_chassis_handlers():
|
def enable_ovn_chassis_handlers():
|
||||||
reactive.set_flag(
|
reactive.set_flag(
|
||||||
ovn_chassis_charm_handlers.OVN_CHASSIS_ENABLE_HANDLERS_FLAG)
|
ovn_chassis_charm_handlers.OVN_CHASSIS_ENABLE_HANDLERS_FLAG)
|
||||||
|
|
||||||
|
|
||||||
|
@reactive.when_not('is-update-status-hook')
|
||||||
|
def configure_deferred_restarts():
|
||||||
|
with charm.provide_charm_instance() as instance:
|
||||||
|
instance.configure_deferred_restarts()
|
||||||
|
@ -23,6 +23,7 @@ target_deploy_status:
|
|||||||
configure:
|
configure:
|
||||||
- zaza.openstack.charm_tests.vault.setup.auto_initialize_no_validation
|
- zaza.openstack.charm_tests.vault.setup.auto_initialize_no_validation
|
||||||
tests:
|
tests:
|
||||||
|
- zaza.openstack.charm_tests.ovn.tests.OVNDedicatedChassisDeferredRestartTest
|
||||||
- zaza.openstack.charm_tests.ovn.tests.ChassisCharmOperationTest
|
- zaza.openstack.charm_tests.ovn.tests.ChassisCharmOperationTest
|
||||||
tests_options:
|
tests_options:
|
||||||
force_deploy:
|
force_deploy:
|
||||||
|
@ -26,6 +26,7 @@ class TestRegisteredHooks(test_utils.TestRegisteredHooks):
|
|||||||
hook_set = {
|
hook_set = {
|
||||||
'when_not': {
|
'when_not': {
|
||||||
'enable_ovn_chassis_handlers': ('MOCKED_FLAG',),
|
'enable_ovn_chassis_handlers': ('MOCKED_FLAG',),
|
||||||
|
'configure_deferred_restarts': ('is-update-status-hook',),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
# test that the hooks were registered via the
|
# test that the hooks were registered via the
|
||||||
|
Loading…
Reference in New Issue
Block a user