Skip to content
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

Merged
merged 25 commits into from
Jul 31, 2023
Merged

K8SPS-283: Add HAProxy for group replication #399

merged 25 commits into from
Jul 31, 2023

Conversation

egegunes
Copy link
Contributor

@egegunes egegunes commented Jul 4, 2023

K8SPS-283 Powered by Pull Request Badge

CHANGE DESCRIPTION

Problem:
Marco doesn't like MySQL Router.

Solution:
We're allowing users to deploy HAProxy with group replication.

CHECKLIST

Jira

  • Is the Jira ticket created and referenced properly?
  • Does the Jira ticket have the proper statuses for documentation (Needs Doc) and QA (Needs QA)?
  • Does the Jira ticket link to the proper milestone (Fix Version field)?

Tests

  • Is an E2E test/test case added for the new feature/change?
  • Are unit tests added where appropriate?

Config/Logging/Testability

  • Are all needed new/changed options added to default YAML files?
  • Are the manifests (crd/bundle) regenerated if needed?
  • Did we add proper logging messages for operator actions?
  • Did we ensure compatibility with the previous version or cluster upgrade process?
  • Does the change support oldest and newest supported PS version?
  • Does the change support oldest and newest supported Kubernetes version?

@pull-request-size pull-request-size bot added the size/L 100-499 lines label Jul 4, 2023
build/haproxy-entrypoint.sh Outdated Show resolved Hide resolved
build/haproxy_check_primary.sh Outdated Show resolved Hide resolved
build/haproxy_check_primary.sh Outdated Show resolved Hide resolved
build/haproxy_check_primary.sh Outdated Show resolved Hide resolved
build/haproxy_check_primary.sh Outdated Show resolved Hide resolved
build/haproxy_check_replicas.sh Outdated Show resolved Hide resolved
build/haproxy_check_replicas.sh Outdated Show resolved Hide resolved
build/haproxy_check_replicas.sh Outdated Show resolved Hide resolved
build/haproxy_check_replicas.sh Outdated Show resolved Hide resolved
build/haproxy_check_replicas.sh Outdated Show resolved Hide resolved
egegunes and others added 3 commits July 5, 2023 12:03
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@egegunes egegunes marked this pull request as ready for review July 7, 2023 06:52
inelpandzic
inelpandzic previously approved these changes Jul 10, 2023
@pull-request-size pull-request-size bot added size/XL 500-999 lines and removed size/L 100-499 lines labels Jul 11, 2023
inelpandzic
inelpandzic previously approved these changes Jul 26, 2023
@pull-request-size pull-request-size bot added size/XXL 1000+ lines and removed size/XL 500-999 lines labels Jul 27, 2023
deploy/cr.yaml Outdated
Comment on lines 46 to 58
readinessProbe:
initialDelaySeconds: 30
timeoutSeconds: 10
periodSeconds: 10
failureThreshold: 3
successThreshold: 1

livenessProbe:
initialDelaySeconds: 15
timeoutSeconds: 10
periodSeconds: 10
failureThreshold: 3
successThreshold: 1
Copy link
Collaborator

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

local level=$1
local message=$2

echo "$(/usr/bin/date +%Y-%m-%dT%H:%M:%S%z) [${level}] ${message}"
Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor Author

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
Comment on lines 147 to 157
readinessProbe:
timeoutSeconds: 3
periodSeconds: 5
failureThreshold: 3
successThreshold: 1

livenessProbe:
timeoutSeconds: 3
periodSeconds: 5
failureThreshold: 3
successThreshold: 1
Copy link
Collaborator

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

Copy link
Contributor Author

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'

Copy link
Collaborator

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

deploy/cr.yaml Show resolved Hide resolved
build/haproxy-entrypoint.sh Outdated Show resolved Hide resolved
build/haproxy-entrypoint.sh Outdated Show resolved Hide resolved
build/haproxy_check_primary.sh Outdated Show resolved Hide resolved
build/haproxy_check_primary.sh Outdated Show resolved Hide resolved
build/haproxy_check_replicas.sh Outdated Show resolved Hide resolved
build/haproxy_check_replicas.sh Outdated Show resolved Hide resolved
egegunes and others added 2 commits July 28, 2023 10:02
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>
Comment on lines 6 to 8
local level=$1
local message=$2
local date=$(/usr/bin/date +"%d/%b/%Y:%H:%M:%S.%3N")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[shfmt] reported by reviewdog 🐶

Suggested change
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")

local message=$2
local date=$(/usr/bin/date +"%d/%b/%Y:%H:%M:%S.%3N")

echo "{\"time\":\"${date}\", \"level\": \"${level}\", \"message\": \"${message}\"}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[shfmt] reported by reviewdog 🐶

Suggested change
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>
Comment on lines 6 to 8
local level=$1
local message=$2
local date=$(/usr/bin/date +"%d/%b/%Y:%H:%M:%S.%3N")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[shfmt] reported by reviewdog 🐶

Suggested change
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")

local message=$2
local date=$(/usr/bin/date +"%d/%b/%Y:%H:%M:%S.%3N")

echo "{\"time\":\"${date}\", \"level\": \"${level}\", \"message\": \"${message}\"}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[shfmt] reported by reviewdog 🐶

Suggested change
echo "{\"time\":\"${date}\", \"level\": \"${level}\", \"message\": \"${message}\"}"
echo "{\"time\":\"${date}\", \"level\": \"${level}\", \"message\": \"${message}\"}"

@percona percona deleted a comment from github-actions bot Jul 28, 2023
@percona percona deleted a comment from github-actions bot Jul 28, 2023
Comment on lines +16 to +40
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[shfmt] reported by reviewdog 🐶

Suggested change
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

@JNKPercona
Copy link
Collaborator

Test name Status
async-ignore-annotations passed
auto-config passed
config passed
config-router passed
demand-backup passed
gr-bootstrap passed
gr-demand-backup passed
gr-haproxy passed
gr-ignore-annotations passed
gr-init-deploy passed
gr-one-pod passed
gr-scaling passed
gr-tls-cert-manager passed
haproxy passed
init-deploy passed
limits passed
monitoring passed
one-pod passed
scaling passed
service-per-pod passed
sidecars passed
tls-cert-manager passed
users passed
version-service passed
We run 24 out of 24

commit: 8b99311
image: perconalab/percona-server-mysql-operator:PR-399-8b99311

@hors hors self-requested a review July 31, 2023 08:50
@hors hors merged commit 2ea88df into main Jul 31, 2023
8 of 10 checks passed
@hors hors deleted the K8SPS-283 branch July 31, 2023 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/XXL 1000+ lines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants