Skip to content

Commit

Permalink
Merge pull request #22 from openshift-virtualization/match-on-podname
Browse files Browse the repository at this point in the history
hook: Match on pod name
  • Loading branch information
fabiand authored May 17, 2024
2 parents 7f3da50 + d218d24 commit 82c6b91
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
4 changes: 1 addition & 3 deletions contrib/hook.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
"path": "/opt/oci-hook-swap.sh"
},
"when": {
"annotations": {
"^kubevirt\\.io\\/domain$": ".*"
}
"always": true
},
"stages": [
"poststart"
Expand Down
3 changes: 2 additions & 1 deletion contrib/hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ echo "WASP SWAP hook"
set -x

CG_PATH=$(jq -er '.linux.cgroupsPath' < config.json)
POD_NAME=$(jq -er '.annotations["io.kubernetes.pod.name"]' < config.json)

if [[ "$CG_PATH" =~ .*"burst".* ]];
if [[ "$CG_PATH" =~ .*"burst".* && "$POD_NAME" =~ "virt-launcher".* ]];
then
CONTAINERID=$(jq -er '.linux.cgroupsPath | split(":")[2]' < config.json)
runc update $CONTAINERID --memory-swap -1
Expand Down
2 changes: 1 addition & 1 deletion examples/fedora.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
creationTimestamp: null
labels:
app: fedora
name: fedora
name: virt-launcher-fedora
spec:
replicas: 1
selector:
Expand Down

0 comments on commit 82c6b91

Please sign in to comment.