Skip to content

Instantly share code, notes, and snippets.

@hughesjj
Created October 6, 2022 00:48
Show Gist options
  • Save hughesjj/4482e4b9143b2c801ed43c6174ab4dda to your computer and use it in GitHub Desktop.
Save hughesjj/4482e4b9143b2c801ed43c6174ab4dda to your computer and use it in GitHub Desktop.
def open_file(filename: str) -> str:
with open(filename) as fin:
return fin.read()
docker = open_file("redis-config-docker-default.txt")
local = open_file("redis-config-local-default.txt")
def to_datastructure(file_contents:str):
tokens = file_contents.split('\n')
if not tokens[-1]:
tokens.pop()
print(tokens)
i = 0
ds = {}
while i < len(tokens):
t = tokens[i]
# print(f"{t} {i}")
i += 1
v = tokens[i]
# print(f"{v} {i}")
i += 1
ds[t] = v
return ds
docker_config = to_datastructure(docker)
local_config = to_datastructure(local)
FILLER = 3*'\t'
values_mismatch = [
#(key, docker_config[key], local_config[key])
f"{key}{FILLER}{docker_config[key]}{FILLER}{local_config[key]}"
for key in docker_config.keys() & local_config.keys()
if docker_config[key] != local_config[key]
]
print(f"Keys in DOCKER but not in LOCAL: {','.join(docker_config.keys() - local_config.keys())}")
print(f"Keys in LOCAL but not in DOCKER: {','.join(local_config.keys() - docker_config.keys())}")
print(f"MISMATCHED VALUES: {','.join(local_config.keys() - docker_config.keys())}")
print("Key Docker Local\n" + '==='.join(3*[FILLER])+ "\n" +'\n'.join(values_mismatch))
@hughesjj
Copy link
Author

hughesjj commented Oct 6, 2022

File redis-docker-default-config.txt:

  1) "lazyfree-lazy-eviction"
  2) "no"
  3) "syslog-enabled"
  4) "no"
  5) "lazyfree-lazy-server-del"
  6) "no"
  7) "supervised"
  8) "no"
  9) "min-slaves-to-write"
 10) "0"
 11) "replica-priority"
 12) "100"
 13) "list-max-listpack-size"
 14) "-2"
 15) "active-expire-effort"
 16) "1"
 17) "syslog-ident"
 18) "redis"
 19) "tls-cluster"
 20) "no"
 21) "maxmemory-policy"
 22) "noeviction"
 23) "maxmemory-eviction-tenacity"
 24) "10"
 25) "replica-announce-port"
 26) "0"
 27) "cluster-announce-bus-port"
 28) "0"
 29) "repl-diskless-sync-delay"
 30) "5"
 31) "latency-monitor-threshold"
 32) "0"
 33) "cluster-slave-no-failover"
 34) "no"
 35) "repl-ping-replica-period"
 36) "10"
 37) "disable-thp"
 38) "yes"
 39) "rdbchecksum"
 40) "yes"
 41) "lazyfree-lazy-user-del"
 42) "no"
 43) "oom-score-adj"
 44) "no"
 45) "rdb-save-incremental-fsync"
 46) "yes"
 47) "lfu-decay-time"
 48) "1"
 49) "cluster-migration-barrier"
 50) "1"
 51) "port"
 52) "6379"
 53) "repl-backlog-size"
 54) "1048576"
 55) "databases"
 56) "16"
 57) "appenddirname"
 58) "appendonlydir"
 59) "aof-rewrite-incremental-fsync"
 60) "yes"
 61) "tls-prefer-server-ciphers"
 62) "no"
 63) "cluster-preferred-endpoint-type"
 64) "ip"
 65) "bind"
 66) "* -::*"
 67) "stop-writes-on-bgsave-error"
 68) "yes"
 69) "hash-max-listpack-entries"
 70) "512"
 71) "slowlog-log-slower-than"
 72) "10000"
 73) "proto-max-bulk-len"
 74) "536870912"
 75) "slave-serve-stale-data"
 76) "yes"
 77) "cluster-allow-pubsubshard-when-down"
 78) "yes"
 79) "bio_cpulist"
 80) ""
 81) "replica-announce-ip"
 82) ""
 83) "cluster-node-timeout"
 84) "15000"
 85) "client-query-buffer-limit"
 86) "1073741824"
 87) "tls-session-cache-size"
 88) "20480"
 89) "hash-max-ziplist-value"
 90) "64"
 91) "server_cpulist"
 92) ""
 93) "aclfile"
 94) ""
 95) "protected-mode"
 96) "no"
 97) "io-threads-do-reads"
 98) "no"
 99) "tls-key-file-pass"
100) ""
101) "latency-tracking-info-percentiles"
102) "50 99 99.9"
103) "lua-time-limit"
104) "5000"
105) "tls-client-key-file"
106) ""
107) "unixsocket"
108) ""
109) "tls-client-key-file-pass"
110) ""
111) "min-replicas-max-lag"
112) "10"
113) "maxmemory-clients"
114) "0"
115) "replica-announced"
116) "yes"
117) "tracking-table-max-keys"
118) "1000000"
119) "active-defrag-ignore-bytes"
120) "104857600"
121) "replica-lazy-flush"
122) "no"
123) "appendfilename"
124) "appendonly.aof"
125) "auto-aof-rewrite-min-size"
126) "67108864"
127) "slowlog-max-len"
128) "128"
129) "lazyfree-lazy-expire"
130) "no"
131) "acllog-max-len"
132) "128"
133) "acl-pubsub-default"
134) "resetchannels"
135) "latency-tracking"
136) "yes"
137) "crash-memcheck-enabled"
138) "yes"
139) "min-slaves-max-lag"
140) "10"
141) "cluster-config-file"
142) "nodes.conf"
143) "slave-read-only"
144) "yes"
145) "timeout"
146) "0"
147) "proc-title-template"
148) "{title} {listen-addr} {server-mode}"
149) "hz"
150) "10"
151) "cluster-allow-replica-migration"
152) "yes"
153) "auto-aof-rewrite-percentage"
154) "100"
155) "zset-max-ziplist-value"
156) "64"
157) "cluster-announce-ip"
158) ""
159) "tls-auth-clients"
160) "yes"
161) "shutdown-on-sigterm"
162) "default"
163) "tls-replication"
164) "no"
165) "slave-announce-ip"
166) ""
167) "rdbcompression"
168) "yes"
169) "syslog-facility"
170) "local0"
171) "dbfilename"
172) "dump.rdb"
173) "unixsocketperm"
174) "0"
175) "bgsave_cpulist"
176) ""
177) "tcp-keepalive"
178) "300"
179) "aof_rewrite_cpulist"
180) ""
181) "cluster-announce-hostname"
182) ""
183) "cluster-announce-port"
184) "0"
185) "active-defrag-threshold-lower"
186) "10"
187) "cluster-replica-validity-factor"
188) "10"
189) "cluster-link-sendbuf-limit"
190) "0"
191) "pidfile"
192) ""
193) "tls-port"
194) "0"
195) "hash-max-listpack-value"
196) "64"
197) "slave-announce-port"
198) "0"
199) "zset-max-listpack-entries"
200) "128"
201) "masterauth"
202) ""
203) "ignore-warnings"
204) ""
205) "replicaof"
206) ""
207) "slave-ignore-maxmemory"
208) "yes"
209) "masteruser"
210) ""
211) "activedefrag"
212) "no"
213) "repl-backlog-ttl"
214) "3600"
215) "loglevel"
216) "notice"
217) "set-proc-title"
218) "yes"
219) "enable-debug-command"
220) "no"
221) "requirepass"
222) ""
223) "cluster-require-full-coverage"
224) "yes"
225) "repl-disable-tcp-nodelay"
226) "no"
227) "dir"
228) "/data"
229) "maxmemory"
230) "0"
231) "shutdown-timeout"
232) "10"
233) "active-defrag-max-scan-fields"
234) "1000"
235) "tls-cert-file"
236) ""
237) "aof-use-rdb-preamble"
238) "yes"
239) "jemalloc-bg-thread"
240) "yes"
241) "tls-session-cache-timeout"
242) "300"
243) "stream-node-max-bytes"
244) "4096"
245) "slaveof"
246) ""
247) "hll-sparse-max-bytes"
248) "3000"
249) "logfile"
250) ""
251) "save"
252) "3600 1 300 100 60 10000"
253) "shutdown-on-sigint"
254) "default"
255) "notify-keyspace-events"
256) ""
257) "busy-reply-threshold"
258) "5000"
259) "rdb-del-sync-files"
260) "no"
261) "cluster-port"
262) "0"
263) "cluster-announce-tls-port"
264) "0"
265) "tls-ciphers"
266) ""
267) "replica-serve-stale-data"
268) "yes"
269) "appendonly"
270) "no"
271) "maxmemory-samples"
272) "5"
273) "cluster-slave-validity-factor"
274) "10"
275) "socket-mark-id"
276) "0"
277) "tls-client-cert-file"
278) ""
279) "set-max-intset-entries"
280) "512"
281) "aof-timestamp-enabled"
282) "no"
283) "tls-dh-params-file"
284) ""
285) "io-threads"
286) "1"
287) "repl-diskless-sync-max-replicas"
288) "0"
289) "appendfsync"
290) "everysec"
291) "tls-ciphersuites"
292) ""
293) "list-compress-depth"
294) "0"
295) "sanitize-dump-payload"
296) "no"
297) "active-defrag-cycle-min"
298) "1"
299) "zset-max-ziplist-entries"
300) "128"
301) "zset-max-listpack-value"
302) "64"
303) "crash-log-enabled"
304) "yes"
305) "lfu-log-factor"
306) "10"
307) "tls-ca-cert-file"
308) ""
309) "repl-diskless-sync"
310) "yes"
311) "aof-load-truncated"
312) "yes"
313) "tls-protocols"
314) ""
315) "active-defrag-cycle-max"
316) "25"
317) "tls-key-file"
318) ""
319) "repl-ping-slave-period"
320) "10"
321) "daemonize"
322) "no"
323) "enable-module-command"
324) "no"
325) "no-appendfsync-on-rewrite"
326) "no"
327) "hash-max-ziplist-entries"
328) "512"
329) "active-defrag-threshold-upper"
330) "100"
331) "stream-node-max-entries"
332) "100"
333) "tls-ca-cert-dir"
334) ""
335) "propagation-error-behavior"
336) "ignore"
337) "min-replicas-to-write"
338) "0"
339) "client-output-buffer-limit"
340) "normal 0 0 0 slave 268435456 67108864 60 pubsub 33554432 8388608 60"
341) "slave-lazy-flush"
342) "no"
343) "replica-read-only"
344) "yes"
345) "bind-source-addr"
346) ""
347) "replica-ignore-disk-write-errors"
348) "no"
349) "slave-priority"
350) "100"
351) "cluster-allow-reads-when-down"
352) "no"
353) "tcp-backlog"
354) "511"
355) "tls-session-caching"
356) "yes"
357) "cluster-enabled"
358) "no"
359) "repl-diskless-load"
360) "disabled"
361) "repl-timeout"
362) "60"
363) "replica-ignore-maxmemory"
364) "yes"
365) "always-show-logo"
366) "no"
367) "lazyfree-lazy-user-flush"
368) "no"
369) "dynamic-hz"
370) "yes"
371) "aof-disable-auto-gc"
372) "no"
373) "maxclients"
374) "10000"
375) "oom-score-adj-values"
376) "0 200 800"
377) "cluster-replica-no-failover"
378) "no"
379) "enable-protected-configs"
380) "no"
381) "activerehashing"
382) "yes"
383) "list-max-ziplist-size"
384) "-2"

@hughesjj
Copy link
Author

hughesjj commented Oct 6, 2022

Diff:

❯ python redisdiff.py
Keys in DOCKER but not in LOCAL:
Keys in LOCAL but not in DOCKER:
MISMATCHED VALUES:
Key Docker Local
                        ===                     ===
"protected-mode"                        "no"                    "yes"
"supervised"                    "no"                    "systemd"
"pidfile"                       ""                      "/var/run/redis_6379.pid"
"dir"                   "/data"                 "/var/lib/redis"
"bind"                  "* -::*"                        "127.0.0.1 -::1"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment