Skip to content

Conversation

@Marouan-chak
Copy link

Description

This PR changes the unmarshal method from yaml.UnmarshalStrict to yaml.Unmarshal in the hostpaths.go file to allow forward compatibility with newer vCluster configurations.

Problem

When running the hostpath-mapper with newer vCluster configurations that include fields not yet defined in the current Config struct (like "reuseNamespace"), the application fails with an error:

E0312 14:36:54.634840 1 hostpaths.go:269] unmarshal config.yaml: &errors.errorString{s:"while decoding JSON: json: unknown field \"reuseNamespace\""}
Error: find vcluster mode: error unmarshaling JSON: while decoding JSON: json: unknown field "reuseNamespace"

Solution

By switching to yaml.Unmarshal instead of yaml.UnmarshalStrict, we allow the parser to ignore fields that are not defined in the target struct, providing forward compatibility with future vCluster configuration versions.

Testing

Tested by running the hostpath-mapper with a configuration that includes the "reuseNamespace" field. After this change, the application starts successfully and properly processes the configuration.

…bility

This change allows the hostpath-mapper to work with newer vCluster configurations that might contain fields not defined in the current Config struct.

Previously, when using UnmarshalStrict, the mapper would fail with an error like: 'error unmarshaling JSON: while decoding JSON: json: unknown field "reuseNamespace"'

Using regular Unmarshal provides forward compatibility with future configuration options.
@hellt
Copy link

hellt commented Mar 15, 2025

I hit this as well with vcluster 0.23.0 and hpm 0.2.0 loft-sh/vcluster#1745 (comment)

@zerbitx zerbitx requested a review from neogopher March 26, 2025 11:41
@zerbitx
Copy link

zerbitx commented Mar 26, 2025

Thanks @Marouan-chak! @neogopher if you'd like to comment here, I believe what we want to do is update the github.com/loft-sh/vcluster dependency in go.mod and do another release rather than relaxing the yaml marshaling.

@neogopher
Copy link
Contributor

neogopher commented Apr 30, 2025

That's correct @zerbitx.

@m-chakran @hellt
I have created the v0.2.1 release now that tracks an incorporates all changes uptil v0.24.

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.

5 participants