fix(controller): resource hooks only carry values the controller accepted (bug-1583)
do_update_resvals() fired the AFTER_EVENT HOOK_DETAIL_RESOURCE_UPDATE with the raw client xce_resval_list_t. update_resval_list() rejects unknown resource names (-ENOENT) but only logged it, so both listeners -- the scheduler push and the apiserver store (apiserver_resource_hook_fun -> handler.go) -- received names the controller had rejected, and the apiserver stored them. - update_resval_list() takes an optional `applied` view (caller-sized, borrowed pointers) and fills it with just the accepted items. - do_update_resvals() hands that view to the AFTER_EVENT hook, and skips it when nothing was applied. The request still owns every item. New test_update_resval_list_reports_only_applied_items (RED before: both items reported). Controller suite 1237/0. Live /xce-test-resources with mem=5 totally-fake-resource-xyz=1: mem MATCH at controller, scheduler and apiserver; the fake name is rejected at injection and appears 0 times in scheduler.log / apiserver.log (verdict FAIL by design, for the rejected name). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
054a1416bc
commit
70360ccfe8
4 changed files with 78 additions and 7 deletions
|
|
@ -383,6 +383,47 @@ static void test_update_resvals_logs_actual_rc_not_stale_errno(void)
|
|||
printf("test_update_resvals_logs_actual_rc_not_stale_errno: PASS\n");
|
||||
}
|
||||
|
||||
/* bug-1583: update_resval_list() must report which items it actually
|
||||
* applied, so do_update_resvals() can hand ONLY those to the AFTER_EVENT
|
||||
* resource hook (scheduler + apiserver). It used to pass the raw client
|
||||
* list, so the apiserver stored resource names the controller rejected. */
|
||||
static void test_update_resval_list_reports_only_applied_items(void)
|
||||
{
|
||||
setup_test_cluster();
|
||||
|
||||
hostattrs_t attrs;
|
||||
memset(&attrs, 0, sizeof(attrs));
|
||||
attrs.hosttype = makeString("LINUX");
|
||||
attrs.hostmodel = makeString("x86");
|
||||
worker_t* w = make_test_worker("host-resval-applied", &attrs);
|
||||
TEST_ASSERT_NOT_NULL(w);
|
||||
|
||||
xce_val_t good_val, bad_val;
|
||||
memset(&good_val, 0, sizeof(good_val));
|
||||
good_val.which = Value_u_fvalue;
|
||||
good_val.u.fvalue = 4.0f;
|
||||
bad_val = good_val;
|
||||
|
||||
xce_resval_t good = { .name = "slots", .val = &good_val };
|
||||
xce_resval_t bad = { .name = "totally-fake-resource-xyz",
|
||||
.val = &bad_val };
|
||||
xce_resval_t* items[2] = { &bad, &good };
|
||||
xce_resval_list_t in = { .count = 2, .vals = items };
|
||||
|
||||
xce_resval_t* out_items[2] = { NULL, NULL };
|
||||
xce_resval_list_t applied = { .count = -1, .vals = out_items };
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(0, update_resval_list(&g_tc.c, w, &in, &applied));
|
||||
|
||||
TEST_ASSERT_EQUAL_INT_MESSAGE(1, applied.count,
|
||||
"bug-1583: only the resource the controller accepted may be "
|
||||
"reported as applied");
|
||||
TEST_ASSERT_TRUE(applied.vals[0] == &good);
|
||||
TEST_ASSERT_EQUAL_FLOAT(4.0f, get_worker_res_fval(w, "slots"));
|
||||
|
||||
teardown_test_cluster();
|
||||
}
|
||||
|
||||
/* ── Task 1.1: Tests for apply_join_state ──────────────────────────── */
|
||||
|
||||
/*
|
||||
|
|
@ -1638,6 +1679,8 @@ void test_worker_join(void)
|
|||
|
||||
RUN_TEST(test_update_resvals_logs_actual_rc_not_stale_errno);
|
||||
|
||||
RUN_TEST(test_update_resval_list_reports_only_applied_items);
|
||||
|
||||
/* Task 1.1: apply_join_state (shared status/resource update) */
|
||||
RUN_TEST(test_apply_join_state_clears_unavail);
|
||||
RUN_TEST(test_apply_join_state_applies_hosttype_override);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue