Skip to content

Catch InvalidDHCPLeaseFileError in DataSourceScaleway._get_data to prevent crash on IPv6-only VMs.#6904

Open
Federicorao wants to merge 2 commits into
canonical:mainfrom
Federicorao:codex/issue-6901-1781215802
Open

Catch InvalidDHCPLeaseFileError in DataSourceScaleway._get_data to prevent crash on IPv6-only VMs.#6904
Federicorao wants to merge 2 commits into
canonical:mainfrom
Federicorao:codex/issue-6901-1781215802

Conversation

@Federicorao

Copy link
Copy Markdown

Fixes #6901.

What changed

Catch InvalidDHCPLeaseFileError in DataSourceScaleway._get_data to prevent crash on IPv6-only VMs.

Why

On IPv6-only Scaleway VMs, dhcpcd returns an empty lease, which raises InvalidDHCPLeaseFileError. This exception was not caught in the except block of _get_data, causing an unhandled crash. The fix adds InvalidDHCPLeaseFileError to the import and the except clause, matching how other datasources handle this error.

Verification

  • python ast parse passed

Not run

  • Repository runtime tests were not run outside the configured static/sandbox policy.

Changed files

  • cloudinit/sources/DataSourceScaleway.py

@holmanb holmanb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix failing tests and sign the CLA.

@Federicorao

Copy link
Copy Markdown
Author

I have signed the Canonical CLA. Please re-check the CLA status and re-review the latest commit.

return False

def _get_data(self):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please avoid unnecessary whitespace changes

Comment on lines +309 to +332
# Methods required by the DataSource base class
def get_instance_id(self):
if not self.metadata:
return None
return self.metadata.get("id")

def get_hostname(self, fqdn=False, resolve_ip=False, metadata_only=False):
if not self.metadata:
return DataSourceHostname(None, True)
hostname = self.metadata.get("hostname")
if hostname:
return DataSourceHostname(hostname, False)
return DataSourceHostname(None, True)

def get_public_ssh_keys(self):
if not self.metadata:
return []
keys = []
for entry in self.metadata.get("ssh_public_keys", []):
if isinstance(entry, dict):
keys.append(entry["key"])
for tag in self.metadata.get("tags", []):
if tag.startswith("AUTHORIZED_KEY="):
key = tag.split("=", 1)[1].replace("_", " ")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please avoid relocating existing code

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scaleway DataSource on IPv6-only VM raises exception when trying EphemeralDHCPv4

2 participants