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

Add test to log level change via signals feature #12572

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions examples/features/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ To run any feature example follow steps for [Basic NSM setup](../basic)
- [Scaled Registry K8s](./scaled-registry)
- [NSC changes endpoints dynamically](./change-nse-dynamically)
- [NSE IPAM Policies](./ipam-policies)
- [Runtime LogLevel Change](./runtime-loglevel-change)

67 changes: 67 additions & 0 deletions examples/features/runtime-loglevel-change/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Test runtime log level change via signals

This example shows how log level can be set, and reset to and from TRACE level

## Requires

Make sure that you have completed steps from [basic](../../basic) setup.


## Run

Ensure log level is not set to TRACE
```bash
kubectl apply -k ../https://github.com/networkservicemesh/deployments-k8s/examples/features/runtime-loglevel-change?ref=a93498171537efbfcfb704c5272519cc771c5ff0
```

Wait for forwarders to get ready
```bash
kubectl rollout status --timeout=3m -n nsm-system daemonset forwarder-vpp
```

Select a forwarder pod, get the pid of the running forwarder, and send SIGUSR1 to switch on TRACE
```bash
forwarder="$(kubectl get pods -n nsm-system --selector=app=forwarder-vpp --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}' | head -1)"
kubectl exec "$forwarder" -n nsm-system -i -- bash <<'EOF'
kill -s SIGUSR1 "$(pgrep 'forwarder')"
EOF
```

Check if signal has arrived
```bash
kubectl logs --selector=app=forwarder-vpp -n nsm-system --tail -1 --since=1m | grep "SetupLevelChangeOnSignal"
```

Check if there are TRACE logs
```bash
sleep 1m
kubectl logs --selector=app=forwarder-vpp -n nsm-system --tail -1 --since=1m | grep "TRAC"
```

Select a forwarder pod, get the pid of the running forwarder, and send SIGUSR2 to restore original log level
```bash
forwarder="$(kubectl get pods -n nsm-system --selector=app=forwarder-vpp --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}' | head -1)"
kubectl exec "$forwarder" -n nsm-system -i -- bash <<'EOF'
kill -s SIGUSR2 "$(pgrep 'forwarder')"
EOF
```

Check if signal has arrived
```bash
kubectl logs --selector=app=forwarder-vpp -n nsm-system --tail -1 --since=1m | grep "SetupLevelChangeOnSignal"
```

Check if there are no TRACE logs
```bash
sleep 1m
! kubectl logs --selector=app=forwarder-vpp -n nsm-system --tail -1 --since=1m | grep "TRAC"
```

//---------------------------------------------------------------------------//
## Cleanup

Reset original basic example
```bash
kubectl apply -k https://github.com/networkservicemesh/deployments-k8s/examples/basic?ref=a93498171537efbfcfb704c5272519cc771c5ff0
kubectl rollout status --timeout=3m -n nsm-system daemonset forwarder-vpp
```
14 changes: 14 additions & 0 deletions examples/features/runtime-loglevel-change/forwarder-patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: forwarder-vpp
spec:
selector: {}
template:
spec:
containers:
- name: forwarder-vpp
env:
- name: NSM_LOG_LEVEL
value: "INFO"
11 changes: 11 additions & 0 deletions examples/features/runtime-loglevel-change/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

namespace: nsm-system

resources:
- ../../basic

patches:
- path: forwarder-patch.yaml