-
Notifications
You must be signed in to change notification settings - Fork 249
feat(localdns): add systemd-based Prometheus-format metrics exporter #7917
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
Open
saewoni
wants to merge
46
commits into
main
Choose a base branch
from
sakwa/add_localdns_metrics__systemd
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
b0d774b
feat(localdns): add systemd-based Prometheus metrics exporter
kwaksaewon 781bd7d
add localdns-exporter.socket into vhdbuilder/packer/imagecustomizer/a…
kwaksaewon 8f25956
perf(localdns): optimize forward IP metrics export using .prom file
kwaksaewon 3667b29
test(localdns): add e2e test for metrics exporter validation
kwaksaewon 84974ca
use posix-compliant equal sign
kwaksaewon 970fcd0
only serve metrics at /metrics endpoint
kwaksaewon 18290a9
improve logigng in parts/linux/cloud-init/artifacts/localdns_exporter.sh
kwaksaewon 526ac5c
fix(localdns): use printf for HTTP headers with proper CRLF termination
kwaksaewon a971dbf
feat(localdns): support multiple forward IPs in metrics export
kwaksaewon f4d2ff1
refactor(localdns): use systemctl is-active for service status check
kwaksaewon 10cf746
fix(localdns): remove redundant dependencies from socket-activated se…
kwaksaewon 06d759b
test(localdns): add test cases for multiple forward IPs in metrics
kwaksaewon a5e7e42
fix(e2e): correct metrics endpoint path in test-localdns-exporter.sh
kwaksaewon 2809a83
test(localdns): add unit tests for localdns_exporter.sh HTTP routing
kwaksaewon 84029aa
fix(localdns): handle client disconnect gracefully in exporter script
kwaksaewon 90cedb8
fix(e2e): remove invalid HTTP header check from metrics validation
kwaksaewon 87a4222
fix(e2e): handle multiple forward IPs in metrics validation
kwaksaewon 2adeb0a
feat(e2e): add explicit HTTP status code validation for metrics endpoint
kwaksaewon 77bca0e
rename file to be snake-case
kwaksaewon fcec432
delete localdns-exporter.socket from vhdbuilder/packer/imagecustomize…
kwaksaewon 9efb467
fix(e2e): align status value validation with actual producer output
kwaksaewon bc98787
feat(localdns): enable systemd resource accounting for metrics
kwaksaewon 2daedaf
fix(localdns): bind metrics exporter socket to localhost only
kwaksaewon b9f9f3d
fix(e2e): filter metric grep to exclude HELP/TYPE comment lines
kwaksaewon a7c9a18
test(localdns): add /metrics endpoint coverage to exporter spec
kwaksaewon af2b2e7
fix(localdns): scope FORWARD_IPS_PROM_FILE as local variable
kwaksaewon 8726825
security(localdns): run exporter as unprivileged DynamicUser
kwaksaewon b24e2ca
security(localdns): add IP-based access controls to exporter socket
kwaksaewon 974c9a5
refactor(localdns): remove unnecessary exit from forward IP parsing
kwaksaewon 9410437
fix(localdns): use atomic write for forward_ips.prom file
kwaksaewon f24e9d9
test(e2e): add AzureLinuxV3 test for localdns exporter metrics
kwaksaewon 6ab3a2e
test(e2e): add Flatcar test for localdns exporter metrics
kwaksaewon a5bca10
fix(e2e): remove -p flag from ss command to avoid permission errors
kwaksaewon 30b08bd
fix(e2e): prevent curl failures from exiting script early
kwaksaewon 9cf87b4
fix(localdns): enable exporter socket conditionally during CSE
kwaksaewon d3b51bf
perf(localdns): use non-blocking start for exporter socket
kwaksaewon 97f3ed5
test(localdns): add security hardening validation to e2e tests
kwaksaewon 05283c7
improve(test): enhance security hardening validation
kwaksaewon 980d491
refactor(e2e): organize localdns test scripts into subdirectory
kwaksaewon 2525ad8
test(e2e): add localdns exporter tests for all supported distros
kwaksaewon 07cbd62
refactor(e2e): extract localdns metrics validation script using go:embed
kwaksaewon 1965390
refactor(e2e): remove redundant manual test script
kwaksaewon 830b342
fix(localdns): filter non-IP tokens when parsing forward IPs from cor…
kwaksaewon 4f77790
refactor(localdns): remove redundant IPAddress directives from socket…
kwaksaewon 9d2f6fe
Merge remote-tracking branch 'origin/main' into sakwa/add_localdns_me…
kwaksaewon 1c7bb9c
chore: regenerate testdata and fix shellcheck warning
kwaksaewon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| #!/bin/bash | ||
| # Helper script to run localdns e2e tests | ||
| # Usage: ./run-localdns-test.sh [test-name] | ||
| # Examples: | ||
| # ./run-localdns-test.sh # Run the test specified in .env | ||
| # ./run-localdns-test.sh Test_Ubuntu2204_LocalDNSHostsPlugin | ||
| # ./run-localdns-test.sh Test_Ubuntu2404_LocalDNSHostsPlugin | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| cd "$(dirname "$0")" | ||
|
|
||
| # Load .env file if it exists | ||
| if [ -f .env ]; then | ||
| echo "Loading configuration from .env..." | ||
| set -a | ||
| source .env | ||
| set +a | ||
| fi | ||
|
|
||
| # If test name is provided as argument, override TAGS_TO_RUN | ||
| if [ $# -gt 0 ]; then | ||
| export TAGS_TO_RUN="name=$1" | ||
| echo "Running specific test: $1" | ||
| else | ||
| echo "Running test(s) from .env: ${TAGS_TO_RUN:-all tests}" | ||
| fi | ||
|
|
||
| # Set defaults | ||
| : "${TIMEOUT:=90m}" | ||
| : "${PARALLEL:=100}" | ||
|
|
||
| echo "" | ||
| echo "==========================================" | ||
| echo "LocalDNS E2E Test Configuration" | ||
| echo "==========================================" | ||
| echo "Subscription: ${SUBSCRIPTION_ID:-not set}" | ||
| echo "Location: ${E2E_LOCATION:-westus3}" | ||
| echo "Tags to run: ${TAGS_TO_RUN:-all}" | ||
| echo "Tags to skip: ${TAGS_TO_SKIP:-none}" | ||
| echo "Keep VMSS: ${KEEP_VMSS:-false}" | ||
| echo "Timeout: ${TIMEOUT}" | ||
| echo "Parallel: ${PARALLEL}" | ||
| echo "==========================================" | ||
| echo "" | ||
|
|
||
| # Run the tests | ||
| echo "Starting e2e tests..." | ||
| go test -parallel $PARALLEL -timeout $TIMEOUT -v -count 1 | ||
|
|
||
| echo "" | ||
| echo "==========================================" | ||
| echo "Test run completed!" | ||
| echo "==========================================" | ||
| if [ "${KEEP_VMSS:-false}" = "true" ]; then | ||
| echo "" | ||
| echo "⚠️ REMINDER: KEEP_VMSS=true is set!" | ||
| echo "⚠️ VMs were NOT deleted. Check scenario-logs/ for SSH keys." | ||
| echo "⚠️ Don't forget to clean up resources to avoid costs:" | ||
| echo "" | ||
| echo " az group list --query \"[?starts_with(name, 'abe2e-')].name\" -o tsv" | ||
| echo " az group delete --name <resource-group-name> --yes --no-wait" | ||
| echo "" | ||
| fi | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script calls
go testwithout specifying any test filter or package path. Without arguments,go testwill test the current directory package. However, this script is meant to run localdns-related e2e tests but doesn't specify which test to run unless TAGS_TO_RUN is set.The script should specify the package path explicitly, e.g.,
go test -parallel $PARALLEL -timeout $TIMEOUT -v -count 1 .or provide better documentation about which directory this script should be run from.Additionally, if TAGS_TO_RUN is set to filter by test name (e.g., "name=Test_Ubuntu2204LocalDns_ExporterMetrics"), the script should use the
-runflag instead of or in addition to-tags. The current code sets TAGS_TO_RUN but doesn't pass it to thego testcommand.