Skip to content

worker_process unpopulated after upgrade to 1.10.2 #12393

Closed
@CatbirdBasil

Description

@CatbirdBasil

What happened:

I'm developing a custom Nginx C Module and I rely on worker_processes (ngx_core_conf_t) during module init to allocate some data. I noticed that when upgrading from 1.10.1 to 1.10.2 this value is no longer populated at both config reading stage and module init stage.

Development Guide

What you expected to happen:

Expected worker_processes variable to be populated as it is only filled in by Nginx when reading configuration (either flat number or calculated afterwards when using auto keyword)

ngx_core_conf_t *core_main_conf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
int num_of_workers = core_main_conf->worker_processes; // This one is -1 but I expected it to be 4

NGINX Ingress controller version (exec into the pod and run /nginx-ingress-controller --version): 1.10.2

Anything else we need to know:

I actually conducted an investigation of this as it didn't make sense to me at all. And after I found our what causes it .. it's still not making any sense.

The issue is caused by the patches you introduced in version 1.10.2 for Nginx of version 1.25.3.
To be more precise this patch https://github.com/kubernetes/ingress-nginx/blob/main/images/nginx/rootfs/patches/11_nginx-1.25.3-privileged_agent_process.patch
To be even more precise, adding those lines:

diff --git a/src/core/ngx_cycle.h b/src/core/ngx_cycle.h
index c51b7ff..3261f90 100644
--- a/src/core/ngx_cycle.h
+++ b/src/core/ngx_cycle.h
@@ -22,6 +22,9 @@
 #define NGX_DEBUG_POINTS_ABORT  2
 
 
+#define HAVE_PRIVILEGED_PROCESS_PATCH   1
+
+
 typedef struct ngx_shm_zone_s  ngx_shm_zone_t;
 
 typedef ngx_int_t (*ngx_shm_zone_init_pt) (ngx_shm_zone_t *zone, void *data);
@@ -81,6 +84,7 @@ struct ngx_cycle_s {
 typedef struct {
     ngx_flag_t                daemon;
     ngx_flag_t                master;
+    ngx_flag_t                privileged_agent;
 
     ngx_msec_t                timer_resolution;

The most strange part - you have to include both those changes to break worker_processes. Including just one is working fine. And I looked at the ngx_cycle.h after the patch and it looks perfectly fine.

*Yep I run all the patches one by one to see what caused and issue and then isolated the problematic patch and it still falied so I started cutting from the patch to see exact faulty lines.

I have no idea why this causes such behavior as of now. And I know you took those patches from Openresty but for some reason in Openresty everything is fine and working when I use their images with Nginx 1.25.3. Tried applying their patches but I lacked some of their stuff so stopped this part of investigation.

This issue prevents me from allocating memory properly and only way I can overcome it is to guestimate using number of cpu's to support strange configs that don't go for 1 core = 1 worker

P.S Sorry that I skipped all the version infra stuff, excluded it as I was able to reproduce even without using Ingress

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.lifecycle/frozenIndicates that an issue or PR should not be auto-closed due to staleness.needs-priorityneeds-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions