Skip to content

Commit

Permalink
make deploy-olm for 4.16
Browse files Browse the repository at this point in the history
Updates operator-sdk to versions that can `run bundle` with restricted security-context-config

Update controller-gen to v0.14.0 to avoid panic on newer golang and CRD_OPTIONS that works with it.

panic log
```
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=0x2 addr=0x0 pc=0x102676d94]

goroutine 23 [running]:
go/types.(*Checker).handleBailout(0x140008ec400, 0x1400323fd18)
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/go/types/check.go:367 +0x9c
panic({0x102936800?, 0x102eb3ce0?})
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/runtime/panic.go:770 +0x124
go/types.(*StdSizes).Sizeof(0x0, {0x1029fdb80, 0x102ebc5e0})
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/go/types/sizes.go:228 +0x314
go/types.(*Config).sizeof(...)
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/go/types/sizes.go:333
go/types.representableConst.func1({0x1029fdb80?, 0x102ebc5e0?})
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/go/types/const.go:76 +0x9c
go/types.representableConst({0x102a03ec0, 0x102e88720}, 0x140008ec400, 0x102ebc5e0, 0x1400323ce78)
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/go/types/const.go:106 +0x2b0
go/types.(*Checker).representation(0x140008ec400, 0x140013b5800, 0x102ebc5e0)
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/go/types/const.go:256 +0x68
go/types.(*Checker).representable(0x140008ec400, 0x140013b5800, 0x102ebc5e0)
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/go/types/const.go:239 +0x28
go/types.(*Checker).shift(0x140008ec400, 0x140013b57c0, 0x140013b5800, {0x102a01ca8, 0x140010360f0}, 0x14)
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/go/types/expr.go:650 +0x1d8
go/types.(*Checker).binary(0x140008ec400, 0x140013b57c0, {0x102a01ca8, 0x140010360f0}, {0x102a021b8, 0x14001026ba0}, {0x102a021b8, 0x14001026bc0}, 0x14, 0xa6c0)
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/go/types/expr.go:796 +0x100
go/types.(*Checker).exprInternal(0x140008ec400, 0x0, 0x140013b57c0, {0x102a01ca8, 0x140010360f0}, {0x0, 0x0})
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/go/types/expr.go:1416 +0x1d4
go/types.(*Checker).rawExpr(0x140008ec400, 0x0, 0x140013b57c0, {0x102a01ca8?, 0x140010360f0?}, {0x0?, 0x0?}, 0x0)
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/go/types/expr.go:979 +0x12c
go/types.(*Checker).expr(0x140008ec400, 0x102114d7c?, 0x140013b57c0, {0x102a01ca8?, 0x140010360f0?})
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/go/types/expr.go:1513 +0x38
go/types.(*Checker).constDecl(0x140008ec400, 0x140013d2d80, {0x0, 0x0}, {0x102a01ca8, 0x140010360f0}, 0x0)
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/go/types/decl.go:488 +0x23c
go/types.(*Checker).objDecl(0x140008ec400, {0x102a08e40, 0x140013d2d80}, 0x0)
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/go/types/decl.go:191 +0x84c
go/types.(*Checker).ident(0x140008ec400, 0x140013b5780, 0x14001026620, 0x0, 0x0)
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/go/types/typexpr.go:62 +0x1f0
go/types.(*Checker).exprInternal(0x140008ec400, 0x0, 0x140013b5780, {0x102a00808, 0x14001026620}, {0x0, 0x0})
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/go/types/expr.go:1033 +0x114
go/types.(*Checker).rawExpr(0x140008ec400, 0x0, 0x140013b5780, {0x102a00808?, 0x14001026620?}, {0x0?, 0x0?}, 0x0)
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/go/types/expr.go:979 +0x12c
go/types.(*Checker).expr(0x140008ec400, 0x2200010342430a?, 0x140013b5780, {0x102a00808?, 0x14001026620?})
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/go/types/expr.go:1513 +0x38
go/types.(*Checker).binary(0x140008ec400, 0x140013b5740, {0x102a01ca8, 0x14001036030}, {0x102a00808, 0x14001026600}, {0x102a00808, 0x14001026620}, 0xc, 0x9e41)
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/go/types/expr.go:784 +0x88
go/types.(*Checker).exprInternal(0x140008ec400, 0x0, 0x140013b5740, {0x102a01ca8, 0x14001036030}, {0x0, 0x0})
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/go/types/expr.go:1416 +0x1d4
go/types.(*Checker).rawExpr(0x140008ec400, 0x0, 0x140013b5740, {0x102a01ca8?, 0x14001036030?}, {0x0?, 0x0?}, 0x0)
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/go/types/expr.go:979 +0x12c
go/types.(*Checker).expr(0x140008ec400, 0x140013a3200?, 0x140013b5740, {0x102a01ca8?, 0x14001036030?})
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/go/types/expr.go:1513 +0x38
go/types.(*Checker).constDecl(0x140008ec400, 0x140013a32c0, {0x0, 0x0}, {0x102a01ca8, 0x14001036030}, 0x0)
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/go/types/decl.go:488 +0x23c
go/types.(*Checker).objDecl(0x140008ec400, {0x102a08e40, 0x140013a32c0}, 0x0)
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/go/types/decl.go:191 +0x84c
go/types.(*Checker).packageObjects(0x140008ec400)
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/go/types/resolver.go:693 +0x468
go/types.(*Checker).checkFiles(0x140008ec400, {0x14000191540, 0xa, 0xa})
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/go/types/check.go:408 +0x164
go/types.(*Checker).Files(...)
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/go/types/check.go:372
sigs.k8s.io/controller-tools/pkg/loader.(*loader).typeCheck(0x140002c8fc0, 0x14002f09c40)
        /Users/tiger/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/loader.go:283 +0x2d8
sigs.k8s.io/controller-tools/pkg/loader.(*Package).NeedTypesInfo(0x14002f09c40)
        /Users/tiger/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/loader.go:96 +0x44
sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check(0x14000fb1110, 0x14002f09c40)
        /Users/tiger/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/refs.go:263 +0x304
sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check.func1(0x0?)
        /Users/tiger/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/refs.go:257 +0x58
created by sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check in goroutine 1
        /Users/tiger/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/refs.go:255 +0x230
make[1]: *** [manifests] Error 2
```

Signed-off-by: Tiger Kaovilai <[email protected]>

Upgrade controller-gen so `make manifests` runs

Signed-off-by: Tiger Kaovilai <[email protected]>
  • Loading branch information
kaovilai committed Oct 1, 2024
1 parent 11aba28 commit 382a45a
Show file tree
Hide file tree
Showing 13 changed files with 688 additions and 205 deletions.
23 changes: 12 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:v$(VERSION)
# Image URL to use all building/pushing image targets
IMG ?= quay.io/konveyor/oadp-operator:oadp-1.3
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false"
CRD_OPTIONS ?= "crd"

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
Expand Down Expand Up @@ -228,14 +228,14 @@ docker-push: ## Push docker image with the manager.

##@ Deployment

install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
install: manifests ## Install CRDs into the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd | kubectl apply -f -

uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
uninstall: manifests ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd | kubectl delete -f -

VELERO_ROLE_TMP?=/tmp/oadp-make-deploy
velero-role-tmp: kustomize
velero-role-tmp:
mkdir -p $(VELERO_ROLE_TMP)
sed -e 's/namespace: system/namespace: $(OADP_TEST_NAMESPACE)/g' config/velero/velero-service_account.yaml > $(VELERO_ROLE_TMP)/velero-service_account.yaml
sed -e 's/namespace: system/namespace: $(OADP_TEST_NAMESPACE)/g' config/velero/velero-role.yaml > $(VELERO_ROLE_TMP)/velero-role.yaml
Expand All @@ -259,11 +259,10 @@ build-deploy: ## Build current branch image and deploy controller to the k8s clu

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

KUSTOMIZE = $(shell pwd)/bin/kustomize
kustomize: ## Download kustomize locally if necessary.
$(call go-install-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/[email protected])
# kustomize from go install wouldn't run in my env so replacing with go run.
KUSTOMIZE = go run sigs.k8s.io/kustomize/kustomize/[email protected]

# Codecov OS String for use in download url
ifeq ($(OS),Windows_NT)
Expand Down Expand Up @@ -314,12 +313,12 @@ operator-sdk:
# Download operator-sdk locally if does not exist
if [ ! -f $(OPERATOR_SDK) ]; then \
mkdir -p bin ;\
curl -Lo $(OPERATOR_SDK) https://github.com/operator-framework/operator-sdk/releases/download/v1.23.0/operator-sdk_$(shell go env GOOS)_$(shell go env GOARCH) ; \
curl -Lo $(OPERATOR_SDK) https://github.com/operator-framework/operator-sdk/releases/download/v1.31.0/operator-sdk_$(shell go env GOOS)_$(shell go env GOARCH) ; \
chmod +x $(OPERATOR_SDK); \
fi

.PHONY: bundle
bundle: manifests kustomize operator-sdk ## Generate bundle manifests and metadata, then validate generated files.
bundle: manifests operator-sdk ## Generate bundle manifests and metadata, then validate generated files.
GOFLAGS="-mod=mod" $(OPERATOR_SDK) generate kustomize manifests -q
cd config/manager && GOFLAGS="-mod=mod" $(KUSTOMIZE) edit set image controller=$(IMG)
GOFLAGS="-mod=mod" $(KUSTOMIZE) build config/manifests | GOFLAGS="-mod=mod" $(OPERATOR_SDK) generate bundle -q --extra-service-accounts "velero" --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
Expand All @@ -328,6 +327,8 @@ bundle: manifests kustomize operator-sdk ## Generate bundle manifests and metada
# TODO: update CI to use generated one
cp bundle.Dockerfile build/Dockerfile.bundle
GOFLAGS="-mod=mod" $(OPERATOR_SDK) bundle validate ./bundle
sed -e 's/ createdAt: .*/$(shell grep -I '^ createdAt: ' bundle/manifests/oadp-operator.clusterserviceversion.yaml)/' bundle/manifests/oadp-operator.clusterserviceversion.yaml > bundle/manifests/oadp-operator.clusterserviceversion.yaml.tmp
mv bundle/manifests/oadp-operator.clusterserviceversion.yaml.tmp bundle/manifests/oadp-operator.clusterserviceversion.yaml

.PHONY: nullables
nullables:
Expand Down Expand Up @@ -389,7 +390,7 @@ deploy-olm: operator-sdk undeploy-olm ## Build current branch operator image, bu
IMG=$(THIS_OPERATOR_IMAGE) BUNDLE_IMG=$(THIS_BUNDLE_IMAGE) \
make docker-build docker-push bundle bundle-build bundle-push; \
rm -rf $(DEPLOY_TMP)
$(OPERATOR_SDK) run bundle $(THIS_BUNDLE_IMAGE) --namespace $(OADP_TEST_NAMESPACE)
$(OPERATOR_SDK) run bundle $(THIS_BUNDLE_IMAGE) --namespace $(OADP_TEST_NAMESPACE) --security-context-config restricted

.PHONY: undeploy-olm
undeploy-olm: login-required ## Uninstall current branch operator via OLM
Expand Down
1 change: 0 additions & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/Dockerfile.bundle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
LABEL operators.operatorframework.io.bundle.package.v1=oadp-operator
LABEL operators.operatorframework.io.bundle.channels.v1=stable-1.3
LABEL operators.operatorframework.io.bundle.channel.default.v1=stable-1.3
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.23.0
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.34.2
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v3

Expand Down
2 changes: 1 addition & 1 deletion bundle.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
LABEL operators.operatorframework.io.bundle.package.v1=oadp-operator
LABEL operators.operatorframework.io.bundle.channels.v1=stable-1.3
LABEL operators.operatorframework.io.bundle.channel.default.v1=stable-1.3
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.23.0
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.34.2
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v3

Expand Down
4 changes: 2 additions & 2 deletions bundle/manifests/oadp-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ metadata:
Cloud Provider,Developer Tools,Modernization & Migration,OpenShift Optional,Storage
certified: "false"
containerImage: quay.io/konveyor/oadp-operator:oadp-1.3
createdAt: "2020-09-08T12:21:00Z"
createdAt: "2024-06-22T19:34:33Z"
description: OADP (OpenShift API for Data Protection) operator sets up and installs
Data Protection Applications on the OpenShift platform.
features.operators.openshift.io/cnf: "false"
Expand All @@ -172,7 +172,7 @@ metadata:
operators.openshift.io/infrastructure-features: '["Disconnected"]'
operators.openshift.io/valid-subscription: '["OpenShift Kubernetes Engine", "OpenShift
Container Platform", "OpenShift Platform Plus"]'
operators.operatorframework.io/builder: operator-sdk-v1.23.0
operators.operatorframework.io/builder: operator-sdk-v1.34.2
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
repository: https://github.com/openshift/oadp-operator
support: Red Hat
Expand Down
30 changes: 19 additions & 11 deletions bundle/manifests/oadp.openshift.io_cloudstorages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.6.1
controller-gen.kubebuilder.io/version: v0.14.0
creationTimestamp: null
name: cloudstorages.oadp.openshift.io
spec:
Expand All @@ -19,14 +19,19 @@ spec:
openAPIV3Schema:
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
metadata:
type: object
Expand All @@ -41,15 +46,18 @@ spec:
valid secret key.
type: string
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?'
description: |-
Name of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?
type: string
optional:
description: Specify whether the Secret or its key must be defined
type: boolean
required:
- key
type: object
x-kubernetes-map-type: atomic
enableSharedConfig:
description: enableSharedConfig enable the use of shared config loading
for AWS Buckets
Expand Down Expand Up @@ -96,5 +104,5 @@ status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
conditions: null
storedVersions: null
Loading

0 comments on commit 382a45a

Please sign in to comment.