Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

providers: support for vendor-data in proxmoxve #2014

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

jdoss
Copy link

@jdoss jdoss commented Feb 6, 2025

This PR adds support for reading Ignition data out of the vendor-data file so we can leave the cloud-config in the user-data file. It will always use the user-data file if it has an ignition config over using the vendor-data file.

This works as expected:

# /home/jdoss/ignition --platform proxmoxve --stage fetch -log-to-stdout
INFO     : Ignition v2.10.1-1315-gaf19b7d7-dirty
INFO     : Stage: fetch
INFO     : no config dir at "/usr/lib/ignition/base.d"
INFO     : no config dir at "/usr/lib/ignition/base.platform.d/proxmoxve"
DEBUG    : parsed url from cmdline: ""
INFO     : no config URL provided
INFO     : reading system config file "/usr/lib/ignition/user.ign"
INFO     : no config at "/usr/lib/ignition/user.ign"
DEBUG    : creating temporary mount point
INFO     : op(1): [started]  mounting config drive
DEBUG    : op(1): executing: "mount" "-o" "ro" "-t" "auto" "/dev/disk/by-label/cidata" "/tmp/ignition-configdrive2469853404"
INFO     : op(1): [finished] mounting config drive
DEBUG    : config drive ("/tmp/ignition-configdrive2469853404/user-data") contains a cloud-config configuration, ignoring
DEBUG    : config drive ("/tmp/ignition-configdrive2469853404/vendor-data") contains a ignition configuration
INFO     : op(2): [started]  unmounting "/dev/disk/by-label/cidata" at "/tmp/ignition-configdrive2469853404"
INFO     : op(2): [finished] unmounting "/dev/disk/by-label/cidata" at "/tmp/ignition-configdrive2469853404"
DEBUG    : parsing config with SHA512: d45cc6bd9291debbfbd47365a802208a027b77407d39caf42f873ffd9183cc20dbc01803da2c17cfba09e1c753bff9168a5865bff30f9428088ae7f7b87d7ae0
INFO     : fetch: fetch complete
INFO     : fetch: fetch passed
INFO     : Ignition finished successfully

@@ -40,7 +41,8 @@ import (
)

const (
cidataPath = "/user-data"
ciuserdataPath = "/user-data"
civendordataPath = "/vendor-data"
Copy link
Member

Choose a reason for hiding this comment

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

Let's link to that Proxmox bugzilla issue here for more context.

Copy link
Author

Choose a reason for hiding this comment

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

Done.

}

// Try to validate if it's JSON
if json.Valid(contents) {
Copy link
Member

Choose a reason for hiding this comment

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

Why check for JSON here? I prefer the current behaviour of "if it's not cloud-config data, assume that it's an Ignition config and otherwise fail". Though I guess we need to at least check that it's a non-zero file.

Copy link
Author

Choose a reason for hiding this comment

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

It was a simple way to check that the file isn't empty and that it contains at least some valid JSON. I think it is fine to leave as is.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, again would rather we be more strict here. We should either expect cloud-init configs, Ignition configs, or an empty file, nothing else.

As it is for example, a typo in the user's Ignition config will be ignored rather than hard fail the system. But also I think given the messiness of this platform, I'd rather we always know exactly what we're dealing with as a way to keep track of any changes in expectations.

Copy link
Author

@jdoss jdoss Feb 27, 2025

Choose a reason for hiding this comment

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

In the current implementation we don't check if it is valid JSON or valid Ignition config. It only checks the first line and if it contains #cloud-config and if so it ignores the file. This means it won't ignore the file if they have invalid Ignition and hard fail the system. Checking for JSON at least ensures that there isn't an empty file but I can just revert it back to the current implementation if you want.

There is only so much that can be done to protect against invalid Ignition configuration and I felt at least checking for valid JSON data is better than nothing.

Copy link
Author

Choose a reason for hiding this comment

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

I just pushed an update that implements checking to ensure the file contains data before returning and removes the check for valid JSON data.

This PR adds support for reading Ignition data out of the
vendor-data file so we can leave the cloud-config in the
user-data file. It will always use the user-data file
if it has an ignition config over using the vendor-data
file.
@jdoss jdoss force-pushed the jdoss/Proxmoxve_vendor-data_support branch from 0d7040f to f60d7f9 Compare February 25, 2025 00:21
…of it instead of verifying that it contains valid JSON data.
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.

2 participants