kolla-ansible/ansible/roles
Mark Goddard 8e627c1eef Fix keystone fernet key rotation scheduling
Right now every controller rotates fernet keys. This is nice because
should any controller die, we know the remaining ones will rotate the
keys. However, we are currently over-rotating the keys.

When we over rotate keys, we get logs like this:

 This is not a recognized Fernet token <token> TokenNotFound

Most clients can recover and get a new token, but some clients (like
Nova passing tokens to other services) can't do that because it doesn't
have the password to regenerate a new token.

With three controllers, in crontab in keystone-fernet we see the once a day
correctly staggered across the three controllers:

ssh ctrl1 sudo cat /etc/kolla/keystone-fernet/crontab
0 0 * * * /usr/bin/fernet-rotate.sh
ssh ctrl2 sudo cat /etc/kolla/keystone-fernet/crontab
0 8 * * * /usr/bin/fernet-rotate.sh
ssh ctrl3 sudo cat /etc/kolla/keystone-fernet/crontab
0 16 * * * /usr/bin/fernet-rotate.sh

Currently with three controllers we have this keystone config:

[token]
expiration = 86400 (although, keystone default is one hour)
allow_expired_window = 172800 (this is the keystone default)

[fernet_tokens]
max_active_keys = 4

Currently, kolla-ansible configures key rotation according to the following:

   rotation_interval = token_expiration / num_hosts

This means we rotate keys more quickly the more hosts we have, which doesn't
make much sense.

Keystone docs state:

   max_active_keys =
     ((token_expiration + allow_expired_window) / rotation_interval) + 2

For details see:
https://docs.openstack.org/keystone/stein/admin/fernet-token-faq.html

Rotation is based on pushing out a staging key, so should any server
start using that key, other servers will consider that valid. Then each
server in turn starts using the staging key, each in term demoting the
existing primary key to a secondary key. Eventually you prune the
secondary keys when there is no token in the wild that would need to be
decrypted using that key. So this all makes sense.

This change adds new variables for fernet_token_allow_expired_window and
fernet_key_rotation_interval, so that we can correctly calculate the
correct number of active keys. We now set the default rotation interval
so as to minimise the number of active keys to 3 - one primary, one
secondary, one buffer.

This change also fixes the fernet cron job generator, which was broken
in the following cases:

* requesting an interval of more than 1 day resulted in no jobs
* requesting an interval of more than 60 minutes, unless an exact
  multiple of 60 minutes, resulted in no jobs

It should now be possible to request any interval up to a week divided
by the number of hosts.

Change-Id: I10c82dc5f83653beb60ddb86d558c5602153341a
Closes-Bug: #1809469
(cherry picked from commit 6c1442c385)
2019-06-18 19:03:30 +01:00
..
aodh Use service-specific _install_type variables in wsgi scripts 2019-03-15 15:22:54 +00:00
barbican Allow barbican services to use independent hostnames 2019-03-06 15:08:28 -05:00
baremetal Merge "Make bootstrap more idempotent" into stable/stein 2019-06-18 10:01:00 +00:00
bifrost Support stop specific containers 2018-11-26 08:07:01 +00:00
blazar Use keystone_*_url var in all configs 2019-03-06 15:08:26 -05:00
ceilometer Fix up config file permissions on the host 2019-04-02 17:23:31 +01:00
ceph Fix up config file permissions on the host 2019-04-02 17:23:31 +01:00
certificates Removing '/certificates' entry in generate.yml as this causes an 2019-03-27 09:26:58 -06:00
chrony Support stop specific containers 2018-11-26 08:07:01 +00:00
cinder Fix up config file permissions on the host 2019-04-02 17:23:31 +01:00
cloudkitty Use keystone_*_url var in all configs 2019-03-06 15:08:26 -05:00
collectd Support stop specific containers 2018-11-26 08:07:01 +00:00
common Set log message field name in Monasca Fluentd plugin 2019-05-23 14:48:53 +00:00
congress Use keystone_*_url var in all configs 2019-03-06 15:08:26 -05:00
cyborg Change action to kolla_action 2019-04-01 18:03:47 +08:00
designate Fix up config file permissions on the host 2019-04-02 17:23:31 +01:00
destroy Add elasticsearch_datadir_volume 2019-02-25 19:30:33 +01:00
elasticsearch Retry perform a synced flush task while upgrading elasticsearch 2019-03-27 18:14:07 +03:00
etcd Support stop specific containers 2018-11-26 08:07:01 +00:00
freezer Fix up config file permissions on the host 2019-04-02 17:23:31 +01:00
glance Check if glance_upgrading is defined before using it 2019-04-29 08:03:03 +00:00
gnocchi Fix up config file permissions on the host 2019-04-02 17:23:31 +01:00
grafana Increase retries numbers of grafana check task 2019-04-24 18:33:25 +00:00
haproxy Add cyborg to kolla-ansible 2019-03-08 10:46:53 +08:00
haproxy-config Allow separate listen port in haproxy-config templates 2018-12-27 15:45:50 -05:00
heat Change heat bootstrap to use internal API interface 2019-04-10 14:54:35 +00:00
horizon add version to OPENSTACK_KEYSTONE_URL 2019-03-29 14:38:59 +03:00
influxdb Support stop specific containers 2018-11-26 08:07:01 +00:00
ironic Use ironic inspector 'dnsmasq' PXE filter by default 2019-04-10 09:24:46 +00:00
iscsi Use new cinder target_helper option 2019-03-01 14:36:25 +00:00
kafka Make Kafka maintenance easier 2019-02-19 11:13:08 +00:00
karbor Use keystone_*_url var in all configs 2019-03-06 15:08:26 -05:00
keystone Fix keystone fernet key rotation scheduling 2019-06-18 19:03:30 +01:00
kibana Edit ansible script for deploy kibana 2019-03-09 11:46:04 +07:00
kuryr Use keystone_*_url var in all configs 2019-03-06 15:08:26 -05:00
magnum Use keystone_*_url var in all configs 2019-03-06 15:08:26 -05:00
manila Spelling mistake in manila.conf.j2 2019-06-06 09:31:07 +00:00
mariadb Merge "Use database_address and database_port var for mariadb check" 2019-04-04 07:35:08 +00:00
memcached Support stop specific containers 2018-11-26 08:07:01 +00:00
mistral Fix up config file permissions on the host 2019-04-02 17:23:31 +01:00
module-load Load known, standard kernel modules from the host, not within containers 2018-10-11 10:26:34 +02:00
monasca Fix issues obtaining Keystone token with Monasca Grafana 2019-05-09 11:04:21 +00:00
mongodb Support stop specific containers 2018-11-26 08:07:01 +00:00
multipathd Support stop specific containers 2018-11-26 08:07:01 +00:00
murano Use keystone_*_url var in all configs 2019-03-06 15:08:26 -05:00
neutron Fix up config file permissions on the host 2019-04-02 17:23:31 +01:00
nova Stop duplicating Nova cells 2019-06-17 10:13:49 +01:00
nova-hyperv Use keystone_*_url var in all configs 2019-03-06 15:08:26 -05:00
octavia Fix up config file permissions on the host 2019-04-02 17:23:31 +01:00
opendaylight Fix up config file permissions on the host 2019-04-02 17:23:31 +01:00
openvswitch Merge "Add support for ovsdb conversion" 2019-04-04 07:46:14 +00:00
ovs-dpdk Fix up config file permissions on the host 2019-04-02 17:23:31 +01:00
panko update the event_connection to connection for panko 2019-03-26 19:17:54 +08:00
placement Fix ubuntu binary deploys 2019-04-16 09:54:11 +00:00
prechecks Use correct variable for default certificate paths 2018-11-19 16:25:28 +00:00
prometheus Set external web URL for Prometheus services 2019-04-24 20:31:03 +00:00
qdrouterd Support stop specific containers 2018-11-26 08:07:01 +00:00
rabbitmq Fix up config file permissions on the host 2019-04-02 17:23:31 +01:00
rally Support stop specific containers 2018-11-26 08:07:01 +00:00
redis Support stop specific containers 2018-11-26 08:07:01 +00:00
sahara Merge "Use keystone_*_url var in all configs" 2019-03-07 12:26:26 +00:00
searchlight Use keystone_*_url var in all configs 2019-03-06 15:08:26 -05:00
senlin Allow senlin services to use independent hostnames 2019-03-06 15:08:28 -05:00
service-stop/tasks Support stop specific containers 2018-11-26 08:07:01 +00:00
skydive Support stop specific containers 2018-11-26 08:07:01 +00:00
solum Use keystone_*_url var in all configs 2019-03-06 15:08:26 -05:00
storm Support stop specific containers 2018-11-26 08:07:01 +00:00
swift Fix up config file permissions on the host 2019-04-02 17:23:31 +01:00
tacker Use keystone_*_url var in all configs 2019-03-06 15:08:26 -05:00
telegraf Fix Telegraf configuration template 2019-01-04 12:11:39 +00:00
tempest Fix tempest.conf permissions 2019-03-07 15:50:41 +01:00
trove Fix up config file permissions on the host 2019-04-02 17:23:31 +01:00
vitrage Use keystone_*_url var in all configs 2019-03-06 15:08:26 -05:00
vmtp Use <project>_install_type instead of kolla_install_type 2019-01-04 14:33:46 +07:00
watcher Fix up config file permissions on the host 2019-04-02 17:23:31 +01:00
zookeeper Support stop specific containers 2018-11-26 08:07:01 +00:00
zun Use keystone_*_url var in all configs 2019-03-06 15:08:26 -05:00
ceph_pools.yml Merge "Configure application for ceph pool" 2018-03-26 02:51:11 +00:00