Duplicate ssh keys after every upgrade-charm hook

Bug #1943753 reported by Rodrigo Barbieri
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Nova Cloud Controller Charm
Fix Released
Undecided
Rodrigo Barbieri

Bug Description

version: stable/21.04
deployment: bionic-ussuri

Upon deploying this charm and then trying to upgrade it (even if the code is exactly the same), when the upgrade-charm hook runs, the contents of:

- /etc/nova/compute_ssh/*/authorized_keys
- /etc/nova/compute_ssh/*/known_hosts
- cloud-compute relations

gets duplicated.

Starting a fresh deploying with 3 compute nodes:
- authorized_keys has 3 keys
- known_hosts has 9 keys, where they are already duplicated 3 times with only the host hash being different

Investigating this, I found:

Condition [0] always returns false. Testing with "public_key in keys.read()" works.

Command [1] exit code is always 1, therefore the function always returns None. Also, testing the command does not show "'# Host xx found: line 1 type RSA'," as the code comment implies. When the code is changed to always return the output even if RC=1 (and lines[0] instead of lines[1]) the deduplication logic at [2] is invoked and works.

[0] https://github.com/openstack/charm-nova-cloud-controller/blob/b2fe2601c96e44c07816d1c70b9c5d7e2409e2b3/hooks/nova_cc_utils.py#L1269

[1] https://github.com/openstack/charm-nova-cloud-controller/blob/b2fe2601c96e44c07816d1c70b9c5d7e2409e2b3/hooks/nova_cc_utils.py#L1163

[2] https://github.com/openstack/charm-nova-cloud-controller/blob/b2fe2601c96e44c07816d1c70b9c5d7e2409e2b3/hooks/nova_cc_utils.py#L1197

Changed in charm-nova-cloud-controller:
assignee: nobody → Rodrigo Barbieri (rodrigo-barbieri2010)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to charm-nova-cloud-controller (master)
Changed in charm-nova-cloud-controller:
status: New → In Progress
Changed in charm-nova-cloud-controller:
milestone: none → 21.10
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to charm-nova-cloud-controller (master)

Reviewed: https://review.opendev.org/c/openstack/charm-nova-cloud-controller/+/809281
Committed: https://opendev.org/openstack/charm-nova-cloud-controller/commit/1a63d9c0b690638e3eab4df8a7666f98d2b68b7a
Submitter: "Zuul (22348)"
Branch: master

commit 1a63d9c0b690638e3eab4df8a7666f98d2b68b7a
Author: Rodrigo Barbieri <email address hidden>
Date: Wed Sep 15 16:27:14 2021 -0300

    Fix ssh keys duplication

    Upon running hooks that update ssh_keys, they
    end up duplicated in the /etc/nova/compute_ssh/* files
    and cloud-compute relations because the code that
    checks whether the keys already exist are currently
    not working.

    This change fixes the deduplication code and improves
    unit tests, while also handling a special case for
    specific ubuntu-version scenarios.

    Change-Id: I93f9418d5340e7cb599a42970d78557362c1542f
    Closes-bug: #1943753

Changed in charm-nova-cloud-controller:
status: In Progress → Fix Committed
Changed in charm-nova-cloud-controller:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.