- 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>
115 lines
3.2 KiB
C
115 lines
3.2 KiB
C
/*
|
|
* test_persist_encryption.c -- bug-1877: persist_init() warned "WAL/snapshot
|
|
* stored unencrypted" on every start without looking, so the warning also
|
|
* fired on encrypted storage. persist_dev_is_dmcrypt() now checks the WAL's
|
|
* block device in sysfs for a dm-crypt (LUKS) layer, directly or under LVM
|
|
* (via `slaves`); the warning stays for storage it cannot show is encrypted.
|
|
*/
|
|
#include <errno.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <sys/stat.h>
|
|
#include <unistd.h>
|
|
|
|
#include <unity/unity.h>
|
|
|
|
#include "persist.h"
|
|
|
|
static char g_sysfs[256];
|
|
|
|
static void mkdirs(const char* rel)
|
|
{
|
|
char path[512];
|
|
char cmd[640];
|
|
|
|
snprintf(path, sizeof(path), "%s/%s", g_sysfs, rel);
|
|
snprintf(cmd, sizeof(cmd), "mkdir -p '%s'", path);
|
|
TEST_ASSERT_EQUAL_INT(0, system(cmd));
|
|
}
|
|
|
|
static void put(const char* rel, const char* text)
|
|
{
|
|
char path[512];
|
|
FILE* fp;
|
|
|
|
snprintf(path, sizeof(path), "%s/%s", g_sysfs, rel);
|
|
fp = fopen(path, "w");
|
|
TEST_ASSERT_NOT_NULL(fp);
|
|
fputs(text, fp);
|
|
fclose(fp);
|
|
}
|
|
|
|
static void fake_sysfs(void)
|
|
{
|
|
char cmd[300];
|
|
|
|
snprintf(g_sysfs, sizeof(g_sysfs), "/tmp/test_persist_enc.%d", (int)getpid());
|
|
snprintf(cmd, sizeof(cmd), "rm -rf %s", g_sysfs);
|
|
TEST_ASSERT_EQUAL_INT(0, system(cmd));
|
|
|
|
/* 259:2 nvme0n1p2, a plain partition */
|
|
mkdirs("dev/block/259:2");
|
|
mkdirs("class/block/nvme0n1p2");
|
|
put("class/block/nvme0n1p2/dev", "259:2\n");
|
|
/* 253:0 dm-0 = LUKS on nvme0n1p2 */
|
|
mkdirs("dev/block/253:0/dm");
|
|
mkdirs("dev/block/253:0/slaves/nvme0n1p2");
|
|
put("dev/block/253:0/dm/uuid", "CRYPT-LUKS2-0123abcd-luks-0123\n");
|
|
mkdirs("class/block/dm-0");
|
|
put("class/block/dm-0/dev", "253:0\n");
|
|
/* 253:1 dm-1 = LVM volume on dm-0 */
|
|
mkdirs("dev/block/253:1/dm");
|
|
mkdirs("dev/block/253:1/slaves/dm-0");
|
|
put("dev/block/253:1/dm/uuid", "LVM-abcdefabcdef\n");
|
|
/* 253:2 dm-2 = LVM volume straight on the plain partition */
|
|
mkdirs("dev/block/253:2/dm");
|
|
mkdirs("dev/block/253:2/slaves/nvme0n1p2");
|
|
put("dev/block/253:2/dm/uuid", "LVM-fedcbafedcba\n");
|
|
}
|
|
|
|
static void drop_sysfs(void)
|
|
{
|
|
char cmd[300];
|
|
|
|
snprintf(cmd, sizeof(cmd), "rm -rf %s", g_sysfs);
|
|
TEST_ASSERT_EQUAL_INT(0, system(cmd));
|
|
}
|
|
|
|
static void test_luks_device_is_encrypted(void)
|
|
{
|
|
fake_sysfs();
|
|
TEST_ASSERT_EQUAL_INT(1, persist_dev_is_dmcrypt(g_sysfs, 253, 0));
|
|
drop_sysfs();
|
|
}
|
|
|
|
static void test_lvm_on_luks_is_encrypted(void)
|
|
{
|
|
fake_sysfs();
|
|
TEST_ASSERT_EQUAL_INT(1, persist_dev_is_dmcrypt(g_sysfs, 253, 1));
|
|
drop_sysfs();
|
|
}
|
|
|
|
static void test_plain_partition_and_plain_lvm_are_not(void)
|
|
{
|
|
fake_sysfs();
|
|
TEST_ASSERT_EQUAL_INT(0, persist_dev_is_dmcrypt(g_sysfs, 259, 2));
|
|
TEST_ASSERT_EQUAL_INT(0, persist_dev_is_dmcrypt(g_sysfs, 253, 2));
|
|
drop_sysfs();
|
|
}
|
|
|
|
static void test_unknown_device_is_not_claimed_encrypted(void)
|
|
{
|
|
fake_sysfs();
|
|
TEST_ASSERT_EQUAL_INT(0, persist_dev_is_dmcrypt(g_sysfs, 8, 99));
|
|
drop_sysfs();
|
|
}
|
|
|
|
void test_persist_encryption(void)
|
|
{
|
|
UnitySetTestFile(__FILE__);
|
|
RUN_TEST(test_luks_device_is_encrypted);
|
|
RUN_TEST(test_lvm_on_luks_is_encrypted);
|
|
RUN_TEST(test_plain_partition_and_plain_lvm_are_not);
|
|
RUN_TEST(test_unknown_device_is_not_claimed_encrypted);
|
|
}
|