aws-controllers-k8s / community

AWS Controllers for Kubernetes (ACK) is a project enabling you to manage AWS services from Kubernetes
https://aws-controllers-k8s.github.io/community/
Apache License 2.0
2.42k stars 255 forks source link

Integration tests fail on Amazon Linux 2 #265

Closed smuralee closed 4 years ago

smuralee commented 4 years ago

Describe the bug Mockery dry-run fails for make kind-test SERVICE=s3

/home/linuxbrew/.linuxbrew/bin/mockery --tags=codegen --case=underscore --output=mocks/pkg/generate/config/ --dir=pkg/generate/config/ --all
02 Sep 20 18:10 UTC INF Starting mockery dry-run=false version=2.2.1
02 Sep 20 18:10 UTC INF Walking dry-run=false version=2.2.1
02 Sep 20 18:10 UTC ERR Error parsing file error="/home/ec2-user/go/src/github.com/aws/aws-controllers-k8s/pkg/generate/config/config.go:189:60: Operation not declared by package api" dry-run=false version=2.2.1
/home/linuxbrew/.linuxbrew/bin/mockery --tags=codegen --case=underscore --output=mocks/pkg/generate/testdata/ --dir=pkg/generate/testdata/ --all
02 Sep 20 18:10 UTC INF Starting mockery dry-run=false version=2.2.1
02 Sep 20 18:10 UTC INF Walking dry-run=false version=2.2.1
go test -tags codegen ./...
# runtime/cgo
_cgo_export.c:3:20: fatal error: stdlib.h: No such file or directory
compilation terminated.
FAIL    github.com/aws/aws-controllers-k8s/pkg/generate [build failed]
FAIL    github.com/aws/aws-controllers-k8s/pkg/model [build failed]
FAIL    github.com/aws/aws-controllers-k8s/pkg/names [build failed]
FAIL    github.com/aws/aws-controllers-k8s/pkg/requeue [build failed]
FAIL    github.com/aws/aws-controllers-k8s/pkg/runtime [build failed]
FAIL    github.com/aws/aws-controllers-k8s/services/bookstore/pkg/resource [build failed]
FAIL    github.com/aws/aws-controllers-k8s/services/bookstore/pkg/resource/book [build failed]
FAIL    github.com/aws/aws-controllers-k8s/services/petstore/pkg/resource [build failed]
FAIL    github.com/aws/aws-controllers-k8s/services/petstore/pkg/resource/pet [build failed]
make: *** [Makefile:25: test] Error 2

Steps to reproduce

Expected outcome Successful execution of the kind-test for this S3 service

Environment

GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/ec2-user/.cache/go-build"
GOENV="/home/ec2-user/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/ec2-user/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/ec2-user/go"
GOPRIVATE=""
GOPROXY="direct"
GOROOT="/home/linuxbrew/.linuxbrew/Cellar/go/1.15/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/linuxbrew/.linuxbrew/Cellar/go/1.15/libexec/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc-5"
CXX="g++-5"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build801398810=/tmp/go-build -gno-record-gcc-switches"
nithu0115 commented 4 years ago

@smuralee

02 Sep 20 18:10 UTC ERR Error parsing file error="/home/ec2-user/go/src/github.com/aws/aws-controllers-k8s/pkg/generate/config/config.go:189:60: Operation not declared by package api" dry-run=false version=2.2.1

copy mockery binary to under /home/ec2-user/go/bin which should resolve above issue as your GOPATH is /home/ec2-user/go

_cgo_export.c:3:20: fatal error: stdlib.h: No such file or directory compilation terminated.

This seems there is no system headers installed. Either install them sudo yum install make glibc-devel gcc patch or try setting CGO_ENABLED=0 and see if that helps!

smuralee commented 4 years ago

@nithu0115

copy mockery binary to under /home/ec2-user/go/bin which should resolve above issue as your GOPATH is /home/ec2-user/go

Mockery was installed with Homebrew and it was on the path. I have moved it to $GOPATH/bin using go get github.com/vektra/mockery/v2/.../ but the error is there.

03 Sep 20 07:02 UTC ERR Error parsing file error="/home/ec2-user/go/src/github.com/aws/aws-controllers-k8s/pkg/generate/config/config.go:189:60: Operation not declared by package api" dry-run=false version=0.0.0-dev
/home/ec2-user/go/bin/mockery --tags=codegen --case=underscore --output=mocks/pkg/generate/testdata/ --dir=pkg/generate/testdata/ --all

This seems there is no system headers installed. Either install them sudo yum install make glibc-devel gcc patch or try setting CGO_ENABLED=0 and see if that helps!

Setting CGO_ENABLED=0 in .bash_profile resolved it. Thanks!

Temporary credentials generated
deployment.apps/ack-s3-controller env updated
Added AWS Credentials to env vars map
======================================================================================================
To poke around your test manually:
export KUBECONFIG=/home/ec2-user/go/src/github.com/aws/aws-controllers-k8s/scripts/../build/tmp-test-bb733669/kubeconfig
kubectl get pods -A
======================================================================================================
bucket.s3.services.k8s.aws/ack-test-smoke-s3-123456789012 created
{
  "CreationDate": "2020-09-03T07:04:21.000Z",
  "Name": "ack-test-smoke-s3-123456789012"
}
bucket.s3.services.k8s.aws "ack-test-smoke-s3-123456789012" deleted
smoke took 23 second(s)
To resume test with the same cluster use: "-c /home/ec2-user/go/src/github.com/aws/aws-controllers-k8s/scripts/../build/tmp-test-bb733669"
nithu0115 commented 4 years ago

Mockery was installed with Homebrew and it was on the path. I have moved it to $GOPATH/bin using go get github.com/vektra/mockery/v2/.../ but the error is there.

I tried replicating the same on AL2 and had no issues. I used ./scripts/install_mockery.sh to get the binary and manually copied the mockery binary under $GOPATH/bin. However, I haven't tried using Homebrew. Try doing it this way and see if that helps!

smuralee commented 4 years ago

I tried replicating the same on AL2 and had no issues. I used ./scripts/install_mockery.sh to get the binary and manually copied the mockery binary under $GOPATH/bin. However, I haven't tried using Homebrew. Try doing it this way and see if that helps!

@nithu0115 Didn't work for me. For my local macOS I had to change the download to mockery Darwin_x86_64.tar.gz and the same error came up again. It's the awssdkmodel.Operation which is having issues. I have got the Go SDK with go get -u github.com/aws/aws-sdk-go/...

jaypipes commented 4 years ago

Make sure you are supplying the -tags codegen if you call mockery. The awssdkmodel.Operation is a struct that is in a "hidden" package aws-sdk-go/private/model/api that is guarded by a build: codegen tag:

https://github.com/aws/aws-sdk-go/blob/d07b568f515fe1b3ad3a066f3396565a914efdb0/private/model/api/api.go#L1

smuralee commented 4 years ago

@jaypipes Yes the tag is passed and this issue does not happen with mockery 1.0.1. The 2.1.0 gives those errors.

a-hilaly commented 4 years ago

I can confirm that this issue doesn't happen with any mockery of version v1.x.x. Using v2.x.x the flag --tags doesn't seem to solve it, i guess this is happening because mockery doesn't build the vendors with the given build tags. I'll open an issue in the mockery repository and send a PR fixing scripts/install-mockery for now

LandonTClipp commented 4 years ago

Thanks for the mockery PR. v2 has this issue fixed now so feel free to move back to that when you are ready.

a-hilaly commented 4 years ago

Thanks for the help and patch release @LandonTClipp

I tested make mocks with mockery v2.2.2 and it's working as expected.