Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit 296ce96

Browse files
authored
Improve redis image readiness checks (#60365)
* Ensure that redis-cli readiness check is working * First draft of readiness script in redis-store * Add readiness script to redis-cache and redis-store * Check rediness script in both images * Duplicate readiness script
1 parent 7a5e7da commit 296ce96

File tree

6 files changed

+56
-4
lines changed

6 files changed

+56
-4
lines changed

docker-images/redis-cache/BUILD.bazel

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,26 @@ filegroup(
88
srcs = ["redis.conf"],
99
)
1010

11+
filegroup(
12+
name = "redis_readiness",
13+
srcs = [
14+
"readiness.sh",
15+
],
16+
)
17+
1118
pkg_tar(
1219
name = "redis_tarball",
13-
srcs = [":redis_conf"],
20+
srcs = [
21+
":redis_conf",
22+
":redis_readiness",
23+
],
1424
modes = {
1525
"/etc/redis/redis.conf": "0644",
26+
"/usr/local/bin/readiness.sh": "0755",
1627
},
1728
remap_paths = {
1829
"/redis.conf": "/etc/redis/redis.conf",
30+
"/readiness.sh": "/usr/local/bin/readiness.sh",
1931
},
2032
)
2133

docker-images/redis-cache/image_test.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ commandTests:
66
args:
77
- --version
88

9+
- name: "readiness script available"
10+
command: "/usr/local/bin/readiness.sh"
11+
expectedError: ["Could not connect to Redis"]
12+
exitCode: 1
13+
914
- name: "not running as root"
1015
command: "/usr/bin/id"
1116
args:
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
response=$(
3+
redis-cli ping
4+
)
5+
if [ "$response" != "PONG" ]; then
6+
echo "$response"
7+
exit 1
8+
fi

docker-images/redis-store/BUILD.bazel

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,32 @@ load("//dev:oci_defs.bzl", "image_repository")
44
load("@container_structure_test//:defs.bzl", "container_structure_test")
55

66
filegroup(
7-
name = "redis_conf",
8-
srcs = ["redis.conf"],
7+
name = "redis_config",
8+
srcs = [
9+
"redis.conf",
10+
],
11+
)
12+
13+
filegroup(
14+
name = "redis_readiness",
15+
srcs = [
16+
"readiness.sh",
17+
],
918
)
1019

1120
pkg_tar(
1221
name = "redis_tarball",
13-
srcs = [":redis_conf"],
22+
srcs = [
23+
":redis_config",
24+
":redis_readiness",
25+
],
1426
modes = {
1527
"/etc/redis/redis.conf": "0644",
28+
"/usr/local/bin/readiness.sh": "0755",
1629
},
1730
remap_paths = {
1831
"/redis.conf": "/etc/redis/redis.conf",
32+
"/readiness.sh": "/usr/local/bin/readiness.sh",
1933
},
2034
)
2135

docker-images/redis-store/image_test.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ commandTests:
66
args:
77
- --version
88

9+
- name: "readiness script available"
10+
command: "/usr/local/bin/readiness.sh"
11+
expectedError: ["Could not connect to Redis"]
12+
exitCode: 1
13+
914
- name: "not running as root"
1015
command: "/usr/bin/id"
1116
args:
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
response=$(
3+
redis-cli ping
4+
)
5+
if [ "$response" != "PONG" ]; then
6+
echo "$response"
7+
exit 1
8+
fi

0 commit comments

Comments
 (0)