Skip to content

Adding an internal WebDAV backup repository fails on nodes with multi-digit IDs #8257

Open

Description

@nrauso

Steps to reproduce

  1. Set up an NS8 cluster containing nodes with multi-digit IDs (e.g. 20 and 21).
  2. Configure an internal WebDAV backup destination.
  3. Try to add the WebDAV destination as a backup repository from the cluster administration UI.
  4. The add-backup-repository action fails at step 50update.

Expected behavior

The internal WebDAV backup repository should be successfully validated and added.

The validation task should be submitted to the node hosting the WebDAV destination, using its complete node ID (e.g. node/20).

Actual behavior

The add-backup-repository action fails with the following traceback:

Oct 21 15:15:33 test agent@cluster[2471280]: Traceback (most recent call last):
Oct 21 15:15:33 test agent@cluster[2471280]:   File "/var/lib/nethserver/cluster/actions/add-backup-repository/50update", line 122, in <module>
Oct 21 15:15:33 test agent@cluster[2471280]:     main()
Oct 21 15:15:33 test agent@cluster[2471280]:   File "/var/lib/nethserver/cluster/actions/add-backup-repository/50update", line 87, in main
Oct 21 15:15:33 test agent@cluster[2471280]:     if all(ntr["exit_code"] != 0 for ntr in node_task_results):
Oct 21 15:15:33 test agent@cluster[2471280]:   File "/var/lib/nethserver/cluster/actions/add-backup-repository/50update", line 87, in <genexpr>
Oct 21 15:15:33 test agent@cluster[2471280]:     if all(ntr["exit_code"] != 0 for ntr in node_task_results):
Oct 21 15:15:33 test agent@cluster[2471280]:            ~~~^^^^^^^^^^^^^
Oct 21 15:15:33 test agent@cluster[2471280]: TypeError: 'TaskSubmissionCheckFailed' object is not subscriptable

The issue appears to originate from the following statement in 50update:

validation_nodes = set(cluster.backup.lookup_node_from_webdav_url(rdb, url) or '0')

If lookup_node_from_webdav_url() returns a node ID as a string, such as "20", calling set() splits the string into individual characters:

>>> set("20")
{'2', '0'}

As a result, validation tasks would be submitted to node/2 and node/0 instead of node/20.

This would cause TaskSubmissionCheckFailed exceptions because the target agents do not exist.

Additionally, 50update does not properly handle exceptions returned by agent.tasks.runp() and assumes that every result is a dictionary containing an exit_code key:

if all(ntr["exit_code"] != 0 for ntr in node_task_results):

Consequently, the original task submission failure is masked by a TypeError.

In the affected cluster, both node/20 and node/21 are reachable and expose the validate-backup-destination action, as verified using:

api-cli run node/20/list-actions
api-cli run node/21/list-actions

Possible fix

If lookup_node_from_webdav_url() returns a single node ID as a string, replace:

validation_nodes = set(cluster.backup.lookup_node_from_webdav_url(rdb, url) or '0')

with:

validation_nodes = {cluster.backup.lookup_node_from_webdav_url(rdb, url) or '0'}

This preserves the complete node ID instead of splitting it into characters.

The return type of lookup_node_from_webdav_url() should be verified to confirm the root cause.

It would also be useful to improve error handling for agent.tasks.runp() to report task submission failures without raising an unrelated TypeError.

Components

  • core:3.23.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions