WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@jjaferson
Copy link
Contributor

@jjaferson jjaferson commented Dec 4, 2025

What issue type does this pull request address? (keep at least one, remove the others)
/kind bugfix

What does this pull request do? Which issues does it resolve? (use resolves #<issue_number> if possible)
resolves ENG-9408

Please provide a short message that should be published in the vcluster release notes
Fixed an issue where vcluster was not being deleted due to the schema difference between vcluster v0.29 and v0.30

What else do we need to know?


Note

Gracefully handle PrivateNodes schema decode errors during deletion by warning and continuing, enabled by a new custom error and guard checks.

  • CLI (delete):
    • On Helm values → config.Config unmarshal failure due to PrivateNodes schema, log warning and proceed with deletion; skip namespace cleanup when config is unavailable.
  • Config:
    • Add ErrInvalidPrivateNodesConfig and custom PrivateNodes.UnmarshalJSON to wrap decode errors for clearer detection.

Written by Cursor Bugbot for commit c35abd0. This will update automatically on new commits. Configure here.

@jjaferson jjaferson requested a review from a team as a code owner December 4, 2025 15:42
return err
cmd.log.Warnf("Failed to parse vcluster config from Helm values: %v. ", err)
cmd.log.Infof("Continuing with deletion...")
vclusterConfig = nil
Copy link
Contributor

Choose a reason for hiding this comment

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

This approach is error prone, the code shouldn’t continue like this, especially since we already have cleanup logic implemented for synced namespaces. Moreover, other potential configuration issues (e.g., invalid sync.toHost fields) would go undetected.

I recommend implementing a custom UnmarshalJSON method for PrivateNodesAutoNodes that attempts to unmarshal the data and, if unsuccessful, returns a dedicated error (e.g., ErrInvalidAutoNodesConfig). Later, check whether the error from yaml.Unmarshal indicates an invalid auto nodes configuration if so, continue as normal, otherwise return the error.

Additionally, please add a comment explaining that we tolerate an invalid auto nodes configuration in the delete action because no cleanup or other follow-up action is required.

Copy link
Contributor Author

@jjaferson jjaferson Dec 5, 2025

Choose a reason for hiding this comment

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

I agree, I was trying to just fix the issue by warning the user that the vcluster config could not be parsed but the vcluster chart would be deleted.

NVM it won't work when we backport to v0.29 version
If we want we could make PrivateNodes backward compatible with older versions by creating a custom UnmarshalJSON that transform PrivateNodes.AutoNodes from an object to an array, instead of returning an dedicated error, what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, the error is enough.

func (p *PrivateNodes) UnmarshalJSON(data []byte) error {
type PrivateNodesAlias PrivateNodes
var alias PrivateNodesAlias
if err := json.Unmarshal(data, &alias); err != nil {
Copy link
Contributor

@flomedja flomedja Dec 6, 2025

Choose a reason for hiding this comment

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

(question) Do we want just to validate the marshalling or a stricter control on the input keys (by using DisallowUnknownFields with a json decoder) ?

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.

3 participants