-
Notifications
You must be signed in to change notification settings - Fork 26
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
K8SPS-283: Add HAProxy for group replication #399
Conversation
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
deploy/cr.yaml
Outdated
readinessProbe: | ||
initialDelaySeconds: 30 | ||
timeoutSeconds: 10 | ||
periodSeconds: 10 | ||
failureThreshold: 3 | ||
successThreshold: 1 | ||
|
||
livenessProbe: | ||
initialDelaySeconds: 15 | ||
timeoutSeconds: 10 | ||
periodSeconds: 10 | ||
failureThreshold: 3 | ||
successThreshold: 1 |
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.
please comment these lines by default
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.
done
build/haproxy_check_replicas.sh
Outdated
local level=$1 | ||
local message=$2 | ||
|
||
echo "$(/usr/bin/date +%Y-%m-%dT%H:%M:%S%z) [${level}] ${message}" |
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.
The support team wants to have JSON format like it was required in PXC. It simplifies there life when you need to parse something.
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.
done
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.
but I don't really like it since we have logs in mixed format right now:
{"time":"28/Jul/2023:06:55:50.971", "level": "INFO", "message": "10.100.1.7:33062 @@super_read_only: 0 Applier: ON"}
{"time":"28/Jul/2023:06:55:50.974", "level": "INFO", "message": "10.100.1.7:33062 for backend mysql-replicas is NOT OK"}
[WARNING] (19) : Server mysql-replicas/cluster1-mysql-0 is DOWN, reason: External check error, code: 1, check duration: 149ms. 2 active and 0 backup servers left. 0 sessions active, 0 requeu
ed, 0 remaining in queue.
{"time":"28/Jul/2023:06:55:52.629", "level": "INFO", "message": "10.100.2.7:33062 @@super_read_only: 1 Applier: ON"}
{"time":"28/Jul/2023:06:55:52.631", "level": "INFO", "message": "10.100.2.7:33062 for backend mysql-replicas is OK"}
{"time":"28/Jul/2023:06:55:54.309", "level": "INFO", "message": "10.100.0.16:33062 @@super_read_only: 1 Applier: ON"}
{"time":"28/Jul/2023:06:55:54.312", "level": "INFO", "message": "10.100.0.16:33062 for backend mysql-replicas is OK"}
deploy/cr.yaml
Outdated
readinessProbe: | ||
timeoutSeconds: 3 | ||
periodSeconds: 5 | ||
failureThreshold: 3 | ||
successThreshold: 1 | ||
|
||
livenessProbe: | ||
timeoutSeconds: 3 | ||
periodSeconds: 5 | ||
failureThreshold: 3 | ||
successThreshold: 1 |
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.
please comment these lines by default
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.
done
if [ "$1" = 'haproxy' ]; then | ||
if [ ! -f '/etc/haproxy/mysql/haproxy.cfg' ]; then | ||
cp /opt/percona/haproxy.cfg /etc/haproxy/mysql | ||
fi | ||
|
||
haproxy_opt='-W -db -f /opt/percona/haproxy-global.cfg -f /etc/haproxy/mysql/haproxy.cfg -p /etc/haproxy/mysql/haproxy.pid -S /etc/haproxy/mysql/haproxy-main.sock' | ||
|
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.
@egegunes please use the same approach for custom conf as we have for PXC operator
https://github.com/percona/percona-docker/blob/main/haproxy/dockerdir/entrypoint.sh#L17C5-L28
In case of custom config we need to replace whole conf
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.
done
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
build/haproxy_check_primary.sh
Outdated
local level=$1 | ||
local message=$2 | ||
local date=$(/usr/bin/date +"%d/%b/%Y:%H:%M:%S.%3N") |
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.
[shfmt] reported by reviewdog 🐶
local level=$1 | |
local message=$2 | |
local date=$(/usr/bin/date +"%d/%b/%Y:%H:%M:%S.%3N") | |
local level=$1 | |
local message=$2 | |
local date=$(/usr/bin/date +"%d/%b/%Y:%H:%M:%S.%3N") |
build/haproxy_check_primary.sh
Outdated
local message=$2 | ||
local date=$(/usr/bin/date +"%d/%b/%Y:%H:%M:%S.%3N") | ||
|
||
echo "{\"time\":\"${date}\", \"level\": \"${level}\", \"message\": \"${message}\"}" |
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.
[shfmt] reported by reviewdog 🐶
echo "{\"time\":\"${date}\", \"level\": \"${level}\", \"message\": \"${message}\"}" | |
echo "{\"time\":\"${date}\", \"level\": \"${level}\", \"message\": \"${message}\"}" |
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
build/haproxy_check_replicas.sh
Outdated
local level=$1 | ||
local message=$2 | ||
local date=$(/usr/bin/date +"%d/%b/%Y:%H:%M:%S.%3N") |
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.
[shfmt] reported by reviewdog 🐶
local level=$1 | |
local message=$2 | |
local date=$(/usr/bin/date +"%d/%b/%Y:%H:%M:%S.%3N") | |
local level=$1 | |
local message=$2 | |
local date=$(/usr/bin/date +"%d/%b/%Y:%H:%M:%S.%3N") |
build/haproxy_check_replicas.sh
Outdated
local message=$2 | ||
local date=$(/usr/bin/date +"%d/%b/%Y:%H:%M:%S.%3N") | ||
|
||
echo "{\"time\":\"${date}\", \"level\": \"${level}\", \"message\": \"${message}\"}" |
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.
[shfmt] reported by reviewdog 🐶
echo "{\"time\":\"${date}\", \"level\": \"${level}\", \"message\": \"${message}\"}" | |
echo "{\"time\":\"${date}\", \"level\": \"${level}\", \"message\": \"${message}\"}" |
if [ ! -f '/etc/haproxy/mysql/haproxy.cfg' ]; then | ||
cp /opt/percona/haproxy.cfg /etc/haproxy/mysql | ||
fi | ||
|
||
custom_conf='/etc/haproxy-custom/haproxy.cfg' | ||
if [ -f "$custom_conf" ]; then | ||
log "haproxy -c -f $custom_conf -f /etc/haproxy/mysql/haproxy.cfg" | ||
haproxy -c -f $custom_conf -f /etc/haproxy/mysql/haproxy.cfg || EC=$? | ||
if [ -n "$EC" ]; then | ||
log "The custom config $custom_conf is not valid and will be ignored." | ||
fi | ||
fi | ||
|
||
haproxy_opt='-W -db ' | ||
if [ -f "$custom_conf" -a -z "$EC" ]; then | ||
haproxy_opt+="-f $custom_conf " | ||
else | ||
haproxy_opt+='-f /opt/percona/haproxy-global.cfg ' | ||
fi | ||
|
||
haproxy_opt+='-f /etc/haproxy/mysql/haproxy.cfg -p /etc/haproxy/mysql/haproxy.pid -S /etc/haproxy/mysql/haproxy-main.sock' | ||
|
||
haproxy_opt='-W -db -f /opt/percona/haproxy-global.cfg -f /etc/haproxy/mysql/haproxy.cfg -p /etc/haproxy/mysql/haproxy.pid -S /etc/haproxy/mysql/haproxy-main.sock' | ||
if [ -f '/etc/haproxy/config/haproxy.cfg' ]; then | ||
haproxy_opt="${haproxy_opt} -f /etc/haproxy/config/haproxy.cfg" | ||
fi |
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.
[shfmt] reported by reviewdog 🐶
if [ ! -f '/etc/haproxy/mysql/haproxy.cfg' ]; then | |
cp /opt/percona/haproxy.cfg /etc/haproxy/mysql | |
fi | |
custom_conf='/etc/haproxy-custom/haproxy.cfg' | |
if [ -f "$custom_conf" ]; then | |
log "haproxy -c -f $custom_conf -f /etc/haproxy/mysql/haproxy.cfg" | |
haproxy -c -f $custom_conf -f /etc/haproxy/mysql/haproxy.cfg || EC=$? | |
if [ -n "$EC" ]; then | |
log "The custom config $custom_conf is not valid and will be ignored." | |
fi | |
fi | |
haproxy_opt='-W -db ' | |
if [ -f "$custom_conf" -a -z "$EC" ]; then | |
haproxy_opt+="-f $custom_conf " | |
else | |
haproxy_opt+='-f /opt/percona/haproxy-global.cfg ' | |
fi | |
haproxy_opt+='-f /etc/haproxy/mysql/haproxy.cfg -p /etc/haproxy/mysql/haproxy.pid -S /etc/haproxy/mysql/haproxy-main.sock' | |
haproxy_opt='-W -db -f /opt/percona/haproxy-global.cfg -f /etc/haproxy/mysql/haproxy.cfg -p /etc/haproxy/mysql/haproxy.pid -S /etc/haproxy/mysql/haproxy-main.sock' | |
if [ -f '/etc/haproxy/config/haproxy.cfg' ]; then | |
haproxy_opt="${haproxy_opt} -f /etc/haproxy/config/haproxy.cfg" | |
fi | |
if [ ! -f '/etc/haproxy/mysql/haproxy.cfg' ]; then | |
cp /opt/percona/haproxy.cfg /etc/haproxy/mysql | |
fi | |
custom_conf='/etc/haproxy-custom/haproxy.cfg' | |
if [ -f "$custom_conf" ]; then | |
log "haproxy -c -f $custom_conf -f /etc/haproxy/mysql/haproxy.cfg" | |
haproxy -c -f $custom_conf -f /etc/haproxy/mysql/haproxy.cfg || EC=$? | |
if [ -n "$EC" ]; then | |
log "The custom config $custom_conf is not valid and will be ignored." | |
fi | |
fi | |
haproxy_opt='-W -db ' | |
if [ -f "$custom_conf" -a -z "$EC" ]; then | |
haproxy_opt+="-f $custom_conf " | |
else | |
haproxy_opt+='-f /opt/percona/haproxy-global.cfg ' | |
fi | |
haproxy_opt+='-f /etc/haproxy/mysql/haproxy.cfg -p /etc/haproxy/mysql/haproxy.pid -S /etc/haproxy/mysql/haproxy-main.sock' | |
if [ -f '/etc/haproxy/config/haproxy.cfg' ]; then | |
haproxy_opt="${haproxy_opt} -f /etc/haproxy/config/haproxy.cfg" | |
fi |
commit: 8b99311 |
CHANGE DESCRIPTION
Problem:
Marco doesn't like MySQL Router.
Solution:
We're allowing users to deploy HAProxy with group replication.
CHECKLIST
Jira
Needs Doc
) and QA (Needs QA
)?Tests
Config/Logging/Testability