Skip to content

Refactor provisioner interaction with freshly created nginx resources #3969

@bjee19

Description

@bjee19

In the nginx provisioner, we call RegisterGateway to create nginx resources upon initial gateway creation. However, with each of the objects initially created, a handler upsert event occurs and updateOrDeleteResources is called, which calls for the provision of nginx again.

This is unnecessary and can potentially be a spot for errors. This also creates incorrect/unneeded log verbosity. See below for example logs:

{"level":"info","ts":"2025-09-26T17:51:38Z","msg":"Starting the NGINX Gateway Fabric control plane","version":"edge","commit":"183dc72d183c2197edc91481a7ba3388aa01424f","date":"2025-09-18T21:39:39Z","dirty":"true"}
{"level":"info","ts":"2025-09-26T17:51:38Z","msg":"Starting manager"}
{"level":"info","ts":"2025-09-26T17:51:38Z","logger":"controller-runtime.metrics","msg":"Starting metrics server"}
{"level":"info","ts":"2025-09-26T17:51:38Z","logger":"controller-runtime.metrics","msg":"Serving metrics server","bindAddress":":9113","secure":false}
{"level":"info","ts":"2025-09-26T17:51:38Z","msg":"starting server","name":"health probe","addr":"[::]:8081"}
{"level":"info","ts":"2025-09-26T17:51:39Z","msg":"attempting to acquire leader lease nginx-gateway/my-release-nginx-gateway-fabric-leader-election..."}
{"level":"info","ts":"2025-09-26T17:51:39Z","logger":"eventLoop.eventHandler","msg":"Reconfigured control plane.","batchID":2}
{"level":"info","ts":"2025-09-26T17:51:53Z","logger":"eventHandler","msg":"NGINX configuration was successfully updated"}
{"level":"info","ts":"2025-09-26T17:51:55Z","msg":"successfully acquired lease nginx-gateway/my-release-nginx-gateway-fabric-leader-election"}
{"level":"info","ts":"2025-09-26T17:51:55Z","logger":"telemetryJob","msg":"Starting cronjob"}
We are in register gateway
{"level":"info","ts":"2025-09-26T17:51:55Z","logger":"provisioner","msg":"Creating/Updating nginx resources","namespace":"default","nginx resource name":"gateway-nginx","resources":["gateway-nginx-agent-tls","gateway-nginx-includes-bootstrap","gateway-nginx-agent-config","gateway-nginx","gateway-nginx","gateway-nginx"]}
We are in secret gateway-nginx-agent-tls
{"level":"info","ts":"2025-09-26T17:51:55Z","logger":"provisioner","msg":"Creating/Updating nginx resources","namespace":"default","nginx resource name":"gateway-nginx","resources":["gateway-nginx-includes-bootstrap"]}
We are in the main case gateway-nginx-includes-bootstrap
We are in update or delete resources
We are in provision resource
We are in the main case gateway-nginx-agent-config
We are in update or delete resources
We are in provision resource
{"level":"info","ts":"2025-09-26T17:51:55Z","logger":"provisioner","msg":"Creating/Updating nginx resources","namespace":"default","nginx resource name":"gateway-nginx","resources":["gateway-nginx-agent-config"]}
We are in the main case gateway-nginx
We are in update or delete resources
{"level":"info","ts":"2025-09-26T17:51:55Z","logger":"provisioner","msg":"Creating/Updating nginx resources","namespace":"default","nginx resource name":"gateway-nginx","resources":["gateway-nginx"]}
We are in provision resource
We are in service gateway-nginx
We are in the main case gateway-nginx
We are in update or delete resources
{"level":"info","ts":"2025-09-26T17:51:55Z","logger":"provisioner","msg":"Creating/Updating nginx resources","namespace":"default","nginx resource name":"gateway-nginx","resources":["gateway-nginx"]}
We are in provision resource
{"level":"info","ts":"2025-09-26T17:51:56Z","logger":"eventHandler","msg":"NGINX configuration was successfully updated"}
{"level":"info","ts":"2025-09-26T17:51:56Z","logger":"eventHandler","msg":"NGINX configuration was successfully updated"}
{"level":"info","ts":"2025-09-26T17:52:04Z","logger":"nginxUpdater.commandService","msg":"Creating connection for nginx pod: gateway-nginx-69d5fc8c96-c75b9"}
{"level":"info","ts":"2025-09-26T17:52:05Z","logger":"nginxUpdater.commandService","msg":"Successfully connected to nginx agent gateway-nginx-69d5fc8c96-c75b9"}
{"level":"info","ts":"2025-09-26T17:52:05Z","logger":"nginxUpdater.commandService","msg":"Sending initial configuration to agent","pod":"gateway-nginx-69d5fc8c96-c75b9","configVersion":"/ceG1UvyWu96vCETC8ATBBr5KB3rl6czLi0ItT5Z1LE="}
{"level":"info","ts":"2025-09-26T17:52:05Z","logger":"nginxUpdater.commandService","msg":"Successfully configured nginx for new subscription","pod":"gateway-nginx-69d5fc8c96-c75b9"}
{"level":"info","ts":"2025-09-26T17:52:05Z","logger":"eventHandler","msg":"NGINX configuration was successfully updated"}

Each of the "Creating/Updating nginx resources" after the one called by RegisterGateway are unneeded.

Another example of extreme log verbosity upon deploying a single application is here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Status

    🆕 New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions