FileExistsError: [Errno 17] File exists: '/etc/corosync'

Bug #1971762 reported by Felipe Reyes
32
This bug affects 5 people
Affects Status Importance Assigned to Milestone
OpenStack HA Cluster Charm
Fix Committed
Undecided
Felipe Reyes

Bug Description

Re-running the install hook fails with the following stacktrace

unit-hacluster-2: 18:43:34 INFO juju.worker.uniter awaiting error resolution for "install" hook
unit-hacluster-2: 18:43:34 WARNING unit.hacluster/2.install Traceback (most recent call last):
unit-hacluster-2: 18:43:34 WARNING unit.hacluster/2.install File "/var/lib/juju/agents/unit-hacluster-2/charm/hooks/install.real", line 760, in <module>
unit-hacluster-2: 18:43:34 WARNING unit.hacluster/2.install hooks.execute(sys.argv)
unit-hacluster-2: 18:43:34 WARNING unit.hacluster/2.install File "/var/lib/juju/agents/unit-hacluster-2/charm/charmhelpers/core/hookenv.py", line 962, in execute
unit-hacluster-2: 18:43:34 WARNING unit.hacluster/2.install self._hooks[hook_name]()
unit-hacluster-2: 18:43:34 WARNING unit.hacluster/2.install File "/var/lib/juju/agents/unit-hacluster-2/charm/hooks/install.real", line 156, in install
unit-hacluster-2: 18:43:34 WARNING unit.hacluster/2.install os.mkdir('/etc/corosync', mode=0o755)
unit-hacluster-2: 18:43:34 WARNING unit.hacluster/2.install FileExistsError: [Errno 17] File exists: '/etc/corosync'
unit-hacluster-2: 18:43:34 ERROR juju.worker.uniter.operation hook "install" (via explicit, bespoke hook script) failed: exit status 1
unit-hacluster-2: 18:43:34 INFO juju.worker.uniter awaiting error resolution for "install" hook

Felipe Reyes (freyes)
Changed in charm-hacluster:
assignee: nobody → Felipe Reyes (freyes)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to charm-hacluster (master)
Changed in charm-hacluster:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to charm-hacluster (master)

Reviewed: https://review.opendev.org/c/openstack/charm-hacluster/+/840722
Committed: https://opendev.org/openstack/charm-hacluster/commit/715d31e09f939844bd27f2d4ed8c9207598a5938
Submitter: "Zuul (22348)"
Branch: master

commit 715d31e09f939844bd27f2d4ed8c9207598a5938
Author: Felipe Reyes <email address hidden>
Date: Thu May 5 15:03:58 2022 -0400

    Catch FileExistsError when creating /etc/corosync dir.

    Hooks are expected to be idempotent, if the install hook for whatever
    reason needs to be re-run and the /etc/corosync directory already exists,
    because for example it was created in a previous run, the exception
    FileExistsError will be raised, this change captures the exception and
    moves on.

    Change-Id: If43a5c95bb59c9cca7f1a975214a9f013ad6f4d6
    Closes-Bug: #1971762

Changed in charm-hacluster:
status: In Progress → Fix Committed
Revision history for this message
Nobuto Murata (nobuto) wrote :

This seems to be happening in the upgrade-charm hook too per:
https://bugs.launchpad.net/charm-hacluster/+bug/1983824

And the fix hasn't been backported to stable/focal nor stable/jammy.

Revision history for this message
Nobuto Murata (nobuto) wrote :

Subscribing ~field-high for stable backports.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to charm-hacluster (stable/focal)

Fix proposed to branch: stable/focal
Review: https://review.opendev.org/c/openstack/charm-hacluster/+/852410

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to charm-hacluster (stable/jammy)

Fix proposed to branch: stable/jammy
Review: https://review.opendev.org/c/openstack/charm-hacluster/+/852495

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to charm-hacluster (stable/jammy)

Reviewed: https://review.opendev.org/c/openstack/charm-hacluster/+/852495
Committed: https://opendev.org/openstack/charm-hacluster/commit/c579d517c5a0a5c95ff24f874e9445ed25245e10
Submitter: "Zuul (22348)"
Branch: stable/jammy

commit c579d517c5a0a5c95ff24f874e9445ed25245e10
Author: Felipe Reyes <email address hidden>
Date: Thu May 5 15:03:58 2022 -0400

    Catch FileExistsError when creating /etc/corosync dir.

    Hooks are expected to be idempotent, if the install hook for whatever
    reason needs to be re-run and the /etc/corosync directory already exists,
    because for example it was created in a previous run, the exception
    FileExistsError will be raised, this change captures the exception and
    moves on.

    Change-Id: If43a5c95bb59c9cca7f1a975214a9f013ad6f4d6
    Closes-Bug: #1971762
    (cherry picked from commit 715d31e09f939844bd27f2d4ed8c9207598a5938)

tags: added: in-stable-jammy
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to charm-hacluster (stable/focal)

Reviewed: https://review.opendev.org/c/openstack/charm-hacluster/+/852410
Committed: https://opendev.org/openstack/charm-hacluster/commit/4661d9c4aa1bb5ada91a3233d34074a96657bb23
Submitter: "Zuul (22348)"
Branch: stable/focal

commit 4661d9c4aa1bb5ada91a3233d34074a96657bb23
Author: Felipe Reyes <email address hidden>
Date: Thu May 5 15:03:58 2022 -0400

    Catch FileExistsError when creating /etc/corosync dir.

    Hooks are expected to be idempotent, if the install hook for whatever
    reason needs to be re-run and the /etc/corosync directory already exists,
    because for example it was created in a previous run, the exception
    FileExistsError will be raised, this change captures the exception and
    moves on.

    Change-Id: If43a5c95bb59c9cca7f1a975214a9f013ad6f4d6
    Closes-Bug: #1971762
    (cherry picked from commit 715d31e09f939844bd27f2d4ed8c9207598a5938)

tags: added: in-stable-focal
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.