Skip to content

Remove sock files on nginx startup #2131

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

Merged
merged 13 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert "Move config-version sock and update docs"
This reverts commit 990c3c4.
  • Loading branch information
ciarams87 committed Jun 21, 2024
commit c26665792bc2564fe03596669e63aa85c9514551
2 changes: 1 addition & 1 deletion internal/mode/static/nginx/config/version_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package config

const versionTemplateText = `
server {
listen unix:/var/lib/nginx/nginx-config-version.sock;
listen unix:/var/run/nginx/nginx-config-version.sock;
access_log off;

location /version {
Expand Down
2 changes: 1 addition & 1 deletion internal/mode/static/nginx/runtime/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"k8s.io/apimachinery/pkg/util/wait"
)

const configVersionURI = "/var/lib/nginx/nginx-config-version.sock"
const configVersionURI = "/var/run/nginx/nginx-config-version.sock"

var noNewWorkersErrFmt = "reload unsuccessful: no new NGINX worker processes started for config version %d." +
" Please check the NGINX container logs for possible configuration issues: %w"
Expand Down
4 changes: 2 additions & 2 deletions site/content/overview/gateway-architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ The following list describes the connections, preceeded by their types in parent
- Write: _NGF_ generates NGINX _configuration_ based on the cluster resources and writes them as `.conf` files to the mounted `nginx-conf` volume, located at `/etc/nginx/conf.d`. It also writes _TLS certificates_ and _keys_ from [TLS secrets](https://kubernetes.io/docs/concepts/configuration/secret/#tls-secrets) referenced in the accepted Gateway resource to the `nginx-secrets` volume at the path `/etc/nginx/secrets`.
- Read: _NGF_ reads the PID file `nginx.pid` from the `nginx-run` volume, located at `/var/run/nginx`. _NGF_ extracts the PID of the nginx process from this file in order to send reload signals to _NGINX master_.
1. (File I/O) _NGF_ writes logs to its _stdout_ and _stderr_, which are collected by the container runtime.
1. (HTTP) _NGF_ fetches the NGINX metrics via the unix:/var/lib/nginx/nginx-status.sock UNIX socket and converts it to _Prometheus_ format used in #2.
1. (HTTP) _NGF_ fetches the NGINX metrics via the unix:/var/run/nginx/nginx-status.sock UNIX socket and converts it to _Prometheus_ format used in #2.
1. (Signal) To reload NGINX, _NGF_ sends the [reload signal](https://nginx.org/en/docs/control.html) to the **NGINX master**.
1. (File I/O)
- Write: The _NGINX master_ writes its PID to the `nginx.pid` file stored in the `nginx-run` volume.
Expand All @@ -88,7 +88,7 @@ The following list describes the connections, preceeded by their types in parent
1. (File I/O) The _NGINX master_ sends logs to its _stdout_ and _stderr_, which are collected by the container runtime.
1. (File I/O) An _NGINX worker_ writes logs to its _stdout_ and _stderr_, which are collected by the container runtime.
1. (Signal) The _NGINX master_ controls the [lifecycle of _NGINX workers_](https://nginx.org/en/docs/control.html#reconfiguration) it creates workers with the new configuration and shutdowns workers with the old configuration.
1. (HTTP) To consider a configuration reload a success, _NGF_ ensures that at least one NGINX worker has the new configuration. To do that, _NGF_ checks a particular endpoint via the unix:/var/lib/nginx/nginx-config-version.sock UNIX socket.
1. (HTTP) To consider a configuration reload a success, _NGF_ ensures that at least one NGINX worker has the new configuration. To do that, _NGF_ checks a particular endpoint via the unix:/var/run/nginx/nginx-config-version.sock UNIX socket.
1. (HTTP, HTTPS) A _client_ sends traffic to and receives traffic from any of the _NGINX workers_ on ports 80 and 443.
1. (HTTP, HTTPS) An _NGINX worker_ sends traffic to and receives traffic from the _backends_.

Expand Down
3 changes: 3 additions & 0 deletions tests/suite/graceful_recovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ func runRecoveryTest(teaURL, coffeeURL, ngfPodName, containerName string, files
Should(Succeed())
}

// TEMP: Add sleep to see if it resolves falures
time.Sleep(5 * time.Second)

Eventually(
func() error {
return checkForWorkingTraffic(teaURL, coffeeURL)
Expand Down