Skip to content

Commit d145e0e

Browse files
authored
MGMT-18606: Update controller-gen to 0.14 (#145)
The version of `controller-gen` that we currently use (0.6.1) crashes when running with recent versions of Go. For example: ``` $ go version go version go1.22.5 linux/amd64 $ make build Installing sigs.k8s.io/controller-tools/cmd/[email protected] Installing github.com/golang/mock/mockgen@latest cd api; /files/projects/openshift/cluster-api-provider-agent/repository/bin/controller-gen object:headerFile="../hack/boilerplate.go.txt" paths="./..." panic: runtime error: invalid memory address or nil pointer dereference [recovered] panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x9ed5cf] ``` The oldest version that doesn't fail like that is 0.14. This patch updates to that version. Note that according to the `controller-gen` documentation version 0.14 of the tool is compatible with `k8s.io` and `client-go` version 0.29 or newer, and we are currently in 0.28, so in theory we should use version 0.13 of `controller-gen`, but it crashes as well. A side effect of the update that is that we can no longer use the `crd:preserveUnknownFields=false` option. But that is the default with the version of the CRD API that we use. The changes to the generated Go and YAML aren't relevant, mostly minor formatting changes in _description_ fields. Related: https://issues.redhat.com/browse/MGMT-18606 Related: https://github.com/kubernetes-sigs/controller-tools?tab=readme-ov-file#compatibility Signed-off-by: Juan Hernandez <[email protected]>
1 parent a40d69b commit d145e0e

File tree

9 files changed

+308
-284
lines changed

9 files changed

+308
-284
lines changed

Makefile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ IMG ?= controller:latest
4040
NAMESPACE ?= cluster-api-provider-agent
4141
WATCH_NAMESPACE ?= ""
4242
AGENTS_NAMESPACE ?= ""
43-
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
44-
CRD_OPTIONS ?= "crd:preserveUnknownFields=false"
4543
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
4644
ENVTEST_K8S_VERSION = 1.21
4745

@@ -83,8 +81,8 @@ help: ## Display this help.
8381

8482
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
8583
# The generate in the api dir is required since it's a different go (sub)modules
86-
cd api; $(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=../config/crd/bases
87-
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
84+
cd api; $(CONTROLLER_GEN) crd rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=../config/crd/bases
85+
$(CONTROLLER_GEN) crd rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
8886

8987
generate: controller-gen mockgen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
9088
cd api; $(CONTROLLER_GEN) object:headerFile="../hack/boilerplate.go.txt" paths="./..."
@@ -149,7 +147,7 @@ undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/confi
149147

150148
CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
151149
controller-gen: ## Download controller-gen locally if necessary.
152-
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.6.1)
150+
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.14.0)
153151

154152
KUSTOMIZE = $(shell pwd)/bin/kustomize
155153
kustomize: ## Download kustomize locally if necessary.

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/capi-provider.agent-install.openshift.io_agentclusters.yaml

Lines changed: 73 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
21
---
32
apiVersion: apiextensions.k8s.io/v1
43
kind: CustomResourceDefinition
54
metadata:
65
annotations:
7-
controller-gen.kubebuilder.io/version: v0.6.1
8-
creationTimestamp: null
6+
controller-gen.kubebuilder.io/version: v0.14.0
97
name: agentclusters.capi-provider.agent-install.openshift.io
108
spec:
119
group: capi-provider.agent-install.openshift.io
@@ -24,14 +22,19 @@ spec:
2422
description: AgentCluster is the Schema for the agentclusters API
2523
properties:
2624
apiVersion:
27-
description: 'APIVersion defines the versioned schema of this representation
28-
of an object. Servers should convert recognized schemas to the latest
29-
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
25+
description: |-
26+
APIVersion defines the versioned schema of this representation of an object.
27+
Servers should convert recognized schemas to the latest internal value, and
28+
may reject unrecognized values.
29+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
3030
type: string
3131
kind:
32-
description: 'Kind is a string value representing the REST resource this
33-
object represents. Servers may infer this from the endpoint the client
34-
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
32+
description: |-
33+
Kind is a string value representing the REST resource this object represents.
34+
Servers may infer this from the endpoint the client submits requests to.
35+
Cannot be updated.
36+
In CamelCase.
37+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
3538
type: string
3639
metadata:
3740
type: object
@@ -58,9 +61,9 @@ spec:
5861
endpoint.
5962
properties:
6063
caCertificateReference:
61-
description: CaCertificateReference is a reference to the secret
62-
containing CA certificate to be used when contacting the URL
63-
via HTTPS.
64+
description: |-
65+
CaCertificateReference is a reference to the secret containing CA certificate to be used
66+
when contacting the URL via HTTPS.
6467
properties:
6568
name:
6669
description: Name is the name of the secret containing the
@@ -102,37 +105,37 @@ spec:
102105
operational state.
103106
properties:
104107
lastTransitionTime:
105-
description: Last time the condition transitioned from one status
106-
to another. This should be when the underlying condition changed.
107-
If that is not known, then using the time when the API field
108-
changed is acceptable.
108+
description: |-
109+
Last time the condition transitioned from one status to another.
110+
This should be when the underlying condition changed. If that is not known, then using the time when
111+
the API field changed is acceptable.
109112
format: date-time
110113
type: string
111114
message:
112-
description: A human readable message indicating details about
113-
the transition. This field may be empty.
115+
description: |-
116+
A human readable message indicating details about the transition.
117+
This field may be empty.
114118
type: string
115119
reason:
116-
description: The reason for the condition's last transition
117-
in CamelCase. The specific API may choose whether or not this
118-
field is considered a guaranteed API. This field may not be
119-
empty.
120+
description: |-
121+
The reason for the condition's last transition in CamelCase.
122+
The specific API may choose whether or not this field is considered a guaranteed API.
123+
This field may not be empty.
120124
type: string
121125
severity:
122-
description: Severity provides an explicit classification of
123-
Reason code, so the users or machines can immediately understand
124-
the current situation and act accordingly. The Severity field
125-
MUST be set only when Status=False.
126+
description: |-
127+
Severity provides an explicit classification of Reason code, so the users or machines can immediately
128+
understand the current situation and act accordingly.
129+
The Severity field MUST be set only when Status=False.
126130
type: string
127131
status:
128132
description: Status of the condition, one of True, False, Unknown.
129133
type: string
130134
type:
131-
description: Type of condition in CamelCase or in foo.example.com/CamelCase.
132-
Many .condition.type values are consistent across resources
133-
like Available, but because arbitrary conditions can be useful
134-
(see .node.status.conditions), the ability to deconflict is
135-
important.
135+
description: |-
136+
Type of condition in CamelCase or in foo.example.com/CamelCase.
137+
Many .condition.type values are consistent across resources like Available, but because arbitrary conditions
138+
can be useful (see .node.status.conditions), the ability to deconflict is important.
136139
type: string
137140
required:
138141
- lastTransitionTime
@@ -142,9 +145,9 @@ spec:
142145
type: array
143146
failureDomains:
144147
additionalProperties:
145-
description: FailureDomainSpec is the Schema for Cluster API failure
146-
domains. It allows controllers to understand how many failure
147-
domains a cluster can optionally span across.
148+
description: |-
149+
FailureDomainSpec is the Schema for Cluster API failure domains.
150+
It allows controllers to understand how many failure domains a cluster can optionally span across.
148151
properties:
149152
attributes:
150153
additionalProperties:
@@ -176,14 +179,19 @@ spec:
176179
description: AgentCluster is the Schema for the agentclusters API
177180
properties:
178181
apiVersion:
179-
description: 'APIVersion defines the versioned schema of this representation
180-
of an object. Servers should convert recognized schemas to the latest
181-
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
182+
description: |-
183+
APIVersion defines the versioned schema of this representation of an object.
184+
Servers should convert recognized schemas to the latest internal value, and
185+
may reject unrecognized values.
186+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
182187
type: string
183188
kind:
184-
description: 'Kind is a string value representing the REST resource this
185-
object represents. Servers may infer this from the endpoint the client
186-
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
189+
description: |-
190+
Kind is a string value representing the REST resource this object represents.
191+
Servers may infer this from the endpoint the client submits requests to.
192+
Cannot be updated.
193+
In CamelCase.
194+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
187195
type: string
188196
metadata:
189197
type: object
@@ -210,9 +218,9 @@ spec:
210218
endpoint.
211219
properties:
212220
caCertificateReference:
213-
description: CaCertificateReference is a reference to the secret
214-
containing CA certificate to be used when contacting the URL
215-
via HTTPS.
221+
description: |-
222+
CaCertificateReference is a reference to the secret containing CA certificate to be used
223+
when contacting the URL via HTTPS.
216224
properties:
217225
name:
218226
description: Name is the name of the secret containing the
@@ -254,37 +262,37 @@ spec:
254262
operational state.
255263
properties:
256264
lastTransitionTime:
257-
description: Last time the condition transitioned from one status
258-
to another. This should be when the underlying condition changed.
259-
If that is not known, then using the time when the API field
260-
changed is acceptable.
265+
description: |-
266+
Last time the condition transitioned from one status to another.
267+
This should be when the underlying condition changed. If that is not known, then using the time when
268+
the API field changed is acceptable.
261269
format: date-time
262270
type: string
263271
message:
264-
description: A human readable message indicating details about
265-
the transition. This field may be empty.
272+
description: |-
273+
A human readable message indicating details about the transition.
274+
This field may be empty.
266275
type: string
267276
reason:
268-
description: The reason for the condition's last transition
269-
in CamelCase. The specific API may choose whether or not this
270-
field is considered a guaranteed API. This field may not be
271-
empty.
277+
description: |-
278+
The reason for the condition's last transition in CamelCase.
279+
The specific API may choose whether or not this field is considered a guaranteed API.
280+
This field may not be empty.
272281
type: string
273282
severity:
274-
description: Severity provides an explicit classification of
275-
Reason code, so the users or machines can immediately understand
276-
the current situation and act accordingly. The Severity field
277-
MUST be set only when Status=False.
283+
description: |-
284+
Severity provides an explicit classification of Reason code, so the users or machines can immediately
285+
understand the current situation and act accordingly.
286+
The Severity field MUST be set only when Status=False.
278287
type: string
279288
status:
280289
description: Status of the condition, one of True, False, Unknown.
281290
type: string
282291
type:
283-
description: Type of condition in CamelCase or in foo.example.com/CamelCase.
284-
Many .condition.type values are consistent across resources
285-
like Available, but because arbitrary conditions can be useful
286-
(see .node.status.conditions), the ability to deconflict is
287-
important.
292+
description: |-
293+
Type of condition in CamelCase or in foo.example.com/CamelCase.
294+
Many .condition.type values are consistent across resources like Available, but because arbitrary conditions
295+
can be useful (see .node.status.conditions), the ability to deconflict is important.
288296
type: string
289297
required:
290298
- lastTransitionTime
@@ -294,9 +302,9 @@ spec:
294302
type: array
295303
failureDomains:
296304
additionalProperties:
297-
description: FailureDomainSpec is the Schema for Cluster API failure
298-
domains. It allows controllers to understand how many failure
299-
domains a cluster can optionally span across.
305+
description: |-
306+
FailureDomainSpec is the Schema for Cluster API failure domains.
307+
It allows controllers to understand how many failure domains a cluster can optionally span across.
300308
properties:
301309
attributes:
302310
additionalProperties:
@@ -322,9 +330,3 @@ spec:
322330
storage: true
323331
subresources:
324332
status: {}
325-
status:
326-
acceptedNames:
327-
kind: ""
328-
plural: ""
329-
conditions: []
330-
storedVersions: []

0 commit comments

Comments
 (0)