Skip to content

Commit

Permalink
fix(kubernetes): make preStop command work with busybox (#3568)
Browse files Browse the repository at this point in the history
* fix(kubernetes): make preStop command work with busybox

The pgrep -c option does not exist in busybox. Make the preStop command more portable.

This avoids a weird error message in the logs of Garden Pods including the util container.
  • Loading branch information
stefreak authored Jan 31, 2023
1 parent e7024fe commit b062281
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion core/src/plugins/kubernetes/container/build/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ export function getUtilContainer(authSecretName: string, provider: KubernetesPro
command: [
"/bin/sh",
"-c",
"until test $(pgrep -fc '^[^ ]+rsync') = 1; do echo waiting for rsync to finish...; sleep 1; done",
"until test $(pgrep -f '^[^ ]+rsync' | wc -l) = 1; do echo waiting for rsync to finish...; sleep 1; done",
],
},
},
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/kubernetes/hot-reload/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export function configureHotReload({
command: [
"/bin/sh",
"-c",
"until test $(pgrep -fc '^[^ ]+rsync') = 1; do echo waiting for rsync to finish...; sleep 1; done",
"until test $(pgrep -f '^[^ ]+rsync' | wc -l) = 1; do echo waiting for rsync to finish...; sleep 1; done",
],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ describe("buildkit build", () => {
command: [
"/bin/sh",
"-c",
"until test $(pgrep -fc '^[^ ]+rsync') = 1; do echo waiting for rsync to finish...; sleep 1; done",
"until test $(pgrep -f '^[^ ]+rsync' | wc -l) = 1; do echo waiting for rsync to finish...; sleep 1; done",
],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe("common build", () => {
command: [
"/bin/sh",
"-c",
"until test $(pgrep -fc '^[^ ]+rsync') = 1; do echo waiting for rsync to finish...; sleep 1; done",
"until test $(pgrep -f '^[^ ]+rsync' | wc -l) = 1; do echo waiting for rsync to finish...; sleep 1; done",
],
},
},
Expand Down
4 changes: 2 additions & 2 deletions core/test/unit/src/plugins/kubernetes/hot-reload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ describe("configureHotReload", () => {
command: [
"/bin/sh",
"-c",
"until test $(pgrep -fc '^[^ ]+rsync') = 1; do echo waiting for rsync to finish...; sleep 1; done",
"until test $(pgrep -f '^[^ ]+rsync' | wc -l) = 1; do echo waiting for rsync to finish...; sleep 1; done",
],
},
},
Expand Down Expand Up @@ -240,7 +240,7 @@ describe("configureHotReload", () => {
command: [
"/bin/sh",
"-c",
"until test $(pgrep -fc '^[^ ]+rsync') = 1; do echo waiting for rsync to finish...; sleep 1; done",
"until test $(pgrep -f '^[^ ]+rsync' | wc -l) = 1; do echo waiting for rsync to finish...; sleep 1; done",
],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ spec:
# actually killing the pod. If the transfer takes more than 30 seconds, which is unlikely, the pod
# will be killed anyway. The command works by counting the number of rsync processes. This works
# because rsync forks for every connection.
command: ["/bin/sh", "-c", "until test $(pgrep -fc '^[^ ]+rsync') = 1; do echo waiting for rsync to finish...; sleep 1; done"]
command: ["/bin/sh", "-c", "until test $(pgrep -f '^[^ ]+rsync' | wc -l) = 1; do echo waiting for rsync to finish...; sleep 1; done"]
volumeMounts:
- mountPath: /data
name: garden-build-sync
Expand Down

0 comments on commit b062281

Please sign in to comment.