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

Add validation to CRDUpgradeSafety preflight check to ensure default values for a field are not changed during an upgrade #949

Closed
rashmigottipati opened this issue May 2, 2024 · 1 comment
Labels
enhancement This issue is a feature request

Comments

@rashmigottipati
Copy link
Contributor

Now that there is a base CRDUpgradeSafety preflight check in place, we can continue adding validation logic based on the CRDUpgradeSafety preflight check proposal.

This issue focuses on adding another field change validation to the CRD Upgrade Safety checks to prevent changes to a fields default value for a given CRD version during an upgrade

As a potential source of inspiration, here is how a couple of the existing validations are implemented:

  • Definitions:
func NoScopeChange(old, new v1.CustomResourceDefinition) error { 
 	if old.Spec.Scope != new.Spec.Scope { 
 		return fmt.Errorf("scope changed from %q to %q", old.Spec.Scope, new.Spec.Scope) 
 	} 
 	return nil 
 } 
  
 func NoStoredVersionRemoved(old, new v1.CustomResourceDefinition) error { 
 	newVersions := sets.New[string]() 
 	for _, version := range new.Spec.Versions { 
 		if !newVersions.Has(version.Name) { 
 			newVersions.Insert(version.Name) 
 		} 
 	} 
  
 	for _, storedVersion := range old.Status.StoredVersions { 
 		if !newVersions.Has(storedVersion) { 
 			return fmt.Errorf("stored version %q removed", storedVersion) 
 		} 
 	} 
  
 	return nil 
 } 
  • Consumption:
Validations: []Validation{ 
 	NewValidationFunc("NoScopeChange", NoScopeChange), 
 	NewValidationFunc("NoStoredVersionRemoved", NoStoredVersionRemoved), 
 }, 
@rashmigottipati
Copy link
Contributor Author

Closing as completed via PR merged into kapp: #950

@github-project-automation github-project-automation bot moved this to Closed in Carvel May 8, 2024
@github-actions github-actions bot removed the carvel triage This issue has not yet been reviewed for validity label May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This issue is a feature request
Projects
Archived in project
Development

No branches or pull requests

1 participant