Open aliok opened 2 years ago
As a workaround, what I did locally is, I change the cmd
function here: https://github.com/knative-sandbox/reconciler-test/blob/be32f9c185c5e5596c24c7a70831fe15032d6f81/pkg/images/cmd.go#L26-L31
func cmd(cmdLine string) *exec.Cmd {
cmdSplit := strings.Split(cmdLine, " ")
cmd := cmdSplit[0]
args := cmdSplit[1:]
c := exec.Command(cmd, args...)
c.Env = os.Environ()
c.Env = append(c.Env, "GOOS=linux")
c.Env = append(c.Env, "CGO_ENABLED=0")
c.Stderr = os.Stdout // Pipe the stderr in stdout
return c
}
I also removed the PLATFORM
env var.
Why CGO_ENABLED=0
? I was having this issue due to cross compilation: https://github.com/golang/go/issues/22510
This issue is stale because it has been open for 90 days with no
activity. It will automatically close after 30 more days of
inactivity. Reopen the issue with /reopen
. Mark the issue as
fresh by adding the comment /remove-lifecycle stale
.
I bumped into a similar issue today. This time with an Apple Silicon machine:
logger.go:130: 2024-09-19T12:00:12.656+0300 DEBUG ko/cmd.go:55 2024/09/19 12:00:12 Using base gcr.io/distroless/static:nonroot@sha256:dcd3f1f09adef5689088c9c4d96a8d98c889d8281d3946145074f89eafe7e1af for knative.dev/reconciler-test/cmd/eventshub {"test": "TestIntegration"}
logger.go:130: 2024-09-19T12:00:12.681+0300 DEBUG ko/cmd.go:55 Error: failed to publish images: error building "ko://knative.dev/reconciler-test/cmd/eventshub": no matching platforms in base image index {"test": "TestIntegration"}
logger.go:130: 2024-09-19T12:00:12.703+0300 DEBUG ko/cmd.go:55 2024/09/19 12:00:12 error during command execution:failed to publish images: error building "ko://knative.dev/reconciler-test/cmd/eventshub": no matching platforms in base image index {"test": "TestIntegration"}
...
logger.go:130: 2024-09-19T12:01:29.025+0300 WARN environment/images.go:100 Ko publish failed, using image directly {"test": "TestIntegration", "error": "ko publish failed: exit status 1 -- command: [\"go\" \"run\" \"github.com/google/ko@v0.11.2\" \"publish\" \"-B\" \"knative.dev/reconciler-test/cmd/eventshub\"]", "image": "knative.dev/reconciler-test/cmd/eventshub"}
Ok, this time, I don't change the vendored reconciler-test
code.
Instead,
go run github.com/google/ko@v0.11.2 publish -B knative.dev/reconciler-test/cmd/eventshub
docker.io/aliok/eventshub@sha256:8d039adcf7a375adeab0954786fbb9da615973c09001de87a3a6dfc19fae2b78
or docker.io/aliok/eventshub:latest
ctx, env := global.Environment(
...
// TODO: remove
eventshub.WithCustomImage("docker.io/aliok/eventshub:latest"),
)
I am running some reconciler tests (specifically, the ones in Knative Eventing) on my MacOS machine.
The framework tries to do
ko publish
: https://github.com/knative-sandbox/reconciler-test/blob/be32f9c185c5e5596c24c7a70831fe15032d6f81/pkg/images/ko.go#L25When I pass a
PLATFORM=linux/amd64
env var, this time I get this:...and, I cannot set
GOOS
env var to my call for test as it doesn't make sense.