Skip to content

Commit 77a269c

Browse files
committed
force delete crd work after deleting condition is true
Signed-off-by: Zhiwei Yin <[email protected]>
1 parent 264c871 commit 77a269c

File tree

52 files changed

+2980
-3056
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2980
-3056
lines changed

go.mod

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ require (
1919
github.com/spf13/pflag v1.0.6
2020
github.com/stolostron/cluster-lifecycle-api v0.0.0-20250521101300-d1731ad54b6d
2121
go.uber.org/zap v1.27.0
22-
golang.org/x/text v0.23.0
22+
golang.org/x/text v0.24.0
2323
k8s.io/api v0.32.4
2424
k8s.io/apiextensions-apiserver v0.32.2
2525
k8s.io/apimachinery v0.32.4
@@ -28,7 +28,7 @@ require (
2828
k8s.io/component-base v0.32.4
2929
k8s.io/klog/v2 v2.130.1
3030
k8s.io/utils v0.0.0-20241210054802-24370beab758
31-
open-cluster-management.io/api v0.16.2-0.20250527062515-98a1d87193c1
31+
open-cluster-management.io/api v1.0.1-0.20250722080758-779879f46835
3232
sigs.k8s.io/controller-runtime v0.20.2
3333
)
3434

@@ -39,7 +39,7 @@ require (
3939
github.com/openshift/hypershift/api v0.0.0-20241022184855-1fa7be0211e4
4040
github.com/sethvargo/go-password v0.2.0
4141
github.com/stretchr/testify v1.10.0
42-
open-cluster-management.io/ocm v0.16.1-0.20250527120941-4cbb12d5a262
42+
open-cluster-management.io/ocm v1.0.1-0.20250724011102-334710ce0e60
4343
sigs.k8s.io/cluster-api v1.9.3
4444
sigs.k8s.io/yaml v1.4.0
4545
)
@@ -81,7 +81,7 @@ require (
8181
github.com/golang/glog v1.2.4 // indirect
8282
github.com/golang/protobuf v1.5.4 // indirect
8383
github.com/google/btree v1.1.3 // indirect
84-
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect
84+
github.com/google/gnostic-models v0.6.9 // indirect
8585
github.com/google/gofuzz v1.2.0 // indirect
8686
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 // indirect
8787
github.com/google/uuid v1.6.0 // indirect
@@ -133,17 +133,17 @@ require (
133133
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
134134
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
135135
go.mongodb.org/mongo-driver v1.14.0 // indirect
136-
go.opentelemetry.io/otel v1.28.0 // indirect
137-
go.opentelemetry.io/otel/trace v1.28.0 // indirect
136+
go.opentelemetry.io/otel v1.33.0 // indirect
137+
go.opentelemetry.io/otel/trace v1.33.0 // indirect
138138
go.uber.org/automaxprocs v1.6.0 // indirect
139139
go.uber.org/multierr v1.11.0 // indirect
140-
golang.org/x/crypto v0.36.0 // indirect
140+
golang.org/x/crypto v0.37.0 // indirect
141141
golang.org/x/net v0.38.0 // indirect
142142
golang.org/x/oauth2 v0.28.0 // indirect
143-
golang.org/x/sync v0.12.0 // indirect
143+
golang.org/x/sync v0.13.0 // indirect
144144
golang.org/x/sys v0.32.0 // indirect
145-
golang.org/x/term v0.30.0 // indirect
146-
golang.org/x/time v0.7.0 // indirect
145+
golang.org/x/term v0.31.0 // indirect
146+
golang.org/x/time v0.9.0 // indirect
147147
golang.org/x/tools v0.31.0 // indirect
148148
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
149149
google.golang.org/protobuf v1.36.5 // indirect
@@ -154,9 +154,10 @@ require (
154154
gorm.io/gorm v1.24.5 // indirect
155155
helm.sh/helm/v3 v3.17.3 // indirect
156156
k8s.io/kube-aggregator v0.32.1 // indirect
157-
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect
157+
k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff // indirect
158158
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
159159
sigs.k8s.io/kube-storage-version-migrator v0.0.6-0.20230721195810-5c8923c5ff96 // indirect
160+
sigs.k8s.io/randfill v1.0.0 // indirect
160161
sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect
161162
)
162163

go.sum

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek
152152
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
153153
github.com/google/btree v1.1.3 h1:CVpQJjYgC4VbzxeGVHfvZrv1ctoYCAI8vbl07Fcxlyg=
154154
github.com/google/btree v1.1.3/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4=
155-
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 h1:0VpGH+cDhbDtdcweoyCVsF3fhN8kejK6rFe/2FFX2nU=
156-
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49/go.mod h1:BkkQ4L1KS1xMt2aWSPStnn55ChGC0DPOn2FQYj+f25M=
155+
github.com/google/gnostic-models v0.6.9 h1:MU/8wDLif2qCXZmzncUQ/BOfxWfthHi63KqpoNbWqVw=
156+
github.com/google/gnostic-models v0.6.9/go.mod h1:CiWsm0s6BSQd1hRn8/QmxqB6BesYcbSZxsz9b0KuDBw=
157157
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
158158
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
159159
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
@@ -429,10 +429,10 @@ github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1
429429
github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
430430
go.mongodb.org/mongo-driver v1.14.0 h1:P98w8egYRjYe3XDjxhYJagTokP/H6HzlsnojRgZRd80=
431431
go.mongodb.org/mongo-driver v1.14.0/go.mod h1:Vzb0Mk/pa7e6cWw85R4F/endUC3u0U9jGcNU603k65c=
432-
go.opentelemetry.io/otel v1.28.0 h1:/SqNcYk+idO0CxKEUOtKQClMK/MimZihKYMruSMViUo=
433-
go.opentelemetry.io/otel v1.28.0/go.mod h1:q68ijF8Fc8CnMHKyzqL6akLO46ePnjkgfIMIjUIX9z4=
434-
go.opentelemetry.io/otel/trace v1.28.0 h1:GhQ9cUuQGmNDd5BTCP2dAvv75RdMxEfTmYejp+lkx9g=
435-
go.opentelemetry.io/otel/trace v1.28.0/go.mod h1:jPyXzNPg6da9+38HEwElrQiHlVMTnVfM3/yv2OlIHaI=
432+
go.opentelemetry.io/otel v1.33.0 h1:/FerN9bax5LoK51X/sI0SVYrjSE0/yUL7DpxW4K3FWw=
433+
go.opentelemetry.io/otel v1.33.0/go.mod h1:SUUkR6csvUQl+yjReHu5uM3EtVV7MBm5FHKRlNx4I8I=
434+
go.opentelemetry.io/otel/trace v1.33.0 h1:cCJuF7LRjUFso9LPnEAHJDB2pqzp+hbO8eu1qqW2d/s=
435+
go.opentelemetry.io/otel/trace v1.33.0/go.mod h1:uIcdVUZMpTAmz0tI1z04GoVSezK37CbGV4fr1f2nBck=
436436
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
437437
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
438438
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
@@ -461,8 +461,8 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
461461
golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
462462
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
463463
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
464-
golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
465-
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
464+
golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE=
465+
golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc=
466466
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
467467
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
468468
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
@@ -505,8 +505,8 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ
505505
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
506506
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
507507
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
508-
golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw=
509-
golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
508+
golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610=
509+
golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
510510
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
511511
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
512512
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -545,19 +545,19 @@ golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
545545
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
546546
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
547547
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
548-
golang.org/x/term v0.30.0 h1:PQ39fJZ+mfadBm0y5WlL4vlM7Sx1Hgf13sMIY2+QS9Y=
549-
golang.org/x/term v0.30.0/go.mod h1:NYYFdzHoI5wRh/h5tDMdMqCqPJZEuNqVR5xJLd/n67g=
548+
golang.org/x/term v0.31.0 h1:erwDkOK1Msy6offm1mOgvspSkslFnIGsFnxOKoufg3o=
549+
golang.org/x/term v0.31.0/go.mod h1:R4BeIy7D95HzImkxGkTW1UQTtP54tio2RyHz7PwK0aw=
550550
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
551551
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
552552
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
553553
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
554554
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
555555
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
556556
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
557-
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
558-
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
559-
golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ=
560-
golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
557+
golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0=
558+
golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU=
559+
golang.org/x/time v0.9.0 h1:EsRrnYcQiGH+5FfbgvV4AP7qEZstoyrHB0DzarOQ4ZY=
560+
golang.org/x/time v0.9.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
561561
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
562562
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
563563
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
@@ -670,16 +670,16 @@ k8s.io/kube-aggregator v0.32.1 h1:cztPyIHbo6tgrhYHDqmdmvxUufJKuxgAC/vog7yeWek=
670670
k8s.io/kube-aggregator v0.32.1/go.mod h1:sXjL5T8FO/rlBzTbBhahw9V5Nnr1UtzZHKTj9WxQCOU=
671671
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65/go.mod h1:sX9MT8g7NVZM5lVL/j8QyCCJe8YSMW30QvGZWaCIDIk=
672672
k8s.io/kube-openapi v0.0.0-20220124234850-424119656bbf/go.mod h1:sX9MT8g7NVZM5lVL/j8QyCCJe8YSMW30QvGZWaCIDIk=
673-
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f h1:GA7//TjRY9yWGy1poLzYYJJ4JRdzg3+O6e8I+e+8T5Y=
674-
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f/go.mod h1:R/HEjbvWI0qdfb8viZUeVZm0X6IZnxAydC7YU42CMw4=
673+
k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff h1:/usPimJzUKKu+m+TE36gUyGcf03XZEP0ZIKgKj35LS4=
674+
k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8=
675675
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
676676
k8s.io/utils v0.0.0-20211116205334-6203023598ed/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
677677
k8s.io/utils v0.0.0-20241210054802-24370beab758 h1:sdbE21q2nlQtFh65saZY+rRM6x6aJJI8IUa1AmH/qa0=
678678
k8s.io/utils v0.0.0-20241210054802-24370beab758/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
679-
open-cluster-management.io/api v0.16.2-0.20250527062515-98a1d87193c1 h1:OAFgR9hrr3dpiwb+Pgz5gSKKdtnHwD8L+PkBd4HjHXc=
680-
open-cluster-management.io/api v0.16.2-0.20250527062515-98a1d87193c1/go.mod h1:/OeqXycNBZQoe3WG6ghuWsMgsKGuMZrK8ZpsU6gWL0Y=
681-
open-cluster-management.io/ocm v0.16.1-0.20250527120941-4cbb12d5a262 h1:lcaj0Ep+TOBPkE19u0Qiqu2d05pSrjDpqd7sF6lc8L8=
682-
open-cluster-management.io/ocm v0.16.1-0.20250527120941-4cbb12d5a262/go.mod h1:60fdcsEXEMe9sPag8R+a/VEwdmxIsh9VsnnWdmUtfA8=
679+
open-cluster-management.io/api v1.0.1-0.20250722080758-779879f46835 h1:am2IzUzjoTjgiicbCfzl7dTITdTo1PtcTuYX0P5KZ2I=
680+
open-cluster-management.io/api v1.0.1-0.20250722080758-779879f46835/go.mod h1:KEj/4wbUjdbWktrKLL8+mWzAIzE6Ii3bcRr4CvnBNEg=
681+
open-cluster-management.io/ocm v1.0.1-0.20250724011102-334710ce0e60 h1:bsHrwWYW5e0q5w9NovDeM9b4K9LqBnJMHXucKeUfOGA=
682+
open-cluster-management.io/ocm v1.0.1-0.20250724011102-334710ce0e60/go.mod h1:qxwXm6Z3OCDUUDznLmQVWk5A3CrHiE1G+TJ56DF+DXs=
683683
sigs.k8s.io/cluster-api v1.9.3 h1:lKWbrXzyNmJh++IcX54ZbAmnO7tZ2wKgds7WvskpiXY=
684684
sigs.k8s.io/cluster-api v1.9.3/go.mod h1:5iojv38PSvOd4cxqu08Un5TQmy2yBkd3+0U7R/e+msk=
685685
sigs.k8s.io/controller-runtime v0.20.2 h1:/439OZVxoEc02psi1h4QO3bHzTgu49bb347Xp4gW1pc=
@@ -689,8 +689,9 @@ sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 h1:gBQPwqORJ8d8/YNZWEjoZs7np
689689
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg=
690690
sigs.k8s.io/kube-storage-version-migrator v0.0.6-0.20230721195810-5c8923c5ff96 h1:PFWFSkpArPNJxFX4ZKWAk9NSeRoZaXschn+ULa4xVek=
691691
sigs.k8s.io/kube-storage-version-migrator v0.0.6-0.20230721195810-5c8923c5ff96/go.mod h1:EOBQyBowOUsd7U4CJnMHNE0ri+zCXyouGdLwC/jZU+I=
692-
sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016 h1:kXv6kKdoEtedwuqMmkqhbkgvYKeycVbC8+iPCP9j5kQ=
693692
sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY=
693+
sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU=
694+
sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY=
694695
sigs.k8s.io/structured-merge-diff/v4 v4.0.2/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw=
695696
sigs.k8s.io/structured-merge-diff/v4 v4.2.1/go.mod h1:j/nl6xW8vLS49O8YvXW1ocPhZawJtm+Yrr7PPRQ0Vg4=
696697
sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc=

pkg/controller/resourcecleanup/resourcecleanup_controller.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
utilerrors "k8s.io/apimachinery/pkg/util/errors"
1717
kevents "k8s.io/client-go/tools/events"
1818
clusterv1 "open-cluster-management.io/api/cluster/v1"
19+
workv1 "open-cluster-management.io/api/work/v1"
1920
"sigs.k8s.io/controller-runtime/pkg/client"
2021
logf "sigs.k8s.io/controller-runtime/pkg/log"
2122
"sigs.k8s.io/controller-runtime/pkg/reconcile"
@@ -218,9 +219,12 @@ func (r *ReconcileResourceCleanup) Cleanup(ctx context.Context, cluster *cluster
218219
if len(works.Items) == 1 && works.Items[0].Name == klusterletCRDWorkName {
219220
// the manifestWorks are deleted by registration controller.
220221
// the agent may be orphaned if the CRD manifestWork is force deleted directly.
221-
if works.Items[0].DeletionTimestamp.IsZero() {
222+
// so the crd is deleting when the deleting condition of crd work is true
223+
// and can force delete the crd work after the crd work is deleting.
224+
if !meta.IsStatusConditionTrue(works.Items[0].Status.Conditions, workv1.WorkDeleting) {
222225
return nil
223226
}
227+
224228
if err = helpers.ForceDeleteManifestWork(ctx, r.clientHolder.WorkClient, r.recorder,
225229
cluster.Name, klusterletCRDWorkName); err != nil {
226230
return err

pkg/controller/resourcecleanup/resourcecleanup_controller_test.go

Lines changed: 90 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func TestReconcile(t *testing.T) {
7777
},
7878
},
7979
{
80-
name: "default cluster is deleting and have klustereletCRD work",
80+
name: "default cluster is deleting and klustereletCRD work is not deleting and no finalizer",
8181
request: reconcile.Request{NamespacedName: types.NamespacedName{Name: "test"}},
8282
runtimeObjects: []client.Object{
8383
&clusterv1.ManagedCluster{
@@ -95,17 +95,101 @@ func TestReconcile(t *testing.T) {
9595
&corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: "test"}},
9696
},
9797
works: []runtime.Object{
98-
&workv1.ManifestWork{ObjectMeta: metav1.ObjectMeta{
99-
Name: "test-klusterlet-crds",
100-
Namespace: "test",
101-
DeletionTimestamp: &now}},
98+
&workv1.ManifestWork{
99+
ObjectMeta: metav1.ObjectMeta{
100+
Name: "test-klusterlet-crds",
101+
Namespace: "test",
102+
},
103+
},
104+
},
105+
requeue: true,
106+
validateFunc: func(t *testing.T, clientHolder *helpers.ClientHolder) {
107+
managedCluster := &clusterv1.ManagedCluster{}
108+
if err := clientHolder.RuntimeClient.Get(context.TODO(),
109+
types.NamespacedName{Name: "test"}, managedCluster); errors.IsNotFound(err) {
110+
t.Errorf("unexpected no cluster,but got error: %v", err)
111+
}
112+
},
113+
},
114+
{
115+
name: "default cluster is deleting and klustereletCRD work is deleting",
116+
request: reconcile.Request{NamespacedName: types.NamespacedName{Name: "test"}},
117+
runtimeObjects: []client.Object{
118+
&clusterv1.ManagedCluster{
119+
ObjectMeta: metav1.ObjectMeta{
120+
Name: "test",
121+
Finalizers: []string{constants.ImportFinalizer, constants.ManifestWorkFinalizer},
122+
DeletionTimestamp: &now,
123+
},
124+
Spec: clusterv1.ManagedClusterSpec{
125+
HubAcceptsClient: true,
126+
},
127+
},
128+
},
129+
kubeObjects: []runtime.Object{
130+
&corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: "test"}},
131+
},
132+
works: []runtime.Object{
133+
&workv1.ManifestWork{
134+
ObjectMeta: metav1.ObjectMeta{
135+
Name: "test-klusterlet-crds",
136+
Namespace: "test",
137+
DeletionTimestamp: &now,
138+
Finalizers: []string{workv1.ManifestWorkFinalizer},
139+
},
140+
},
141+
},
142+
requeue: true,
143+
validateFunc: func(t *testing.T, clientHolder *helpers.ClientHolder) {
144+
managedCluster := &clusterv1.ManagedCluster{}
145+
if err := clientHolder.RuntimeClient.Get(context.TODO(),
146+
types.NamespacedName{Name: "test"}, managedCluster); errors.IsNotFound(err) {
147+
t.Errorf("unexpected no cluster,but got error: %v", err)
148+
}
149+
},
150+
},
151+
{
152+
name: "default cluster is deleting and klustereletCRD work is deleting and have deleting condition",
153+
request: reconcile.Request{NamespacedName: types.NamespacedName{Name: "test"}},
154+
runtimeObjects: []client.Object{
155+
&clusterv1.ManagedCluster{
156+
ObjectMeta: metav1.ObjectMeta{
157+
Name: "test",
158+
Finalizers: []string{constants.ImportFinalizer, constants.ManifestWorkFinalizer},
159+
DeletionTimestamp: &now,
160+
},
161+
Spec: clusterv1.ManagedClusterSpec{
162+
HubAcceptsClient: true,
163+
},
164+
},
165+
},
166+
kubeObjects: []runtime.Object{
167+
&corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: "test"}},
168+
},
169+
works: []runtime.Object{
170+
&workv1.ManifestWork{
171+
ObjectMeta: metav1.ObjectMeta{
172+
Name: "test-klusterlet-crds",
173+
Namespace: "test",
174+
DeletionTimestamp: &now,
175+
Finalizers: []string{workv1.ManifestWorkFinalizer},
176+
},
177+
Status: workv1.ManifestWorkStatus{
178+
Conditions: []metav1.Condition{
179+
metav1.Condition{
180+
Type: workv1.WorkDeleting,
181+
Status: metav1.ConditionTrue,
182+
},
183+
},
184+
},
185+
},
102186
},
103187
requeue: false,
104188
validateFunc: func(t *testing.T, clientHolder *helpers.ClientHolder) {
105189
managedCluster := &clusterv1.ManagedCluster{}
106190
if err := clientHolder.RuntimeClient.Get(context.TODO(),
107191
types.NamespacedName{Name: "test"}, managedCluster); !errors.IsNotFound(err) {
108-
t.Errorf("unexpected no cluster,but got error: %v", err)
192+
t.Errorf("expected no cluster,but got error: %v", err)
109193
}
110194
},
111195
},

0 commit comments

Comments
 (0)