-
Notifications
You must be signed in to change notification settings - Fork 0
Fix gateway recovery epoch replacement boundary #101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| function canonical_timestamp(value, fraction, digits) { | ||
| sub(/,/, ".", value) | ||
| if (value ~ /^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\.[0-9]+)?Z$/) { | ||
| sub(/Z$/, "", value) | ||
| sub(/T/, " ", value) | ||
| } else if (value !~ /^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}(\.[0-9]+)?$/) { | ||
| return "" | ||
| } | ||
|
|
||
| if (value ~ /\./) { | ||
| fraction = value | ||
| sub(/^.*\./, "", fraction) | ||
| sub(/\..*$/, "", value) | ||
| } else { | ||
| fraction = "" | ||
| } | ||
| digits = length(fraction) | ||
| if (digits > 9) { | ||
| fraction = substr(fraction, 1, 9) | ||
| } | ||
| while (length(fraction) < 9) { | ||
| fraction = fraction "0" | ||
| } | ||
| return value "." fraction | ||
| } | ||
|
|
||
| BEGIN { | ||
| epoch_timestamp = canonical_timestamp(epoch_started_at) | ||
| if (epoch_timestamp == "") { | ||
| exit 2 | ||
| } | ||
| } | ||
|
|
||
| { | ||
| line_timestamp = "" | ||
| if ($0 ~ /^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\.[0-9]+)?Z[[:space:]]/) { | ||
| line_timestamp = $1 | ||
| } else if ($0 ~ /^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}([.,][0-9]+)?[[:space:]]/) { | ||
| line_timestamp = $1 " " $2 | ||
| } | ||
|
|
||
| line_timestamp = canonical_timestamp(line_timestamp) | ||
| if (line_timestamp == "" || line_timestamp < epoch_timestamp) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Useful? React with 👍 / 👎. |
||
| next | ||
| } | ||
| if ($0 ~ terminal_regex) { | ||
| terminal_found = 1 | ||
| } | ||
| if ($0 ~ progress_regex) { | ||
| progress_found = 1 | ||
| } | ||
| } | ||
|
|
||
| END { | ||
| if (terminal_found) { | ||
| print "terminal" | ||
| } else if (progress_found) { | ||
| print "progress" | ||
| } else { | ||
| print "none" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| ib_gateway_started_at_is_valid() { | ||
| local started_at="${1:-}" | ||
|
|
||
| [[ "${started_at}" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\.[0-9]+)?Z$ ]] \ | ||
| && [[ "${started_at}" != 0001-01-01T00:00:00* ]] | ||
| } | ||
|
|
||
| ib_gateway_inspect_container_epoch() { | ||
| local container_ref="${1:-}" | ||
| local inspect_record container_id started_at | ||
|
|
||
| [ -n "${container_ref}" ] || return 1 | ||
| inspect_record="$(docker inspect --format '{{.Id}} {{.State.StartedAt}}' "${container_ref}" 2>/dev/null)" \ | ||
| || return 1 | ||
| read -r container_id started_at <<<"${inspect_record}" | ||
| [ -n "${container_id}" ] || return 1 | ||
| ib_gateway_started_at_is_valid "${started_at}" || return 1 | ||
| printf '%s %s\n' "${container_id}" "${started_at}" | ||
| } | ||
|
|
||
| ib_gateway_validate_replacement_epoch() { | ||
| local old_container_id="${1:-}" | ||
| local replacement_container_id="${2:-}" | ||
| local replacement_started_at="${3:-}" | ||
|
|
||
| [ -n "${old_container_id}" ] \ | ||
| && [ -n "${replacement_container_id}" ] \ | ||
| && [ "${old_container_id}" != "${replacement_container_id}" ] \ | ||
| && ib_gateway_started_at_is_valid "${replacement_started_at}" | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On hosts where plain
awkresolves tomawk(common on Ubuntu/Debian images), this interval regexp with an optional group aborts the classifier with aREcompile() - panicerror; becauserecover_ib_gateway_ready.shinvokesawkdirectly, replacement log classification then produces no activity instead of detecting progress or terminal events. Use a POSIX-compatible pattern or requiregawkso recovery does not silently skip the new epoch policy on those hosts.Useful? React with 👍 / 👎.