Implementation of deferred restarts
Add deferred restart actions and config. Change-Id: I34ceac5b62e079259a25a11edcedc30f943888d7
This commit is contained in:
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))
|
||||
@@ -14,3 +14,10 @@ options:
|
||||
a hypervisor hosts an instance in a subnet, so the volume should be
|
||||
relatively low. If you set this number too high you may put an
|
||||
unnecessary toll on the OVN Southbound database server.
|
||||
enable-auto-restarts:
|
||||
type: boolean
|
||||
default: True
|
||||
description: |
|
||||
Allow the charm and packages to restart services automatically when
|
||||
required.
|
||||
|
||||
|
||||
@@ -20,7 +20,8 @@ import charms.ovn_charm
|
||||
charm.use_defaults('charm.default-select-release')
|
||||
|
||||
|
||||
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
|
||||
# Pockets get their name from OpenStack releases
|
||||
release = 'train'
|
||||
@@ -31,7 +32,8 @@ class TrainOVNChassisCharm(charms.ovn_charm.BaseTrainOVNChassisCharm):
|
||||
source_config_key = ''
|
||||
|
||||
|
||||
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
|
||||
# Pockets get their name from OpenStack releases
|
||||
release = 'ussuri'
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
import charms.reactive as reactive
|
||||
import charms_openstack.charm as charm
|
||||
|
||||
from . import ovn_chassis_charm_handlers
|
||||
|
||||
@@ -20,3 +21,9 @@ from . import ovn_chassis_charm_handlers
|
||||
def enable_ovn_chassis_handlers():
|
||||
reactive.set_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()
|
||||
|
||||
@@ -26,6 +26,7 @@ target_deploy_status:
|
||||
configure:
|
||||
- zaza.openstack.charm_tests.vault.setup.auto_initialize_no_validation
|
||||
tests:
|
||||
- zaza.openstack.charm_tests.ovn.tests.OVNChassisDeferredRestartTest
|
||||
- zaza.openstack.charm_tests.ovn.tests.ChassisCharmOperationTest
|
||||
tests_options:
|
||||
force_deploy:
|
||||
|
||||
@@ -26,6 +26,7 @@ class TestRegisteredHooks(test_utils.TestRegisteredHooks):
|
||||
hook_set = {
|
||||
'when_not': {
|
||||
'enable_ovn_chassis_handlers': ('MOCKED_FLAG',),
|
||||
'configure_deferred_restarts': ('is-update-status-hook',),
|
||||
},
|
||||
}
|
||||
# test that the hooks were registered via the
|
||||
|
||||
Reference in New Issue
Block a user