Skip to content

Commit 3a2c26b

Browse files
committed
Addressing review comments:
* Move applyset/applylib -> pkg/applylib * Add more docs * Add a reference to the applyset KEP in comments * Add docs.go and interface docs * Improvements: * remove caching a json marshalled copy of obj * Remove name/namespace in PruneObject and instead derive it from object. Also change object type from runtime.Object to unstructured. * use fieldmanager config param to remove kro hardcoding in applyset * Aggregate pruneErrors and applyErrors into single Errors() * add recordPruneObject helper * switched from waitGroup to errgroup when collecting objects to prune across namespaces * take logr as a config in ApplySet. Added more logging in applyset. * use superset of namespaces and GKs we compute before apply for pruning * Add simple tests in the applyset pkg * use namespace-scoped resource interface when pruning * use force=True when applying in setManaged() * Removed un-necessary deepcopy in updateParentLabelsAndAnnotations * Add Unit tests to verify pruning and apply logic * Fix bugs in pruning logic that missed old namespaces and GKs * Refactors: * add RestMapper to the client-set * use Unstrucutred in ApplyableObject instead of interface and forcing it to be unstructured in code * minor restruction in processLoad() method * Refactor code that was using errors.Join and an array * Use ContainsFinalizer * Converting unstructured to PartialObjectMetadata for parent in applyset. * Cleanups: * Fix typos in comments, prints etc * Remove obseleted comments * Make the exported resources strutter less, applyset.ApplySet -> applyset.Set, NewApplySet -> New etc. * Fix captilaization for var names. Uid -> UID, ... * use consts for labelManager strings * remove pure formatting changes in unrelated files to minimize PR changeset Split out: * Remove pkg/metadata/finalizer.go changes and create a separate PR kubernetes-sigs#625 * move envtest makefile changes to kubernetes-sigs#636 * removing labeller changes and moving them to kubernetes-sigs#631 * Fix regression when removing labeller changes: `dynamic-controller Error syncing item, requeuing with rate limit {"item": {"NamespacedKey":"chainsaw-special-quail/test-instance","GVR":{"Group":"kro.run","Version":"v1alpha1","Resource":"checkinstancecreationsimpledeployments"}}, "error": "failed to setup instance: failed to set finalizer: error getting finalizers: .metadata.finalizers accessor error: [] is of the type []string, expected []interface{}"}`
1 parent a48bcd0 commit 3a2c26b

File tree

21 files changed

+1346
-311
lines changed

21 files changed

+1346
-311
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ deploy-kind: ko
278278
# This generates deployment with ko://... used in image.
279279
# ko then intercepts it builds image, pushes to kind node, replaces the image in deployment and applies it
280280
helm template kro ./helm --namespace kro-system --set image.pullPolicy=Never --set image.ko=true --set config.allowCRDDeletion=true | $(KO) apply -f -
281+
sleep 5
281282
kubectl wait --for=condition=ready --timeout=1m pod -n kro-system -l app.kubernetes.io/component=controller
282283
$(KUBECTL) --context kind-${KIND_CLUSTER_NAME} get pods -A
283284

go.mod

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ require (
1515
github.com/stretchr/testify v1.10.0
1616
go.uber.org/zap v1.26.0
1717
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56
18+
golang.org/x/sync v0.12.0
1819
golang.org/x/time v0.3.0
1920
google.golang.org/genproto/googleapis/api v0.0.0-20240826202546-f6391c0de4c7
2021
k8s.io/api v0.31.0
@@ -26,7 +27,7 @@ require (
2627
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8
2728
sigs.k8s.io/controller-runtime v0.19.0
2829
sigs.k8s.io/release-utils v0.11.0
29-
sigs.k8s.io/yaml v1.4.0
30+
sigs.k8s.io/yaml v1.6.0
3031
)
3132

3233
require (
@@ -86,6 +87,7 @@ require (
8687
github.com/x448/float16 v0.8.4 // indirect
8788
github.com/xlab/treeprint v1.2.0 // indirect
8889
go.uber.org/multierr v1.11.0 // indirect
90+
go.yaml.in/yaml/v2 v2.4.2 // indirect
8991
golang.org/x/mod v0.22.0 // indirect
9092
golang.org/x/net v0.38.0 // indirect
9193
golang.org/x/oauth2 v0.28.0 // indirect

go.sum

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,10 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
299299
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
300300
go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo=
301301
go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so=
302+
go.yaml.in/yaml/v2 v2.4.2 h1:DzmwEr2rDGHl7lsFgAHxmNz/1NlQ7xLIrlN2h5d1eGI=
303+
go.yaml.in/yaml/v2 v2.4.2/go.mod h1:081UH+NErpNdqlCXm3TtEran0rJZGxAYx9hb/ELlsPU=
304+
go.yaml.in/yaml/v3 v3.0.3 h1:bXOww4E/J3f66rav3pX3m8w6jDE4knZjGOw8b5Y6iNE=
305+
go.yaml.in/yaml/v3 v3.0.3/go.mod h1:tBHosrYAkRZjRAOREWbDnBXUf08JOwYq++0QNwQiWzI=
302306
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
303307
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
304308
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
@@ -398,6 +402,8 @@ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJ
398402
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
399403
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
400404
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
405+
golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw=
406+
golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
401407
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
402408
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
403409
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -659,5 +665,5 @@ sigs.k8s.io/release-utils v0.11.0 h1:FUVSw2dO67M7mfcQx9AITEGnTHoBOdJNbbQ3FT3o8mA
659665
sigs.k8s.io/release-utils v0.11.0/go.mod h1:wAlXz8xruzvqZUsorI64dZ3lbkiDnYSlI4IYC6l2yEA=
660666
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4=
661667
sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08=
662-
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
663-
sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY=
668+
sigs.k8s.io/yaml v1.6.0 h1:G8fkbMSAFqgEFgh4b1wmtzDnioxFCUgTZhlbj5P9QYs=
669+
sigs.k8s.io/yaml v1.6.0/go.mod h1:796bPqUfzR/0jLAl6XjHl3Ck7MiyVv8dbTdyT3/pMf4=

0 commit comments

Comments
 (0)