-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch adds a new metric `container_runtime_crio_containers_oom_total` and `container_runtime_crio_containers_oom`, which collects out of memory (oom) metrics global and by container name. This also includes sandboxes, since we reuse the CRI-O internal name for every container. Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
- Loading branch information
1 parent
33afe03
commit 17b8f71
Showing
7 changed files
with
136 additions
and
46 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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 @@ | ||
#!/usr/bin/env bats | ||
# vim: set syntax=sh: | ||
|
||
load helpers | ||
|
||
function setup() { | ||
setup_test | ||
} | ||
|
||
function teardown() { | ||
cleanup_test | ||
} | ||
|
||
@test "metrics with default port" { | ||
# start crio with default port 9090 | ||
PORT="9090" | ||
CONTAINER_ENABLE_METRICS=true start_crio | ||
if ! port_listens "$PORT"; then | ||
skip "Metrics port $PORT not listening" | ||
fi | ||
|
||
# get metrics | ||
curl -sf "http://localhost:$PORT/metrics" | ||
} | ||
|
||
@test "metrics with random port" { | ||
# start crio with custom port | ||
PORT=$(free_port) | ||
CONTAINER_ENABLE_METRICS=true CONTAINER_METRICS_PORT=$PORT start_crio | ||
|
||
crictl run "$TESTDATA"/container_redis.json "$TESTDATA"/sandbox_config.json | ||
|
||
# get metrics | ||
curl -sf "http://localhost:$PORT/metrics" | grep crio_operations | ||
} | ||
|
||
@test "metrics container oom" { | ||
PORT=$(free_port) | ||
CONTAINER_ENABLE_METRICS=true CONTAINER_METRICS_PORT=$PORT start_crio | ||
|
||
jq '.image.image = "quay.io/crio/oom" | ||
| .linux.resources.memory_limit_in_bytes = 25165824 | ||
| .command = ["/oom"]' \ | ||
"$TESTDATA/container_config.json" > "$TESTDIR/config.json" | ||
CTR_ID=$(crictl run "$TESTDIR/config.json" "$TESTDATA/sandbox_config.json") | ||
|
||
# Wait for container to OOM | ||
CNT=0 | ||
while [ $CNT -le 100 ]; do | ||
CNT=$((CNT + 1)) | ||
OUTPUT=$(crictl inspect --output yaml "$CTR_ID") | ||
if [[ "$OUTPUT" == *"OOMKilled"* ]]; then | ||
break | ||
fi | ||
sleep 10 | ||
done | ||
[[ "$OUTPUT" == *"OOMKilled"* ]] | ||
|
||
METRIC=$(curl -sf "http://localhost:$PORT/metrics" | grep '^container_runtime_crio_containers_oom_total') | ||
[[ "$METRIC" == 'container_runtime_crio_containers_oom_total 1' ]] | ||
|
||
METRIC=$(curl -sf "http://localhost:$PORT/metrics" | grep 'crio_containers_oom{') | ||
[[ "$METRIC" == 'container_runtime_crio_containers_oom{name="k8s_container1_podsandbox1_redhat.test.crio_redhat-test-crio_1"} 1' ]] | ||
} |
This file contains 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