Skip to content

Obfuscate is failing intermittently with list index out of range #403

@adarshrtech

Description

@adarshrtech

While running the rancher2_logs_collector.sh script with the Obfuscate (-o) option, it sometimes failed with the following error.

processing file: iplinkshow
processing file: ss4apn
processing file: ip6tablesmangle
processing file: iptables
Traceback (most recent call last):
  File "<stdin>", line 186, in <module>
  File "<stdin>", line 162, in process_file
  File "<stdin>", line 131, in obfuscate_text
  File "<stdin>", line 80, in obfuscate_hostname
  File "<stdin>", line 80, in <listcomp>
  File "<stdin>", line 72, in obfuscate_subdomain
  File "<stdin>", line 23, in generate_word
  File "<stdin>", line 44, in generate_adv
  File "/usr/lib/python3.10/random.py", line 378, in choice
    return seq[self._randbelow(len(seq))]
IndexError: list index out of range

In a test cluster where it failed, the number of Hostname/IP mappings were as below and a successful run on the same cluster had 3714/354 created

# cat hostname_mapping.json | wc -l
2346
# cat ip_mapping.json | wc -l
78

During successful run too, some of the hostnames are visible like below

ip-172-31-40-225 NotReady <none> 5d23h v1.31.3+rke2r1 172.braggingly.fantasy.better <none> Ubuntu 22.04.5 LTS 6.8.0-1035-aws containerd://1.7.23-k3s2

In addition to that, both IP and hostname are present in the file path rke2/kubectl/rancher-prov/nodes.management.cattle.io

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions