myxce/src/controller/testsuite/test_phase2_cold_boot.c
Rongsong Shen 44173f74ae
fix: spurious errors/warnings from a pc13v HA deploy (bug-1872..1877)
- bug-1872 (worker): "Failed to find any disk statistics in
  /proc/diskstats" ERROR every 15 s on an NVMe-only host. The whole-disk
  filter guessed from the name and skipped anything ending in a digit or
  containing 'p' -- every nvmeXnY, mmcblkN, even sdp -- so io was never
  reported. diskstats.h now counts a device only when
  /sys/block/<name>/device exists (real disks; not partitions, loop, dm,
  md, zram), and a host with no disk warns once.
- bug-1873 (worker): "Failed to get worker pid" WARN on job start. MainPID
  reads 0 until systemd has forked the new transient unit; xcecd.c already
  retries, so the miss is DEBUG and the final failure names the unit.
- bug-1874 (scheduler): deprecation WARN for the legacy xce_sched_fcfs on
  every start, though builtin_fcfs is the picker. Registration still wraps
  a job_elect_fn plugin but no longer warns; selecting one warns once.
- bug-1875 (apiserver): "Not running as root -- PAM authentication will not
  work" with the default provider config_file; now only for provider pam.
- bug-1876 (controller): standbys logged "cluster_init_phase2 ... failed
  (rc=-22)" WARN every 3 s while waiting for the primary's config push,
  a state the function itself calls normal. It returns -EAGAIN for that
  wait; callers log it at INFO, other failures still WARN.
- bug-1877 (controller): "WAL/snapshot stored unencrypted" warned without
  looking. persist_path_encrypted() checks fscrypt (statx) and dm-crypt
  (sysfs dm/uuid CRYPT-, through LVM slaves); the warning stays when the
  storage is not shown to be encrypted (e.g. a plain /tmp).

Tests: worker diskstats_test (2 of 4 RED on the old filter with pc13v's
/proc/diskstats), controller test_phase2_cold_boot and
test_persist_encryption, scheduler picker tests, apiserver
TestRootWarning. Full ASAN build: all 113 suites pass (controller 319/0,
harness 141/0).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 04:35:19 +00:00

40 lines
1.2 KiB
C

/*
* test_phase2_cold_boot.c -- bug-1876: while a standby waits for the
* primary's config push, cluster_init_phase2() has nothing to build yet.
* That is the normal cold-boot state, but it returned -EINVAL, and its
* callers logged it as a WARN ("cluster_init_phase2 on standby rejoin
* failed (rc=-22)") every 3 s until the config arrived. It now returns
* -EAGAIN, which the callers log at INFO.
*/
#include <errno.h>
#include <string.h>
#include <unity/unity.h>
#include "cluster.h"
#include "ha.h"
#include "myconf.h"
#include "xce/cluster_def.h"
extern int cluster_init_phase2(cluster_t* c);
static void test_phase2_without_config_is_a_wait_not_an_error(void)
{
cluster_t c;
myconf_t conf;
memset(&c, 0, sizeof(c));
memset(&conf, 0, sizeof(conf));
c.myconf = &conf; /* cluster_config not pushed yet */
TEST_ASSERT_EQUAL_INT(-EAGAIN, cluster_init_phase2(&c));
TEST_ASSERT_TRUE(ha_phase2_rc_is_waiting(-EAGAIN));
TEST_ASSERT_FALSE(ha_phase2_rc_is_waiting(-EINVAL));
TEST_ASSERT_FALSE(ha_phase2_rc_is_waiting(0));
}
void test_phase2_cold_boot(void)
{
UnitySetTestFile(__FILE__);
RUN_TEST(test_phase2_without_config_is_a_wait_not_an_error);
}