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

refactor vip #408

Merged
merged 1 commit into from
Apr 24, 2024
Merged

refactor vip #408

merged 1 commit into from
Apr 24, 2024

Conversation

renyunkang
Copy link
Member

Description

What type of PR is this ?:

We have refactored the VIP mode of OpenELB, eliminating openelb-keepalived-vip and switching to the built-in keepalived for ARP announcements. Simultaneously, we have reduced redundancy in the allocation record data, making it more maintainable.

Related links:

@ks-ci-bot ks-ci-bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Apr 22, 2024
// Reload sends SIGHUP to keepalived to reload the configuration.
func (k *KeepAlived) Reload() error {
klog.Info("Waiting for keepalived to start")
for !k.IsRunning() {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should add some info logs here.

Copy link
Member Author

Choose a reason for hiding this comment

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

We should add some info logs here.

There are already info logs and error logs.

scanner.Buffer(nil, 1024*1024)
klog.Info("start scanning keepalived logs")
go func() {
for scanner.Scan() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice work!

if err = k.client.CoreV1().ConfigMaps(util.EnvNamespace()).Delete(context.TODO(), cm.Name, deleteOpt); err != nil {
k.log.Error(err, "keepalived configMap delete error")
defer logWriter.Close()
k.cmd = exec.Command(keepalivedStarter, "--dont-fork", "--log-console", "--log-detail", "--vrrp", "--release-vips")
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we provide an external parameter that allows users to customize the parameters of keepalived?

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

if protocol == constant.OpenELBProtocolVip {
ip = fmt.Sprintf("%s:%s", ip, value)
if len(nodes) == 0 {
klog.Warningf("no available nodes for service ip %s:%s", ip, value)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also add an event here?

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

{{ range $name, $instance := .instances }}
{{ if $instance.Enabled }}
vrrp_instance {{ $name }} {
state BACKUP
Copy link
Contributor

Choose a reason for hiding this comment

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

Just one question: Why is there a fixed value BACKUP here? When will it become MASTER?

Copy link
Member Author

Choose a reason for hiding this comment

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

Here's what the official documentation says:
Initial state, MASTER|BACKUP If the priority is 255, then the instance will transition immediately to MASTER if state MASTER is specified; otherwise the instance will wait between 3 and 4 advert intervals before it can transition, depending on the priority.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok.

Copy link
Contributor

@chaunceyjiang chaunceyjiang left a comment

Choose a reason for hiding this comment

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

LGTM

Great job!

@ks-ci-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chaunceyjiang, renyunkang

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [chaunceyjiang,renyunkang]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

1 similar comment
@ks-ci-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chaunceyjiang, renyunkang

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [chaunceyjiang,renyunkang]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@chaunceyjiang
Copy link
Contributor

/lgtm

@ks-ci-bot ks-ci-bot added lgtm Indicates that a PR is ready to be merged. labels Apr 24, 2024
@ks-ci-bot
Copy link
Collaborator

LGTM label has been added.

Git tree hash: 94f47b0a9e27a5dac6b95f34b9e0897c93015693

1 similar comment
@ks-ci-bot
Copy link
Collaborator

LGTM label has been added.

Git tree hash: 94f47b0a9e27a5dac6b95f34b9e0897c93015693

@ks-ci-bot ks-ci-bot merged commit db8bd5b into openelb:refactor Apr 24, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants