diff --git a/devstack/plugin.sh b/devstack/plugin.sh index 7761b86fef..43cf9ff60b 100644 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -332,6 +332,7 @@ function octavia_configure { iniset $OCTAVIA_CONF controller_worker network_driver ${OCTAVIA_NETWORK_DRIVER} iniset $OCTAVIA_CONF controller_worker image_driver ${OCTAVIA_IMAGE_DRIVER} iniset $OCTAVIA_CONF controller_worker amp_image_tag ${OCTAVIA_AMP_IMAGE_TAG} + iniset $OCTAVIA_CONF controller_worker amp_timezone $(readlink -e /etc/localtime | sed "s/\/usr\/share\/zoneinfo\///") iniuncomment $OCTAVIA_CONF health_manager heartbeat_key iniset $OCTAVIA_CONF health_manager heartbeat_key ${OCTAVIA_HEALTH_KEY} diff --git a/etc/octavia.conf b/etc/octavia.conf index 411baef4ca..3dfbdede70 100644 --- a/etc/octavia.conf +++ b/etc/octavia.conf @@ -311,6 +311,9 @@ # Upload the ssh key as the service_auth user described elsewhere in this config. # Leaving this variable blank will install no ssh key on the amphora. # amp_ssh_key_name = +# Defines the timezone to use as represented in /usr/share/zoneinfo. +# Default is UTC. +# amp_timezone = # Networks to attach to the Amphorae examples: # - One primary network diff --git a/octavia/common/config.py b/octavia/common/config.py index 86bd179a13..83a8358dab 100644 --- a/octavia/common/config.py +++ b/octavia/common/config.py @@ -477,6 +477,10 @@ controller_worker_opts = [ default='', help=_('Optional SSH keypair name, in nova, that will be used ' 'for the authorized_keys inside the amphora.')), + cfg.StrOpt('amp_timezone', + default='UTC', + help=_('The timezone to use in the Amphora as represented in ' + '/usr/share/zoneinfo.')), cfg.ListOpt('amp_boot_network_list', default='', help=_('List of networks to attach to the Amphorae. ' diff --git a/octavia/common/jinja/templates/user_data_config_drive.template b/octavia/common/jinja/templates/user_data_config_drive.template index 612f54ba07..6df3dff643 100644 --- a/octavia/common/jinja/templates/user_data_config_drive.template +++ b/octavia/common/jinja/templates/user_data_config_drive.template @@ -37,3 +37,5 @@ runcmd: {% if user_data -%} - service amphora-agent restart {%- endif %} + +timezone: {{ timezone }} diff --git a/octavia/common/jinja/user_data_jinja_cfg.py b/octavia/common/jinja/user_data_jinja_cfg.py index 893a500d8c..a42fceddad 100644 --- a/octavia/common/jinja/user_data_jinja_cfg.py +++ b/octavia/common/jinja/user_data_jinja_cfg.py @@ -35,4 +35,5 @@ class UserDataJinjaCfg(object): constants.USER_DATA_CONFIG_DRIVE_TEMPLATE) def build_user_data_config(self, user_data): - return self.agent_template.render(user_data=user_data) + return self.agent_template.render( + user_data=user_data, timezone=CONF.controller_worker.amp_timezone) diff --git a/octavia/tests/unit/common/jinja/test_user_data_jinja_cfg.py b/octavia/tests/unit/common/jinja/test_user_data_jinja_cfg.py index 4504d4c545..4f6ed9d805 100644 --- a/octavia/tests/unit/common/jinja/test_user_data_jinja_cfg.py +++ b/octavia/tests/unit/common/jinja/test_user_data_jinja_cfg.py @@ -40,7 +40,8 @@ BASE_CFG = ('#cloud-config\n' WRITE_FILES_CFG = ('write_files:\n') RUN_CMD = ('runcmd:\n' '- systemctl restart rsyslog\n') -WRITE_FILES_CMD = ('- service amphora-agent restart') +WRITE_FILES_CMD = ('- service amphora-agent restart\n') +TIMEZONE = '\ntimezone: UTC' class TestUserDataJinjaCfg(base.TestCase): @@ -52,12 +53,12 @@ class TestUserDataJinjaCfg(base.TestCase): expected_config = (BASE_CFG + WRITE_FILES_CFG + '- path: /test/config/path\n' ' content: |\n' + EXPECTED_TEST_CONFIG + - RUN_CMD + WRITE_FILES_CMD) + RUN_CMD + WRITE_FILES_CMD + TIMEZONE) ud_cfg = udc.build_user_data_config({'/test/config/path': TEST_CONFIG}) self.assertEqual(expected_config, ud_cfg) def test_build_user_data_config_no_files(self): udc = user_data_jinja_cfg.UserDataJinjaCfg() - expected_config = (BASE_CFG + '\n' + RUN_CMD) + expected_config = (BASE_CFG + '\n' + RUN_CMD + '\n' + TIMEZONE) ud_cfg = udc.build_user_data_config({}) self.assertEqual(expected_config, ud_cfg) diff --git a/releasenotes/notes/add-config-option-for-amp-timezone-6496a33a23d7520d.yaml b/releasenotes/notes/add-config-option-for-amp-timezone-6496a33a23d7520d.yaml new file mode 100644 index 0000000000..d33e0a76ad --- /dev/null +++ b/releasenotes/notes/add-config-option-for-amp-timezone-6496a33a23d7520d.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + Configuration of the amphora's timezone is now possible using new + configuration setting "amp_timezone" in the controller_worker options + group.