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

IgnoreVolumeClaimTemplateTypeMetaAndStatus looks not work #51

Open
Rory-Z opened this issue Jan 24, 2022 · 3 comments
Open

IgnoreVolumeClaimTemplateTypeMetaAndStatus looks not work #51

Rory-Z opened this issue Jan 24, 2022 · 3 comments

Comments

@Rory-Z
Copy link

Rory-Z commented Jan 24, 2022

Describe the bug
IgnoreVolumeClaimTemplateTypeMetaAndStatus looks not work

Steps to reproduce the issue:
I tried to compare the two statefulsets like this

opts := []patch.CalculateOption{
    patch.IgnoreStatusFields(), 
    patch.IgnoreVolumeClaimTemplateTypeMetaAndStatus(),
}
patchResult, err := patch.DefaultPatchMaker.Calculate(old, new, opts...)
fmt.Printf("==========================%+v\n", patchResult.String())

I got this

Patch: {"spec":{"volumeClaimTemplates":[{"metadata":{"name":"emqx-data","namespace":"default"},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"20Mi"}},"storageClassName":"standard"},"status":{"phase":"Pending"}},{"metadata":{"name":"emqx-log","namespace":"default"},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"20Mi"}},"storageClassName":"standard"},"status":{"phase":"Pending"}}]}} 

volumeClaimTemplates is not ignored

Expected behavior
volumeClaimTemplates should be ignored

Additional context
k8s-objectmatcher version: v1.7.0
go version: go1.17.3 darwin/amd64

@iamabhishek-dubey
Copy link

Same for me as well

@mobasherul
Copy link

Similar error for me -
PatchResult is not empty even when patch.IgnoreVolumeClaimTemplateTypeMetaAndStatus())
"{"spec":{"volumeClaimTemplates":[{"metadata":{"name":"corestore""

@iamabhishek-dubey
Copy link

iamabhishek-dubey commented May 24, 2022

@mobasherul I forked this project and fixed it

github.com/iamabhishek-dubey/k8s-objectmatcher/patch

Example:-

	patchResult, err := patch.DefaultPatchMaker.Calculate(storedStateful, newStateful,
		patch.IgnoreStatusFields(),
		patch.IgnoreVolumeClaimTemplateTypeMetaAndStatus(),
		patch.IgnorePersistenVolumeFields(),
		patch.IgnoreField("kind"),
		patch.IgnoreField("apiVersion"),
		patch.IgnoreField("metadata"),
	)

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

No branches or pull requests

3 participants