Description of problem: The example go operator memcached-operator still use go 1.16 version.It might cause some problem about reflect.StructField during the build work. Version-Release number of selected component (if applicable): operator-sdk version: "v1.16.0-ocp", commit: "8dad7ace335d11ac79f1684e2a460dc34d910e0e", kubernetes version: "v1.22", go version: "go1.17.4", GOOS: "linux", GOARCH: "amd64" How reproducible: always Steps to Reproduce: 1. create the go operator memcached-operator by https://docs.openshift.com/container-platform/4.9/operators/operator_sdk/golang/osdk-golang-tutorial.html#osdk-golang-define-api_osdk-golang-tutorial 2.build the operator $make docker-build docker-push IMG=quay.io/xxxxx/memcached-operator:v4.10 Actual results: 1. Will meet error "sf.IsExported undefined (type reflect.StructField has no field or method IsExported" $ make docker-build docker-push IMG=quay.io/olmqe/memcached-operator:v4.10 /data/kaka/image/go/4.10/memcached-operator/bin/controller-gen rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases /data/kaka/image/go/4.10/memcached-operator/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..." go fmt ./... go vet ./... KUBEBUILDER_ASSETS="/home/cloud-user/.local/share/kubebuilder-envtest/k8s/1.22.1-linux-amd64" go test ./... -coverprofile cover.out ? github.com/example-inc/memcached-operator [no test files] ? github.com/example-inc/memcached-operator/api/v1 [no test files] ok github.com/example-inc/memcached-operator/controllers 5.590s coverage: 0.0% of statements docker build -t quay.io/olmqe/memcached-operator:v4.10 . Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg. STEP 1: FROM golang:1.16 AS builder STEP 2: WORKDIR /workspace --> Using cache b44c9fe3bb44fec142c57ed7bb840c4b4157e740df0d01f0e788abca64b711fc --> b44c9fe3bb4 STEP 3: COPY go.mod go.mod --> de2cd462f35 STEP 4: COPY go.sum go.sum --> a7183daf9e9 STEP 5: RUN go mod download --> 8f130ec6262 STEP 6: COPY main.go main.go --> 013ec0900df STEP 7: COPY api/ api/ --> e691f904a8f STEP 8: COPY controllers/ controllers/ --> efa9136c70b STEP 9: RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager main.go # sigs.k8s.io/json/internal/golang/encoding/json /go/pkg/mod/sigs.k8s.io/json.0-20211020170558-c049b76a60c6/internal/golang/encoding/json/encode.go:1249:12: sf.IsExported undefined (type reflect.StructField has no field or method IsExported) /go/pkg/mod/sigs.k8s.io/json.0-20211020170558-c049b76a60c6/internal/golang/encoding/json/encode.go:1255:18: sf.IsExported undefined (type reflect.StructField has no field or method IsExported) STEP 10: FROM registry.access.redhat.com/ubi8/ubi-minimal:8.3 Error: error building at STEP "RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager main.go": error while running runtime: exit status 2 make: *** [Makefile:110: docker-build] Error 125 2. The Docker file # Build the manager binary FROM golang:1.16 as builder ......... 3. The go.mod module github.com/example-inc/memcached-operator go 1.16 require ( ... ) ....... Expected results: 1. build operator image success 2. The Docker file # Build the manager binary FROM golang:1.17 as builder ......... 3. The go.mod module github.com/example-inc/memcached-operator go 1.17 require ( ... ) ....... Additional info:
This will be addressed for 4.11 when we sync operator-sdk 1.17 downstream.
This has been addressed by the v1.18.0 sync. https://github.com/openshift/ocp-release-operator-sdk/pull/234
verified.
operator-sdk version operator-sdk version: "v1.18.1-ocp", commit: "eb7df29d845ba00cee6f662ab7604644786198b4", kubernetes version: "v1.22", go version: "go1.17.4", GOOS: "linux", GOARCH: "amd64" $cat Dockerfile # Build the manager binary FROM golang:1.17 as builder $cat go.mod module github.com/example-inc/memcached-operator go 1.17 require ( github.com/onsi/ginkgo v1.16.5 github.com/onsi/gomega v1.17.0 k8s.io/apimachinery v0.23.0 k8s.io/client-go v0.23.0 sigs.k8s.io/controller-runtime v0.11.0 )
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory (Important: OpenShift Container Platform 4.11.0 bug fix and security update), and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHSA-2022:5069