Skip to content

Commit

Permalink
Revert "all: ensure pidfile is created if a reload causes child to st…
Browse files Browse the repository at this point in the history
…art"

This reverts commit 3ea412d.

This commit should only have included keepalived/core/pidfile.c
  • Loading branch information
pqarmitage committed Aug 22, 2024
1 parent 39ed8b3 commit cbf0a7d
Show file tree
Hide file tree
Showing 25 changed files with 159 additions and 323 deletions.
9 changes: 2 additions & 7 deletions doc/man/man5/keepalived.conf.5.in
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@ sync group or real server monitors it.
A value will be read as a number in text from the file. If the weight
configured against the track_file is 0, a non-zero value in the file will
be treated as a failure status, and a zero value will be treated as
an OK status, otherwise the value will be multiplied by the weight configured
an OK status, otherwise the value will be multiplied by the weight configured
in the track_file statement.

For VRRP instances, if the result is less than -253 anything monitoring the
Expand Down Expand Up @@ -2334,11 +2334,6 @@ The syntax for virtual_server is :
# Minimum total weight of all live servers in
# the pool necessary to operate VS with no
# quality regression. Defaults to 1.
# If a sorry server is configured and the quorum
# is not met, any remaining alive real servers will
# be taken down and the sorry server enabled.
# If there is no sorry server, the remaining alive
# real servers will not be modified.
\fBquorum \fR<INTEGER>

# Tolerate this much weight units compared to the
Expand Down Expand Up @@ -2989,7 +2984,7 @@ There can be multiple ~SEQ elements on a line, so for example:
.SH List blocks
.PP
List blocks are similar to sequence blocks, except that the values to substitute into
the variable(s) are listed in the ~LST specification.
the variable are listed in the ~LST specification.

A line starting \fB~LST(var, val1, val2, val3)\fR will cause the remainder of the
line to be processed multiple times, with the variable \fB$var\fR set initially to
Expand Down
13 changes: 6 additions & 7 deletions keepalived/check/check_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,17 @@ dump_connection_opts(FILE *fp, const void *data)

/* Queue a checker into the real server's checkers_queue */
void
queue_checker(real_server_t *rs
, const checker_funcs_t *funcs
queue_checker(const checker_funcs_t *funcs
, thread_func_t launch
, checker_details_t checker_details
, void *data
, conn_opts_t *co
, bool fd_required)
{
checker_t *checker;

/* Set default dst = RS, timeout = default */
if (co) {
co->dst = rs->addr;
co->dst = current_rs->addr;
co->connection_to = UINT_MAX;
}

Expand All @@ -140,8 +139,8 @@ queue_checker(real_server_t *rs
checker->checker_funcs = funcs;
checker->launch = launch;
checker->vs = current_vs;
checker->rs = rs;
checker->check_type = checker_details;
checker->rs = current_rs;
checker->data = data;
checker->co = co;
checker->enabled = true;
checker->alpha = -1;
Expand All @@ -157,7 +156,7 @@ queue_checker(real_server_t *rs
if (fd_required)
check_data->num_checker_fd_required++;

list_add_tail(&checker->rs_list, &rs->checkers_list);
list_add_tail(&checker->rs_list, &current_rs->checkers_list);

current_checker = checker;
}
Expand Down
20 changes: 10 additions & 10 deletions keepalived/check/check_bfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static void bfd_check_thread(thread_ref_t);
static void
free_bfd_check(checker_t *checker)
{
bfd_checker_t *bfd_checker = checker->check_type.bfd_check;
bfd_checker_t *bfd_checker = checker->data;

FREE(bfd_checker);
FREE(checker);
Expand All @@ -63,7 +63,7 @@ free_bfd_check(checker_t *checker)
static void
dump_bfd_check(FILE *fp, const checker_t *checker)
{
const bfd_checker_t *bfd_checker = checker->check_type.bfd_check;
const bfd_checker_t *bfd_checker = checker->data;

conf_write(fp, " Keepalive method = BFD_CHECK");
conf_write(fp, " Name = %s", bfd_checker->bfd->bname);
Expand Down Expand Up @@ -108,8 +108,8 @@ dump_bfds_rs_list(FILE *fp, const list_head_t *l)
static bool
compare_bfd_check(const checker_t *old_c, checker_t *new_c)
{
const bfd_checker_t *old = old_c->check_type.bfd_check;
const bfd_checker_t *new = new_c->check_type.bfd_check;
const bfd_checker_t *old = old_c->data;
const bfd_checker_t *new = new_c->data;

if (strcmp(old->bfd->bname, new->bfd->bname))
return false;
Expand All @@ -135,13 +135,13 @@ static const checker_funcs_t bfd_checker_funcs = { CHECKER_BFD, free_bfd_check,
static void
bfd_check_handler(__attribute__((unused)) const vector_t *strvec)
{
checker_details_t checker_details;
bfd_checker_t *new_bfd_checker;

PMALLOC(checker_details.bfd_check);
INIT_LIST_HEAD(&checker_details.bfd_check->e_list);
PMALLOC(new_bfd_checker);
INIT_LIST_HEAD(&new_bfd_checker->e_list);

/* queue new checker */
queue_checker(current_rs, &bfd_checker_funcs, NULL, checker_details, NULL, false);
queue_checker(&bfd_checker_funcs, NULL, new_bfd_checker, NULL, false);
}

static void
Expand All @@ -153,7 +153,7 @@ bfd_name_handler(const vector_t *strvec)
bool config_error = true;
char *name;

bfdc = current_checker->check_type.bfd_check;
bfdc = current_checker->data;

if (vector_size(strvec) >= 2)
name = vector_slot(strvec, 1);
Expand Down Expand Up @@ -224,7 +224,7 @@ bfd_end_handler(void)
tracking_obj_t *top;
cref_tracked_bfd_t *tbfd;

bfdc = current_checker->check_type.bfd_check;
bfdc = current_checker->data;

if (!bfdc->bfd) {
report_config_error(CONFIG_GENERAL_ERROR, "(%s) No name has been specified for BFD_CHECKER - skipping"
Expand Down
24 changes: 0 additions & 24 deletions keepalived/check/check_daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,40 +424,19 @@ start_check(data_t *prev_global_data)
/* Set up the track files */
add_rs_to_track_files();
init_track_files(&check_data->track_files);
dump_vs_rs_checker_state("after init_track_files");

/* Processing differential configuration parsing */
set_track_file_weights();
dump_vs_rs_checker_state("after set_track_file_weights");
//#define MOVE_CLEAR_DIFF_SVCS
#ifndef MOVE_CLEAR_DIFF_SVCS
if (reload)
{
clear_diff_services();
dump_vs_rs_checker_state("after clear_diff_services");
}
#endif
set_track_file_checkers_down();
dump_vs_rs_checker_state("after set_track_file_checkers_down");
set_effective_weights();
dump_vs_rs_checker_state("after set_effective_weights");
if (reload)
{
check_new_rs_state();
dump_vs_rs_checker_state("after check_new_rs_state");
}
#ifdef MOVE_CLEAR_DIFF_SVCS
if (reload)
{
clear_diff_services();
dump_vs_rs_checker_state("after clear_diff_services");
}
#endif

/* Initialize IPVS topology */
if (!init_services())
stop_check(KEEPALIVED_EXIT_FATAL);
dump_vs_rs_checker_state("after init_services");

#ifndef _ONE_PROCESS_DEBUG_
/* Notify parent config has been read if appropriate */
Expand All @@ -478,7 +457,6 @@ dump_vs_rs_checker_state("after init_services");

/* Set the process cpu affinity if configured */
set_process_cpu_affinity(&global_data->checker_cpu_mask, "checker");
dump_vs_rs_checker_state("end of start_check");
}

void
Expand Down Expand Up @@ -507,7 +485,6 @@ reload_check_thread(__attribute__((unused)) thread_ref_t thread)

/* set the reloading flag */
SET_RELOAD;
dump_vs_rs_checker_state("Pre reload");

/* Terminate all script process */
script_killall(master, SIGTERM, false);
Expand Down Expand Up @@ -783,7 +760,6 @@ start_check_child(void)
separate_config_file();

/* Child process part, write pidfile */
log_message(LOG_INFO, "pidfile fd %d, name %s", checkers_pidfile.fd, checkers_pidfile.path);
if (!pidfile_write(&checkers_pidfile)) {
log_message(LOG_INFO, "Healthcheck child process: cannot write pidfile");
exit(KEEPALIVED_EXIT_FATAL);
Expand Down
32 changes: 16 additions & 16 deletions keepalived/check/check_dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ dns_recv_thread(thread_ref_t thread)
int flags, rcode;

checker_t *checker = THREAD_ARG(thread);
dns_check_t *dns_check = checker->check_type.dns_check;
dns_check_t *dns_check = CHECKER_ARG(checker);

if (thread->type == THREAD_READ_TIMEOUT) {
dns_final(thread, true, "read timeout from socket");
Expand Down Expand Up @@ -257,7 +257,7 @@ dns_make_query(thread_ref_t thread)
const char *s, *e;
size_t n;
checker_t *checker = THREAD_ARG(thread);
dns_check_t *dns_check = checker->check_type.dns_check;
dns_check_t *dns_check = CHECKER_ARG(checker);
dns_header_t *header = PTR_CAST(dns_header_t, dns_check->sbuf);

DNS_SET_RD(flags, 1); /* Recursion Desired */
Expand Down Expand Up @@ -296,7 +296,7 @@ static void
dns_send(thread_ref_t thread)
{
checker_t *checker = THREAD_ARG(thread);
dns_check_t *dns_check = checker->check_type.dns_check;
dns_check_t *dns_check = CHECKER_ARG(checker);
unsigned long timeout;
ssize_t ret;

Expand Down Expand Up @@ -430,18 +430,18 @@ dns_connect_thread(thread_ref_t thread)
static void
free_dns_check(checker_t *checker)
{
dns_check_t *dns_check = checker->check_type.dns_check;
dns_check_t *dns_check = checker->data;

FREE_CONST(dns_check->name);
FREE(checker->co);
FREE(checker->check_type.dns_check);
FREE(checker->data);
FREE(checker);
}

static void
dump_dns_check(FILE *fp, const checker_t *checker)
{
const dns_check_t *dns_check = checker->check_type.dns_check;
const dns_check_t *dns_check = checker->data;

conf_write(fp, " Keepalive method = DNS_CHECK");
conf_write(fp, " Type = %s", dns_type_name(dns_check->type));
Expand All @@ -451,8 +451,8 @@ dump_dns_check(FILE *fp, const checker_t *checker)
static bool
compare_dns_check(const checker_t *old_c, checker_t *new_c)
{
const dns_check_t *old = old_c->check_type.dns_check;
const dns_check_t *new = new_c->check_type.dns_check;
const dns_check_t *old = old_c->data;
const dns_check_t *new = new_c->data;

if (!compare_conn_opts(old_c->co, new_c->co))
return false;
Expand All @@ -469,12 +469,12 @@ static const checker_funcs_t dns_checker_funcs = { CHECKER_DNS, free_dns_check,
static void
dns_check_handler(__attribute__((unused)) const vector_t *strvec)
{
checker_details_t checker_details;
dns_check_t *dns_check;

PMALLOC(checker_details.dns_check);
checker_details.dns_check->type = DNS_DEFAULT_TYPE;
queue_checker(current_rs, &dns_checker_funcs, dns_connect_thread,
checker_details, CHECKER_NEW_CO(), true);
PMALLOC(dns_check);
dns_check->type = DNS_DEFAULT_TYPE;
queue_checker(&dns_checker_funcs, dns_connect_thread,
dns_check, CHECKER_NEW_CO(), true);

/* Set the non-standard retry time */
current_checker->default_retry = DNS_DEFAULT_RETRY;
Expand All @@ -484,7 +484,7 @@ dns_check_handler(__attribute__((unused)) const vector_t *strvec)
static void
dns_type_handler(const vector_t *strvec)
{
dns_check_t *dns_check = current_checker->check_type.dns_check;
dns_check_t *dns_check = current_checker->data;
uint16_t dns_type;

dns_type = dns_type_lookup(strvec_slot(strvec, 1));
Expand All @@ -498,7 +498,7 @@ dns_type_handler(const vector_t *strvec)
static void
dns_name_handler(const vector_t *strvec)
{
dns_check_t *dns_check = current_checker->check_type.dns_check;
dns_check_t *dns_check = current_checker->data;
const char *name;
bool name_invalid = false;
const char *p;
Expand Down Expand Up @@ -532,7 +532,7 @@ dns_name_handler(const vector_t *strvec)
static void
dns_check_end(void)
{
dns_check_t *dns_check = current_checker->check_type.dns_check;
dns_check_t *dns_check = current_checker->data;

if (!check_conn_opts(current_checker->co)) {
dequeue_new_checker();
Expand Down
17 changes: 3 additions & 14 deletions keepalived/check/check_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* <www.linuxvirtualserver.org>. It monitor & manipulate
* a loadbalanced server pool using multi-layer checks.
*
* Part: FILE CHECK. Monitor contents of a file
* Part: FILE CHECK. Monitor contents if a file
*
* Authors: Quentin Armitage, <[email protected]>
*
Expand Down Expand Up @@ -46,7 +46,7 @@ free_file_check(checker_t *checker)
static void
dump_file_check(FILE *fp, const checker_t *checker)
{
tracked_file_t *tfp = checker->check_type.file_check;
tracked_file_t *tfp = checker->data;

conf_write(fp, " Keepalive method = FILE_CHECK");
conf_write(fp, " Tracked file = %s", tfp->fname);
Expand All @@ -64,14 +64,6 @@ track_file_handler(const vector_t *strvec)
return;
}

if (current_tfile->file) {
report_config_error(CONFIG_GENERAL_ERROR, "%s track_file already specified as %s - ignoring %s", FMT_RS(current_rs, current_vs), current_tfile->file->fname, strvec_slot(strvec, 1));
return;
}

if (vector_size(strvec) > 2)
report_config_error(CONFIG_WARNING, "%s track_file %s has extra parameters - ignoring %s ...", FMT_RS(current_rs, current_vs), strvec_slot(strvec, 1), strvec_slot(strvec, 2));

current_tfile->file = vsf;
}

Expand Down Expand Up @@ -114,7 +106,6 @@ track_file_weight_handler(const vector_t *strvec)

current_tfile->weight = weight;
current_tfile->weight_reverse = reverse;
log_message(LOG_INFO, "Set track_file weight %d", current_tfile->weight);
}

static void
Expand Down Expand Up @@ -156,16 +147,14 @@ add_rs_to_track_files(void)
{
virtual_server_t *vs;
real_server_t *rs;
checker_details_t checker_details;
tracked_file_monitor_t *tfl;

list_for_each_entry(vs, &check_data->vs, e_list) {
list_for_each_entry(rs, &vs->rs, e_list) {
list_for_each_entry(tfl, &rs->track_files, e_list) {
/* queue new checker - we don't have a compare function since we don't
* update file checkers that way on a reload. */
checker_details.file_check = tfl->file;
queue_checker(rs, &file_checker_funcs, NULL, checker_details, NULL, false);
queue_checker(&file_checker_funcs, NULL, tfl->file, NULL, false);
current_checker->vs = vs;
current_checker->rs = rs;

Expand Down
6 changes: 3 additions & 3 deletions keepalived/check/check_genhash.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ genhash_usage(const char *prog, bool am_genhash)
static int
check_genhash_parse_cmdline(int argc, char **argv, checker_t *checker)
{
http_checker_t *http_get_check = checker->check_type.http_check;
http_checker_t *http_get_check = checker->data;
conn_opts_t *co = checker->co;
const char *start;
char *endptr;
Expand Down Expand Up @@ -131,7 +131,7 @@ check_genhash_parse_cmdline(int argc, char **argv, checker_t *checker)
bad_option = true;
break;
case 'v':
((http_checker_t *)checker->check_type.http_check)->genhash_flags |= GENHASH_VERBOSE;
((http_checker_t *)checker->data)->genhash_flags |= GENHASH_VERBOSE;
break;
case 'S':
http_get_check->proto = PROTO_SSL;
Expand Down Expand Up @@ -290,7 +290,7 @@ check_genhash(bool am_genhash, int argc, char **argv)
INIT_LIST_HEAD(&http_get_check->url);
http_get_check->genhash_flags = GENHASH;
http_get_check->proto = PROTO_HTTP;
checker->check_type.http_check = http_get_check;
checker->data = http_get_check;
checker->enabled = true;

/* Parse command line */
Expand Down
Loading

0 comments on commit cbf0a7d

Please sign in to comment.