Skip to content

Commit e5c7941

Browse files
committed
revert(install): restore the activation-transaction diagnostics to main
The refusal notes changed the error text the Windows launcher guards match against, and test-windows-guards went red on this PR after they landed. They were investigation instrumentation and they succeeded -- they turned 'staging transaction open failed (status -3, os 0)' into ERROR_DISK_FULL and named the exact site -- but a diagnostic that shifts a matched error string does not belong in a release-blocking change. Worth redoing deliberately on its own, with the guards' expectations updated in the same commit. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent 375d11e commit e5c7941

2 files changed

Lines changed: 2 additions & 73 deletions

File tree

‎src/cli/activation_transaction.c‎

Lines changed: 1 addition & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -991,11 +991,9 @@ static cbm_activation_transaction_status_t activation_create_unique(
991991
free(candidate);
992992
free(name);
993993
if (created != ACTIVATION_CREATE_EXISTS) {
994-
activation_note_refusal("io-site-994", 0UL);
995994
return CBM_ACTIVATION_TRANSACTION_IO;
996995
}
997996
}
998-
activation_note_refusal("io-site-997", 0UL);
999997
return CBM_ACTIVATION_TRANSACTION_IO;
1000998
}
1001999

@@ -1267,18 +1265,6 @@ static cbm_activation_transaction_status_t activation_transaction_prepare(
12671265
if (!activation_directory_secure(transaction->directory_path, &transaction->directory_fd,
12681266
&transaction->directory_identity)) {
12691267
#endif
1270-
/* The one refusal on this path that said nothing: the caller reported
1271-
* "status -3, os 0" because destroy() below clobbers GetLastError and no
1272-
* note was set. Capture both before unwinding -- a target directory that
1273-
* fails the exact-owner rule is a completely different problem from an
1274-
* unreadable source, and telling them apart used to cost a full guard
1275-
* run per guess. */
1276-
#ifdef _WIN32
1277-
unsigned long secure_os_error = (unsigned long)GetLastError();
1278-
#else
1279-
unsigned long secure_os_error = 0UL;
1280-
#endif
1281-
activation_note_refusal("target-directory-not-secure", secure_os_error);
12821268
activation_transaction_destroy(transaction);
12831269
return CBM_ACTIVATION_TRANSACTION_IO;
12841270
}
@@ -1303,7 +1289,6 @@ static cbm_activation_transaction_status_t activation_transaction_prepare(
13031289
if (!durable || !closed || !activation_sync_directory(transaction)) {
13041290
(void)activation_discard_staged_assets(transaction);
13051291
activation_transaction_destroy(transaction);
1306-
activation_note_refusal("io-site-1304", 0UL);
13071292
return CBM_ACTIVATION_TRANSACTION_IO;
13081293
}
13091294
}
@@ -1347,7 +1332,6 @@ cbm_activation_transaction_status_t cbm_activation_transaction_stage_bytes(
13471332
bool closed = activation_native_close(staged);
13481333
if (!written || !durable || !closed || !activation_sync_directory(transaction)) {
13491334
activation_failed_stage_cleanup(transaction);
1350-
activation_note_refusal("io-site-1347", 0UL);
13511335
return CBM_ACTIVATION_TRANSACTION_IO;
13521336
}
13531337
*transaction_out = transaction;
@@ -1374,17 +1358,6 @@ static bool activation_source_open(const char *path, activation_native_file_t *f
13741358
bool snapshot_ok =
13751359
src_dir_ok && activation_external_snapshot_with_owner(path, false, &exists, &expected);
13761360
if (!src_dir_ok || !snapshot_ok || !exists) {
1377-
/* Three different refusals, and the caller only sees one boolean: an
1378-
* insecure source directory, a snapshot that could not be taken, and a
1379-
* source that simply is not there are separate bugs. Name which one
1380-
* before the frees below, because free() clobbers GetLastError and the
1381-
* caller's report then reads "status -3, os 0" -- an I/O failure with no
1382-
* cause, which is what made this take a full guard run per guess. */
1383-
unsigned long os_error = GetLastError();
1384-
activation_note_refusal(!src_dir_ok ? "source directory not secure"
1385-
: !snapshot_ok ? "source snapshot failed"
1386-
: "source file missing",
1387-
os_error);
13881361
free(directory);
13891362
free(name);
13901363
return false;
@@ -1494,7 +1467,6 @@ cbm_activation_transaction_status_t cbm_activation_transaction_stage_file(
14941467
activation_native_file_t source = ACTIVATION_INVALID_FILE;
14951468
if (!activation_source_open(candidate_path, &source)) {
14961469
activation_failed_stage_cleanup(transaction);
1497-
activation_note_refusal("io-site-1493", 0UL);
14981470
return CBM_ACTIVATION_TRANSACTION_IO;
14991471
}
15001472
activation_native_file_t staged = ACTIVATION_INVALID_FILE;
@@ -1510,61 +1482,27 @@ cbm_activation_transaction_status_t cbm_activation_transaction_stage_file(
15101482
unsigned char buffer[64U * 1024U];
15111483
size_t total = 0;
15121484
bool copied = true;
1513-
/* Captured AT the failure, not after: the cleanup and close calls below all
1514-
* clobber the thread's last error, which is why this path could only ever
1515-
* report "os 0". */
1516-
unsigned long copy_os_error = 0UL;
1517-
bool copy_failed_on_read = false;
15181485
for (;;) {
15191486
size_t amount = 0;
15201487
if (!activation_native_read(source, buffer, sizeof(buffer), &amount)) {
15211488
copied = false;
1522-
copy_failed_on_read = true;
1523-
#ifdef _WIN32
1524-
copy_os_error = (unsigned long)GetLastError();
1525-
#else
1526-
copy_os_error = (unsigned long)errno;
1527-
#endif
15281489
break;
15291490
}
15301491
if (amount == 0) {
15311492
break;
15321493
}
15331494
if (SIZE_MAX - total < amount || !activation_native_write_all(staged, buffer, amount)) {
15341495
copied = false;
1535-
#ifdef _WIN32
1536-
copy_os_error = (unsigned long)GetLastError();
1537-
#else
1538-
copy_os_error = (unsigned long)errno;
1539-
#endif
15401496
break;
15411497
}
15421498
total += amount;
15431499
}
15441500
bool durable = copied && total > 0 && activation_native_sync(staged);
15451501
bool source_closed = activation_native_close(source);
15461502
bool staged_closed = activation_native_close(staged);
1547-
bool directory_synced = activation_sync_directory(transaction);
15481503
if (!copied || total == 0 || !durable || !source_closed || !staged_closed ||
1549-
!directory_synced) {
1550-
/* Five different failures shared one branch: a short read/write, an
1551-
* EMPTY source, a failed fsync, a failed close, and a failed directory
1552-
* sync are not the same bug. Naming them is what turns a ten-minute
1553-
* guard run per hypothesis into one run that answers the question. */
1504+
!activation_sync_directory(transaction)) {
15541505
activation_failed_stage_cleanup(transaction);
1555-
const char *why = "stage-directory-sync";
1556-
if (!copied) {
1557-
why = copy_failed_on_read ? "stage-copy-read" : "stage-copy-write";
1558-
} else if (total == 0) {
1559-
why = "stage-source-empty";
1560-
} else if (!durable) {
1561-
why = "stage-fsync";
1562-
} else if (!source_closed) {
1563-
why = "stage-source-close";
1564-
} else if (!staged_closed) {
1565-
why = "stage-staged-close";
1566-
}
1567-
activation_note_refusal(why, copy_os_error);
15681506
return CBM_ACTIVATION_TRANSACTION_IO;
15691507
}
15701508
*transaction_out = transaction;
@@ -2012,7 +1950,6 @@ cbm_activation_transaction_status_t cbm_activation_transaction_commit(
20121950
return CBM_ACTIVATION_TRANSACTION_INVALID_STATE;
20131951
}
20141952
if (!activation_target_still_original(transaction)) {
2015-
activation_note_refusal("io-site-1976", 0UL);
20161953
return CBM_ACTIVATION_TRANSACTION_IO;
20171954
}
20181955
if (transaction->action == ACTIVATION_REPLACE) {
@@ -2022,7 +1959,6 @@ cbm_activation_transaction_status_t cbm_activation_transaction_commit(
20221959
transaction->staged_name, &transaction->staged_identity,
20231960
&staged_exists) ||
20241961
!staged_exists) {
2025-
activation_note_refusal("io-site-1985", 0UL);
20261962
return CBM_ACTIVATION_TRANSACTION_IO;
20271963
}
20281964
}
@@ -2031,7 +1967,6 @@ cbm_activation_transaction_status_t cbm_activation_transaction_commit(
20311967
activation_publish_status_t published =
20321968
activation_publish_existing_replacement(transaction);
20331969
if (published == ACTIVATION_PUBLISH_UNCHANGED_ERROR) {
2034-
activation_note_refusal("io-site-1993", 0UL);
20351970
return CBM_ACTIVATION_TRANSACTION_IO;
20361971
}
20371972
if (published == ACTIVATION_PUBLISH_CHANGED_ERROR) {
@@ -2051,7 +1986,6 @@ cbm_activation_transaction_status_t cbm_activation_transaction_commit(
20511986
!reservation_exists ||
20521987
!activation_rename(transaction, transaction->target_path, transaction->target_name,
20531988
transaction->backup_path, transaction->backup_name, true)) {
2054-
activation_note_refusal("io-site-2012", 0UL);
20551989
return CBM_ACTIVATION_TRANSACTION_IO;
20561990
}
20571991
transaction->backup_identity = transaction->target_identity;
@@ -2065,7 +1999,6 @@ cbm_activation_transaction_status_t cbm_activation_transaction_commit(
20651999
}
20662000
activation_publish_status_t published = activation_publish_absent_replacement(transaction);
20672001
if (published == ACTIVATION_PUBLISH_UNCHANGED_ERROR) {
2068-
activation_note_refusal("io-site-2025", 0UL);
20692002
return CBM_ACTIVATION_TRANSACTION_IO;
20702003
}
20712004
if (published == ACTIVATION_PUBLISH_CHANGED_ERROR) {
@@ -2114,15 +2047,13 @@ cbm_activation_transaction_status_t cbm_activation_transaction_finalize(
21142047
return CBM_ACTIVATION_TRANSACTION_INVALID_STATE;
21152048
}
21162049
if (!activation_directory_still_valid(transaction)) {
2117-
activation_note_refusal("io-site-2073", 0UL);
21182050
return CBM_ACTIVATION_TRANSACTION_IO;
21192051
}
21202052
if (transaction->backup_contains_target) {
21212053
activation_unlink_status_t removed = activation_unlink_expected(
21222054
transaction, transaction->backup_path, transaction->backup_name,
21232055
&transaction->backup_identity, true);
21242056
if (removed == ACTIVATION_UNLINK_ERROR) {
2125-
activation_note_refusal("io-site-2080", 0UL);
21262057
return CBM_ACTIVATION_TRANSACTION_IO;
21272058
}
21282059
if (removed == ACTIVATION_UNLINK_DEFERRED) {
@@ -2134,7 +2065,6 @@ cbm_activation_transaction_status_t cbm_activation_transaction_finalize(
21342065
transaction->backup_contains_target = false;
21352066
}
21362067
if (!activation_sync_directory(transaction)) {
2137-
activation_note_refusal("io-site-2091", 0UL);
21382068
return CBM_ACTIVATION_TRANSACTION_IO;
21392069
}
21402070
transaction->state = ACTIVATION_FINALIZED;

‎tests/windows/test_windows_launcher.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,8 +1414,7 @@ def assert_uninstall_immediate_reinstall_safe(
14141414
reinstall = install_managed(portable_payload, managed_dir, env)
14151415
require(
14161416
reinstall.returncode == 0,
1417-
"immediate managed reinstall failed: rc=%s output=%r"
1418-
% (reinstall.returncode, output_text(reinstall)[-800:]),
1417+
"immediate managed reinstall failed: %s" % output_text(reinstall)[-800:],
14191418
)
14201419
new_current, new_current_bytes, _ = find_and_validate_current(managed_dir)
14211420
deadline = time.monotonic() + 30

0 commit comments

Comments
 (0)