-
Notifications
You must be signed in to change notification settings - Fork 3.8k
keepalived: Added track_script option to sync group and fixed print_track_script_indent #29027
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
base: master
Are you sure you want to change the base?
Changes from all commits
6f43925
6d48739
169fcb7
b956c7f
2983ba4
e527de8
4285957
8848d0b
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -75,9 +75,12 @@ config globals 'globals' | |||||
| # list route "route1" | ||||||
|
|
||||||
| #config vrrp_sync_group | ||||||
| # option name "VI_sync_group_1" | ||||||
| # list group "VI_1" | ||||||
| # list group "VI_2" | ||||||
| # option name "VI_sync_group_1" | ||||||
| # list group "VI_1" | ||||||
| # list group "VI_2" | ||||||
| # Note that priority will not work with vrrp_script | ||||||
| # when in sync group | ||||||
| # list track_script "vrrp_script1" | ||||||
|
Comment on lines
+79
to
+83
|
||||||
| # option smtp_alert "1" | ||||||
| # option global_tracking 1 | ||||||
|
|
||||||
|
|
@@ -132,11 +135,16 @@ config globals 'globals' | |||||
| # option accept "1" | ||||||
|
|
||||||
| #config vrrp_script | ||||||
| # option name "vrrp_script1" | ||||||
| # option script "<script-file>" | ||||||
| # option interval "5" | ||||||
| # weight will increase +10 if script status is OK, otherwise -10 | ||||||
| # option weight "10" | ||||||
| # option fall "2" | ||||||
| # option rise "3" | ||||||
| # valid values for direction reverse|noreverse -- reverse flips weight change | ||||||
| # option direction "reverse" | ||||||
| # option timeout "5" | ||||||
|
||||||
| # option timeout "5" | |
| # option timeout "5" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -215,16 +215,14 @@ print_track_script_indent() { | |
|
|
||
| local name value weight direction | ||
| config_get name "$section" name | ||
| [ "$name" != "$curr_track_elem" ] && return 0 | ||
| [ -z "$name" ] && return 0 | ||
|
|
||
| config_get value "$section" value | ||
| config_get weight "$section" weight | ||
|
Comment on lines
216
to
220
|
||
| config_get direction "$section" direction | ||
|
|
||
| [ -z "$value" ] && return 0 | ||
| [ "$direction" != "reverse" ] && [ "$direction" != "noreverse" ] && unset direction | ||
|
|
||
| printf '%b%s' "$indent" "$value" >> "$KEEPALIVED_CONF" | ||
| printf '%b%s' "$indent" "$name" >> "$KEEPALIVED_CONF" | ||
| [ -n "$weight" ] && printf ' weight %s' "$weight ${direction:+${direction}}" >> "$KEEPALIVED_CONF" | ||
| printf '\n' >> "$KEEPALIVED_CONF" | ||
| } | ||
|
|
@@ -347,6 +345,17 @@ vrrp_sync_group() { | |
|
|
||
| print_elems_indent "$1" "$INDENT_1" no_val_smtp_alert no_val_global_tracking | ||
|
|
||
| # Handle track_script list for sync group | ||
| local track_script_val | ||
| config_get track_script_val "$1" track_script | ||
| if [ -n "$track_script_val" ]; then | ||
| printf '%btrack_script {\n' "${INDENT_1}" >> "$KEEPALIVED_CONF" | ||
|
Member
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. Can we not use config_section_open there?
Author
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. We could use config_section_open here but it would mess up the indentation in keepalived.conf. Besides for this is referenced referenced the track_script logic in vrrp_instance
Member
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. I think we should extend the config_section_open and config_section_close function, to add a new
Author
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. yeah we can do that. But after this should all the functions that hardcoded this must be changed? |
||
| for t in $track_script_val; do | ||
| config_foreach print_track_script_indent vrrp_script "$t" "$INDENT_2" | ||
| done | ||
| printf '%b}\n' "${INDENT_1}" >> "$KEEPALIVED_CONF" | ||
|
Member
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. Can we not use config_section_close there? |
||
| fi | ||
|
|
||
| print_notify "GROUP" "$name" "$INDENT_1" notify_backup notify_master \ | ||
| notify_fault notify | ||
|
|
||
|
|
@@ -413,7 +422,7 @@ vrrp_instance() { | |
| [ -z "$optval" ] && continue | ||
| printf '%b%s {\n' "${INDENT_1}" "$opt" >> "$KEEPALIVED_CONF" | ||
| for t in $optval; do | ||
| config_foreach print_track_script_indent track_script "$t" "$INDENT_2" | ||
| config_foreach print_track_script_indent vrrp_script "$t" "$INDENT_2" | ||
|
Member
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. I see what you do, but can you please explain why this is needed?
Author
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. Currently theres no support for track_script section, only for vrrp_script. I am not sure if this is how it was supposed to be done so correct me if I'm wrong but I tested this and it works.
Member
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. As the old option is still valid, we need to extend it to include the new option too. What would a correct keepalived configuration look like if both the
Author
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. The old option doesn't exist in the code. However its still present in the keepalived.config as of now. This is the sample configuration The above config generates this As you can see no section for
Member
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. But then I do not understand the uci why do i have to specifies the path to the script
Author
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. You are absolutely right, we dont need the section track_script. On reviewing the docs of keepalived, a seprate track_script section doesnt exist. My guess is that it was removed and the config file was not updated, same with the init file. I think we should update |
||
| done | ||
| printf '%b}\n' "${INDENT_1}" >> "$KEEPALIVED_CONF" | ||
| done | ||
|
|
@@ -466,7 +475,7 @@ vrrp_script() { | |
|
|
||
| config_section_open "vrrp_script" "$name" | ||
|
|
||
| print_elems_indent "$1" "$INDENT_1" script interval weight fall rise | ||
| print_elems_indent "$1" "$INDENT_1" script interval weight fall rise timeout | ||
|
|
||
| config_section_close | ||
| } | ||
|
|
@@ -670,4 +679,3 @@ start_service() { | |
| procd_set_param respawn | ||
| procd_close_instance | ||
| } | ||
|
|
||
|
Member
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. Does not belongs to this change.
Author
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. Cant this be accepted? Or should make changes in another commit to leave it as it is?
Member
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. As I said. If this is not related to the change move it to a new commit. |
||
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 changes
are not needed leave it as it is
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.
I have added some documentation for the new option here. Is the documentation not needed?
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.
It’s fine that this is documented. But you’ve changed lines that you didn’t need to change.