solo-io / gloo

The Feature-rich, Kubernetes-native, Next-Generation API Gateway Built on Envoy
https://docs.solo.io/
Apache License 2.0
4.07k stars 435 forks source link

Review plugin development guide to see if it can work for M1 #7908

Open sheidkamp opened 1 year ago

sheidkamp commented 1 year ago

Version

1.13.x (latest stable)

Is your feature request related to a problem? Please describe.

When trying to stand up the now-deprecated hmac-auth plugin, I ran into AMD/M1 compatibility issues.

There is dependency, , documented in our auth plugin development guide that describes a dependency: verify-plugins-linux-amd64: a script to verify that the plugin can be loaded by the given Gloo Edge version. which I believe is the issue.

To reproduce on an M1 Mac, checkout the hmac-auth repository and apply the following diff:

index 0d05374..776f8a2 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -6,6 +6,9 @@ FROM $GO_BUILD_IMAGE AS build-env
 # Install packages needed for compilation
 RUN apk add --no-cache gcc musl-dev

+# https://stackoverflow.com/questions/71718772/how-to-solve-running-gcc-failed-exist-status-1-in-mac-m1
+RUN apk update && apk add gcc make git libc-dev binutils-gold
+
 # This must contain the value of the `gcflag` build flag that Gloo was built with
 ARG GC_FLAGS
 # This must contain the path to the plugin verification script
@@ -25,8 +28,10 @@ WORKDIR /go/src/github.com/solo-io/hmac-auth
 # This way the go tool will not need to fetch any packages from remote repositories.
 RUN if [[ $OFFLINE_BUILD == "true" ]]; then mkdir -p /go/pkg/mod && tar -xvf mod-cache-*.tar.gz -C /go/pkg/mod; else apk add --no-cache git; fi

-# Build plugin with CGO enabled
-ENV CGO_ENABLED=1 GOARCH=amd64 GOOS=linux
+# Build plugin with CGO enabled 
+# https://github.com/confluentinc/confluent-kafka-go/issues/898#issuecomment-1313054432
+ENV CGO_ENABLED=1 
+#GOARCH=amd64 GOOS=linux
 RUN go build -buildmode=plugin -gcflags="$GC_FLAGS" -o HmacAuth.so main.go

 # Verify that plugin can be loaded by GlooE
diff --git a/scripts/build_mod_cache/Dockerfile b/scripts/build_mod_cache/Dockerfile
index 6d6c3aa..7bf0cee 100644
--- a/scripts/build_mod_cache/Dockerfile
+++ b/scripts/build_mod_cache/Dockerfile
@@ -6,6 +6,9 @@ FROM $GO_BUILD_IMAGE AS build-env
 # Install packages needed for compilation
 RUN apk add --no-cache gcc musl-dev git

+# https://stackoverflow.com/questions/71718772/how-to-solve-running-gcc-failed-exist-status-1-in-mac-m1
+RUN apk update && apk add gcc make git libc-dev binutils-gold
+
 # This must contain the value of the `gcflag` build flag that Gloo was built with
 ARG GC_FLAGS
 ARG GLOOE_VERSION
@@ -15,8 +18,10 @@ ADD . /go/src/github.com/solo-io/hmac-auth/
 WORKDIR /go/src/github.com/solo-io/hmac-auth

 # Build plugin with CGO enabled
-ENV CGO_ENABLED=1 GOARCH=amd64 GOOS=linux
-RUN go build -buildmode=plugin -gcflags="$GC_FLAGS" -o HmacAuth.so main.go
+# https://github.com/confluentinc/confluent-kafka-go/issues/898#issuecomment-1313054432
+ENV CGO_ENABLED=1 
+#GOARCH=amd64 GOOS=linux
+RUN go build -tags dynamic -buildmode=plugin -gcflags="$GC_FLAGS" -o HmacAuth.so main.go

 RUN tar -zvcf mod-cache-$GLOOE_VERSION.tar.gz -C /go/pkg/mod .
 RUN mv mod-cache-$GLOOE_VERSION.tar.gz /mod-cache-$GLOOE_VERSION.tar.gz```

 and follow the setup steps in the readme.

 When you get to the command:
 `make build-plugins GLOOE_VERSION=1.6.2 "DOCKER_BUILD_ARGS=-t gcr.io/solo-test-236622/hmac-plugin:test"`

 you will get (or at least I get) the error:

 ``` => [build-env  9/10] RUN chmod +x _glooe/verify-plugins-linux-amd64                                                                                                                            0.4s 
 => ERROR [build-env 10/10] RUN _glooe/verify-plugins-linux-amd64 -pluginDir . -manifest plugin_manifest.yaml                                                                                   0.3s 
------                                                                                                                                                                                               
 > [build-env 10/10] RUN _glooe/verify-plugins-linux-amd64 -pluginDir . -manifest plugin_manifest.yaml:                                                                                              
#19 0.326 qemu-x86_64: Could not open '/lib/ld-musl-x86_64.so.1': No such file or directory                                                                                                          
------                                                                                                                                                                                               
executor failed running [/bin/sh -c $VERIFY_SCRIPT -pluginDir . -manifest plugin_manifest.yaml]: exit code: 255
make: *** [build-plugins] Error 1

Describe the solution you'd like

Validation/investigation by another developer and an assessment of the level of effort needed to make plug-ins and the documentation available on all architectures.

Describe alternatives you've considered

No response

Additional Context

No response

github-actions[bot] commented 3 months ago

This issue has been marked as stale because of no activity in the last 180 days. It will be closed in the next 180 days unless it is tagged "no stalebot" or other activity occurs.