Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dev env on aarch64 hosts #1381

Merged
merged 9 commits into from
Jan 20, 2023
Merged

Fix dev env on aarch64 hosts #1381

merged 9 commits into from
Jan 20, 2023

Conversation

guicassolato
Copy link
Collaborator

@guicassolato guicassolato commented Nov 24, 2022

Fixes multiple issues to build and run the development environment on aarch64-based host machines, caused by several incompatible dependencies.

  • build and run dev image targeting linux/amd64 platform
  • deps: IPC::Run (preinstalled) - because otherwise Test-Nginx cannot be installed
  • deps: lua-resty-jwt v0.2.0 (installed with Rover) - because latest version (v0.2.3) requires incompatible lua-resty-openssl
  • deps: jsonschema v0.8 (installed with Rover) - because latest version (v0.9.8) requires incompatible lrexlib-pcre.
  • deps: luaossl 20200709 (preinstalled) - because latest (20220711) cannot be compiled with OpenSSL 1.1.1 on an aarch64 host (ref)
  • deps: deps: nginx-lua-prometheus v0.20181120 - to avoid "module 'nginx.prometheus' not found" when running the tests
  • deps: lua-resty-http v0.15 - to avoid string vs table type when deep invoking is_fqdn from apicast.configuration_loader.remote_v1:download → resty.resolver.http:request_uri
  • fix: test assertion of a falsy value passing no argument – no longer the same as passing nil since luassert v1.9.0.

Closes #1375.

Verification steps

(Optional) Build your own dev image:

make dev-build

Run the dev env:

make development IMAGE=apicast-development:latest

...or using a prebuilt image containing the fixes:

make development IMAGE=quay.io/guicassolato/3scale:apicast-dev-20221124

Within the container, install the dependencies:

make dependencies

After several minutes, installation should finish successfully:

Complete! Modules were bundled into /opt/app-root/src/vendor/cache

Run the tests:

make busted
# 1208 successes / 0 failures / 0 errors / 3 pending : 24.479539 seconds
make prove
# All tests successful.
# Files=85, Tests=3397, 1601 wallclock secs ( 1.52 usr  0.20 sys + 3998.34 cusr 406.44 csys = 4406.50 CPU)
# Result: PASS
# Success

Future improvement

Ditch Lua Rover altogether and use LuaRocks directly instead to install the dependencies.

@guicassolato guicassolato requested a review from a team as a code owner November 24, 2022 11:30
@guicassolato guicassolato self-assigned this Nov 24, 2022
@@ -72,7 +72,7 @@ dev-build: export OPENRESTY_RPM_VERSION?=1.19.3
dev-build: export LUAROCKS_VERSION?=2.3.0
dev-build: IMAGE_NAME ?= apicast-development:latest
dev-build: ## Build development image
$(DOCKER) build -t $(IMAGE_NAME) \
$(DOCKER) build --platform linux/amd64 -t $(IMAGE_NAME) \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't be this multiplatform?

Dockerfile.devel Show resolved Hide resolved
@eguzki
Copy link
Member

eguzki commented Nov 28, 2022

Which docker-compose version are you using?

With docker-compose version 1.25.0, build unknown, I get the follwing when running make development IMAGE=apicast-development:latest

❯ make development IMAGE=apicast-development:latest
Running on Linux
docker-compose -f docker-compose-devel.yml -f docker-compose-devel-volmount-default.yml up -d
ERROR: The Compose file './docker-compose-devel.yml' is invalid because:
Unsupported config option for services.development: 'platform'
make: [Makefile:204: development] Error 1 (ignored)
docker-compose -f docker-compose-devel.yml -f docker-compose-devel-volmount-default.yml exec -e COLUMNS="`tput cols`" -e LINES="`tput lines`" --user 1000:1000 development bash
ERROR: The Compose file './docker-compose-devel.yml' is invalid because:
Unsupported config option for services.development: 'platform'
make: *** [Makefile:206: development] Error 1

BTW, should we replace docker-compose python based v1 of https://github.com/docker/compose to v2, written in go?? (not part of this PR obviously)

@guicassolato
Copy link
Collaborator Author

Which docker-compose version are you using?

$ docker-compose version
Docker Compose version v2.12.2

@eguzki
Copy link
Member

eguzki commented Nov 28, 2022

Upgraded docker-compose to v2.13.0. After the major upgrade, seems that the docker compose files are still valid. I would not expect after a major upgrade, but happy to see we can safely upgrade.

make development works

make dependencies inside the container works

however, tests fail. Run make busted inside the container. Many missing libraries. The library lookup is broken

spec/policy/custom_metrics/custom_metrics_spec.lua:1: module 'apicast.policy.custom_metrics' not found:
	no field package.preload['apicast.policy.custom_metrics']
/opt/app-root/src/gateway/src/apicast/prometheus.lua:1: module 'nginx.prometheus' not found:
	no field package.preload['nginx.prometheus']

@eguzki
Copy link
Member

eguzki commented Jan 12, 2023

working locally 💃

we can expect tests in CircleCI to fail as they are using old dev image.

@eguzki
Copy link
Member

eguzki commented Jan 12, 2023

I have pushed the new dev image to quay: quay.io/3scale/apicast-ci:openresty-1.19.3-pr1381

Can you update the image URL references from the repo?? That should make the tests pass. The references:

❯ ag --hidden quay.io/3scale/apicast-ci:openresty-1.19.3
docker-compose-devel.yml
5:    image: ${IMAGE:-quay.io/3scale/apicast-ci:openresty-1.19.3}

Makefile
15:DEVEL_IMAGE ?= quay.io/3scale/apicast-ci:openresty-1.19.3
66:#     make dev-build IMAGE_NAME=quay.io/3scale/apicast-ci:openresty-1.19.3
68:#     docker push quay.io/3scale/apicast-ci:openresty-1.19.3

.circleci/config.yml
115:      - image: quay.io/3scale/apicast-ci:openresty-1.19.3

Ensures Perl IPC::Run module is preinstalled in the image or the installation of Test-Nginx will fail when the host's arch is aarch64.
This will avoid for now bumping `lua-resty-jwt` to a newer version (v0.2.3+) which requires `lua-resty-openssl` >= v0.6.8 (see [1]) and fails, at least on darwin/arm64 platform, with `attempt to index local 'rockspec' (a nil value) stack traceback`.

[1] https://github.com/cdbattags/lua-resty-jwt/blob/b3d5c085643fa95099e72a609c57095802106ff9/lua-resty-jwt-dev-0.rockspec#L19

Reported in #1375.
This will avoid for now bumping the `jsonschema` module to v0.9.8+, which depends on lrexlib-pcre v2.9.1-1 (see [1]) and fails, at least on darwin/arm64 platform, with `Could not find header file for PCRE` when running `rover install`.

[1] https://github.com/api7/jsonschema/blob/0096f5e5bfdd210136a98e9d50799d86b9bd040c/rockspec/jsonschema-0.9.8-0.rockspec#L23

Reported in #1375
So Rover doesn't try to install luaossl 20220711 (latest) which is incompatible with OpenSSL 1.1.1 (at least when the host's arch is arm64). See wahern/luaossl#175 (comment).
This will avoid make busted from failing with "module 'nginx.prometheus' not found".
This will prevent (apicast.configuration_loader.remote_v1)loader.download from failing in gateway/src/resty/resolver.lua:358 with "bad argument #1 to 'is_fqdn' (string expected, got table)".
Since luassert v1.9.0, function assert.truthy and assert.falsy check for the number of arguments passed which must be >= 1. See lunarmodules/luassert@4e799e7.
Because no retun and returning nil are two different things in Lua, upgrading luassert was causing the tests for apicast.configuration_loader.configure to fail.
@eguzki
Copy link
Member

eguzki commented Jan 19, 2023

awesome work @guicassolato 🎖️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setup local env fails
2 participants