Skip to content
New issue

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

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

Already on GitHub? # to your account

Failed to load the resty.core module when using include with js_import in http-snippet #13135

Open
thisissoamazin opened this issue Mar 31, 2025 · 2 comments
Labels
kind/support Categorizes issue or PR as a support question. needs-priority needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.

Comments

@thisissoamazin
Copy link

thisissoamazin commented Mar 31, 2025

Adding module to the base image

I'm customizing the ingress-nginx controller by using a modified nginx-base image. Specifically, I want to add the NJS module to enable advanced CORS handling logic via js_import and js_header_filter directives.

I build my own nginx-base image based on registry.k8s.io/ingress-nginx/nginx:v1.2.1, only added the NJS module.

Source

Built from the helm-chart-4.12.1 branch

The issue

When I use the custom base image and enable my custom CORS logic via http-snippet in the HelmRelease config:

controller:
  config:
    http-snippet: |
      include /etc/nginx/CORS_http.conf;
cat /etc/nginx/CORS_http.conf
js_var $cors_config_file; # set or override in server or location contexts of nginx configuration to point to configuration file
js_var $cors_is_valid_preflight_request; # set by cors.header_filter to signal detection of a valid pre-flight request
js_import cors from /etc/nginx/njs/http/cors.js;

I get the following error:
failed to load the 'resty.core' module

2025/03/31 09:41:20 [alert] 18#18: failed to load the 'resty.core' module (https://github.com/openresty/lua-resty-core); ensure you are using an OpenResty release from https://openresty.org/en/download.html (reason: module 'resty.core' not found:
 no field package.preload['resty.core']
 no file '/etc/nginx/lua/resty/core.lua'
 no file '../lua-resty-core/lib/resty/core.lua'
 no file '../lua-resty-lrucache/lib/resty/core.lua'
 no file './resty/core.lua'
 no file '/usr/local/share/luajit-2.1/resty/core.lua'
 no file '/usr/local/share/lua/5.1/resty/core.lua'
 no file '/usr/local/share/lua/5.1/resty/core/init.lua'

Which seems unrelated to my CORS config or NJS module.

Why this is weird

This error disappears when I comment out the http-snippet. But the snippet itself only references js_import (NJS), and does not use Lua at all.

It seems like enabling NJS somehow triggers Lua module loading even when Lua isn't used.

What I want to know

  1. Is this behavior expected?

  2. Why does including an http-snippet that only uses js_import (NJS) cause the controller to try loading resty.core?

  3. Is there a config option to disable Lua entirely and avoid this error?

Also tried building from main, from branches starting with controller v1.12.0 down to v1.10.0, and from helm-chart-4.12.1 down to helm-chart-4.10.0 - same result every time.
Tried both building manually and using the current ci.yaml from a fork of the ingress-nginx repo.

Thanks in advance.

cc @rikatz @strongjz

@thisissoamazin thisissoamazin added the kind/bug Categorizes issue or PR as related to a bug. label Mar 31, 2025
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If Ingress contributors determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority labels Mar 31, 2025
@longwuyuan
Copy link
Contributor

/remove-kind bug
/kind support

We are not able to allocate developers to try modified images and load NJS module etc. The community meeting recording on youtube and announcements have details as to why.

Even internally we desired to move to njs but the idea is dropped as desired but not practical.

@k8s-ci-robot k8s-ci-robot added kind/support Categorizes issue or PR as a support question. and removed kind/bug Categorizes issue or PR as related to a bug. labels Apr 1, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
kind/support Categorizes issue or PR as a support question. needs-priority needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.
Projects
Development

No branches or pull requests

3 participants