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 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Starting with this release, ignition-validate binaries are signed with the
### Features

- Add Azure blob support for fetching ignition configs
- Add a check for ignition config in vendor-data (proxmoxve)

### Changes

Expand Down
2 changes: 1 addition & 1 deletion docs/supported-platforms.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Ignition is currently supported for the following platforms:
* Bare Metal (`metal`) - Use the `ignition.config.url` kernel parameter to provide a URL to the configuration. The URL can use the `http://`, `https://`, `tftp://`, `s3://`, `arn:`, or `gs://` schemes to specify a remote config.
* [Nutanix] (`nutanix`) - Ignition will read its configuration from the instance userdata via config drive. Cloud SSH keys are handled separately.
* [OpenStack] (`openstack`) - Ignition will read its configuration from the instance userdata via either metadata service or config drive. Cloud SSH keys are handled separately.
* [Proxmox VE] (`proxmoxve`) - Ignition will read its configuration from the instance userdata via config drive. Cloud SSH keys are handled separately.
* [Proxmox VE] (`proxmoxve`) - Ignition will read its configuration from the instance userdata via config drive. If there isn't any valid Ignition configuration in userdata it will check the vendordata next. Cloud SSH keys are handled separately.
* [Equinix Metal] (`packet`) - Ignition will read its configuration from the instance userdata. Cloud SSH keys are handled separately.
* [IBM Power Systems Virtual Server] (`powervs`) - Ignition will read its configuration from the instance userdata. Cloud SSH keys are handled separately.
* [QEMU] (`qemu`) - Ignition will read its configuration from the 'opt/com.coreos/config' key on the QEMU Firmware Configuration Device (available in QEMU 2.4.0 and higher).
Expand Down
45 changes: 32 additions & 13 deletions internal/providers/proxmoxve/proxmoxve.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ import (
)

const (
cidataPath = "/user-data"
ciuserdataPath = "/user-data"
// See https://bugzilla.proxmox.com/show_bug.cgi?id=2429 for more details about vendordata
civendordataPath = "/vendor-data"
deviceLabel = "cidata"
)

Expand Down Expand Up @@ -123,20 +125,37 @@ func fetchConfigFromDevice(logger *log.Logger, ctx context.Context, path string)
)
}()

if !fileExists(filepath.Join(mnt, cidataPath)) {
return nil, nil
}
paths := []string{ciuserdataPath, civendordataPath}
header := []byte("#cloud-config\n")

contents, err := os.ReadFile(filepath.Join(mnt, cidataPath))
if err != nil {
return nil, err
}
for _, path := range paths {
fullPath := filepath.Join(mnt, path)
if !fileExists(fullPath) {
continue
}

header := []byte("#cloud-config\n")
if bytes.HasPrefix(contents, header) {
logger.Debug("config drive (%q) contains a cloud-config configuration, ignoring", path)
return nil, nil
contents, err := os.ReadFile(fullPath)
if err != nil {
// Log the error but continue to next file
logger.Debug("failed to read %q: %v", fullPath, err)
continue
}

// Skip if it's a cloud-config file
if bytes.HasPrefix(contents, header) {
logger.Debug("config drive (%q) contains a cloud-config configuration, ignoring", fullPath)
continue
}

// Check if there's actual content in the file
if len(contents) > 0 {
logger.Debug("config drive (%q) contains data", fullPath)
return contents, nil
}

logger.Debug("config drive (%q) is empty, ignoring", fullPath)
}

return contents, nil
// No valid configuration found in any of the files
return nil, nil
}
Loading