Compare commits

..

5 Commits

Author SHA1 Message Date
overtrue 7fb98ef228 test(ci): guard watchdog alert wiring 2026-08-22 11:56:26 +08:00
overtrue 570f31442b merge: update test validation evidence branch 2026-08-22 11:10:45 +08:00
overtrue 07e02fcb79 ci: wire MinIO interop failure alerts 2026-08-22 10:29:26 +08:00
overtrue 97b3a36f77 test(ci): guard scheduled alert issue wiring 2026-08-22 10:22:41 +08:00
overtrue f420357a71 ci: detect incomplete scheduled validation runs 2026-08-22 08:10:16 +08:00
8 changed files with 449 additions and 319 deletions
@@ -14,9 +14,10 @@
name: "Schedule Failure Issue"
description: >-
Open (or update) a tracking issue when a scheduled workflow run fails.
Open (or update) a tracking issue when a scheduled workflow run fails or
does not complete normally.
Dedupes by workflow name: if an open issue titled
"[scheduled-failure] <workflow name>" already exists, the failure is
"[scheduled-failure] <workflow name>" already exists, the result is
appended as a comment; otherwise a new issue is created. This is the
single alerting mechanism for all scheduled pipelines (backlog#1149 ci-8).
@@ -38,6 +39,26 @@ inputs:
Set to an empty string to skip labeling.
required: false
default: "infrastructure"
source-run-id:
description: "Run ID to report. Defaults to the current workflow run."
required: false
default: ${{ github.run_id }}
source-run-attempt:
description: "Run attempt to report. Defaults to the current attempt."
required: false
default: ${{ github.run_attempt }}
source-event:
description: "Trigger event of the run being reported."
required: false
default: ${{ github.event_name }}
source-ref-name:
description: "Ref name of the run being reported."
required: false
default: ${{ github.ref_name }}
source-sha:
description: "Commit SHA of the run being reported."
required: false
default: ${{ github.sha }}
runs:
using: "composite"
@@ -48,17 +69,21 @@ runs:
GH_TOKEN: ${{ inputs.github-token }}
WORKFLOW_NAME: ${{ inputs.workflow-name }}
ISSUE_LABEL: ${{ inputs.label }}
SOURCE_RUN_ID: ${{ inputs.source-run-id }}
SOURCE_RUN_ATTEMPT: ${{ inputs.source-run-attempt }}
SOURCE_EVENT: ${{ inputs.source-event }}
SOURCE_REF_NAME: ${{ inputs.source-ref-name }}
SOURCE_SHA: ${{ inputs.source-sha }}
run: |
set -euo pipefail
title="[scheduled-failure] ${WORKFLOW_NAME}"
run_url="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
run_url="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${SOURCE_RUN_ID}"
# Failed job names for this run attempt. The alert job runs while the
# run as a whole is still in progress, so inspect the jobs that have
# already completed with a non-success conclusion.
# Inspect the reported run attempt. It can be the current in-workflow
# failure or a completed run observed by the external watchdog.
failed_jobs="$(gh api \
"repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/attempts/${GITHUB_RUN_ATTEMPT}/jobs" \
"repos/${GITHUB_REPOSITORY}/actions/runs/${SOURCE_RUN_ID}/attempts/${SOURCE_RUN_ATTEMPT}/jobs" \
--paginate \
--jq '.jobs[]
| select(.conclusion == "failure" or .conclusion == "timed_out" or .conclusion == "cancelled")
@@ -68,13 +93,13 @@ runs:
fi
body="$(cat <<EOF
Scheduled run of **${WORKFLOW_NAME}** failed.
Scheduled run of **${WORKFLOW_NAME}** did not complete successfully.
- Run: ${run_url} (attempt ${GITHUB_RUN_ATTEMPT})
- Event: \`${GITHUB_EVENT_NAME}\`
- Ref: \`${GITHUB_REF_NAME}\` @ \`${GITHUB_SHA}\`
- Run: ${run_url} (attempt ${SOURCE_RUN_ATTEMPT})
- Event: \`${SOURCE_EVENT}\`
- Ref: \`${SOURCE_REF_NAME}\` @ \`${SOURCE_SHA}\`
Failed jobs:
Non-success jobs:
${failed_jobs}
EOF
)"
+20
View File
@@ -1032,3 +1032,23 @@ jobs:
echo "🎉 Released $TAG successfully!"
echo "📄 Release URL: ${{ needs.create-release.outputs.release_url }}"
alert-on-failure:
name: Alert on scheduled failure
needs: [build-check, prepare-platform-matrix, build-rustfs, build-summary]
if: >-
always() && github.event_name == 'schedule' &&
(contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled'))
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
issues: write
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
persist-credentials: false
- name: Open or update failure-tracking issue
uses: ./.github/actions/schedule-failure-issue
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
+34
View File
@@ -1032,3 +1032,37 @@ jobs:
path: artifacts/s3tests-single/**
if-no-files-found: ignore
retention-days: 3
alert-on-failure:
name: Alert on scheduled failure
needs:
- typos
- quick-checks
- test-and-lint
- test-ilm-integration-serial
- test-and-lint-rio-v2
- test-and-lint-protocols
- build-rustfs-debug-binary
- build-rustfs-debug-binary-rio-v2
- uring-integration
- e2e-tests
- e2e-full
- e2e-tests-rio-v2
- s3-implemented-tests
- s3-lifecycle-behavior-tests
if: >-
always() && github.event_name == 'schedule' &&
(contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled'))
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
issues: write
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
persist-credentials: false
- name: Open or update failure-tracking issue
uses: ./.github/actions/schedule-failure-issue
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
+18
View File
@@ -121,3 +121,21 @@ jobs:
cargo nextest run --run-ignored ignored-only --no-tests=fail \
-p "$INTEROP_PACKAGE" --features "$INTEROP_FEATURES" \
-E "$INTEROP_FILTER"
alert-on-failure:
name: Alert on scheduled failure
needs: [minio-interop]
if: always() && github.event_name == 'schedule' && contains(needs.*.result, 'failure')
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
issues: write
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
persist-credentials: false
- name: Open or update failure-tracking issue
uses: ./.github/actions/schedule-failure-issue
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
+20
View File
@@ -194,3 +194,23 @@ jobs:
- name: Run HA leader failover live checks (three-node Raft cluster in Docker)
run: bash scripts/test/vault_ha_kms_live.sh
alert-on-failure:
name: Alert on scheduled failure
needs: [build, kms-vault-lane, kms-vault-ha-failover]
if: >-
always() && github.event_name == 'schedule' &&
(contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled'))
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
issues: write
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
persist-credentials: false
- name: Open or update failure-tracking issue
uses: ./.github/actions/schedule-failure-issue
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,63 @@
# Copyright 2024 RustFS Team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Scheduled Validation Watchdog
on:
workflow_run:
workflows:
- "Security Audit"
- "Build and Release"
- "Continuous Integration"
- "coverage"
- "e2e-nightly"
- "e2e-s3tests"
- "Fuzz"
- "mint"
- "minio-interop"
- "Nightly GNU Build"
- "Performance A/B"
- "Runner Hygiene"
types: [completed]
permissions:
contents: read
jobs:
alert-on-incomplete-run:
name: Alert on incomplete scheduled run
if: >-
github.event.workflow_run.event == 'schedule' &&
github.event.workflow_run.conclusion != 'success' &&
github.event.workflow_run.conclusion != 'failure'
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
actions: read
contents: read
issues: write
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
persist-credentials: false
- name: Open or update incomplete-run issue
uses: ./.github/actions/schedule-failure-issue
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
workflow-name: ${{ github.event.workflow_run.name }}
source-run-id: ${{ github.event.workflow_run.id }}
source-run-attempt: ${{ github.event.workflow_run.run_attempt }}
source-event: ${{ github.event.workflow_run.event }}
source-ref-name: ${{ github.event.workflow_run.head_branch }}
source-sha: ${{ github.event.workflow_run.head_sha }}
+98 -306
View File
@@ -89,7 +89,6 @@ const DECOMMISSION_STAGE_SOURCE_CLEANUP: &str = "source_cleanup";
const DECOMMISSION_STAGE_ENTRY_FINISHED: &str = "entry_finished";
const DECOMMISSION_PROGRESS_SAVE_INTERVAL: Duration = Duration::seconds(30);
const DECOMMISSION_PROGRESS_SAVE_ITEM_THRESHOLD: usize = 1000;
const DECOMMISSION_PROGRESS_SAVE_RETRY_BACKOFF: Duration = Duration::seconds(1);
const DECOMMISSION_BUCKET_CONCURRENCY_ENV: &str = "RUSTFS_DECOMMISSION_BUCKET_CONCURRENCY";
const DECOMMISSION_BUCKET_CONCURRENCY_DEFAULT_CAP: usize = 4;
const DECOMMISSION_TARGET_CAPACITY_OVERHEAD_PERCENT: usize = 30;
@@ -639,6 +638,22 @@ fn track_decommission_current_object(meta: &mut PoolMeta, idx: usize, bucket: &s
track_decommission_current_object_stage(meta, idx, bucket, object, "")
}
fn touch_decommission_progress(meta: &mut PoolMeta, idx: usize) -> Result<()> {
let pool_count = meta.pools.len();
ensure_valid_decommission_pool_index(pool_count, idx)?;
let Some(pool) = meta.pools.get_mut(idx) else {
return Err(invalid_decommission_pool_index_error(pool_count, idx));
};
let Some(info) = pool.decommission.as_mut() else {
return Err(decommission_metadata_not_initialized_error("touch decommission progress"));
};
pool.last_update = OffsetDateTime::now_utc();
info.mark_progress_saved();
Ok(())
}
fn resolve_decommission_update_after_result(result: Result<bool>) -> Result<bool> {
result.map_err(|err| Error::other(format!("decommission metadata update failed: {err}")))
}
@@ -1468,7 +1483,6 @@ impl TryFrom<PersistedPoolDecommissionInfo> for PoolDecommissionInfo {
terminal_reload_attempt_at: value.terminal_reload_attempt_at,
terminal_reload_failures: value.terminal_reload_failures,
progress_save_item_baseline: value.items_decommissioned.saturating_add(value.items_decommission_failed),
progress_save_retry_after: None,
})
}
}
@@ -1500,7 +1514,6 @@ impl TryFrom<LegacyPoolDecommissionInfo> for PoolDecommissionInfo {
terminal_reload_attempt_at: None,
terminal_reload_failures: Vec::new(),
progress_save_item_baseline: value.items_decommissioned.saturating_add(value.items_decommission_failed),
progress_save_retry_after: None,
})
}
}
@@ -1614,82 +1627,6 @@ impl PoolMeta {
}
}
fn decommission_progress_checkpoint(
&self,
idx: usize,
duration: Duration,
now: OffsetDateTime,
) -> Result<Option<DecommissionProgressCheckpoint>> {
let pool_count = self.pools.len();
ensure_valid_decommission_pool_index(pool_count, idx)?;
let Some(pool) = self.pools.get(idx) else {
return Err(invalid_decommission_pool_index_error(pool_count, idx));
};
let Some(info) = pool.decommission.as_ref() else {
return Err(decommission_metadata_not_initialized_error("update decommission metadata timestamp"));
};
if info.progress_save_retry_after.is_some_and(|retry_after| now < retry_after) {
return Ok(None);
}
let time_threshold_reached = now.unix_timestamp() - pool.last_update.unix_timestamp() >= duration.whole_seconds();
let item_threshold_reached = info.items_since_last_progress_save() >= DECOMMISSION_PROGRESS_SAVE_ITEM_THRESHOLD;
if !time_threshold_reached && !item_threshold_reached {
return Ok(None);
}
Ok(Some(DecommissionProgressCheckpoint {
start_time: info.start_time,
queued: info.queued,
counted_items: info.counted_items(),
checkpoint_at: now,
}))
}
fn commit_decommission_progress_checkpoint(&mut self, idx: usize, checkpoint: DecommissionProgressCheckpoint) -> bool {
let Some(pool) = self.pools.get_mut(idx) else {
return false;
};
let Some(info) = pool.decommission.as_mut() else {
return false;
};
if info.start_time != checkpoint.start_time
|| info.queued != checkpoint.queued
|| !is_decommission_active(info.complete, info.failed, info.canceled)
{
return false;
}
info.progress_save_item_baseline = info.progress_save_item_baseline.max(checkpoint.counted_items);
info.progress_save_retry_after = None;
pool.last_update = pool.last_update.max(checkpoint.checkpoint_at);
true
}
fn defer_decommission_progress_checkpoint(
&mut self,
idx: usize,
checkpoint: DecommissionProgressCheckpoint,
retry_after: OffsetDateTime,
) {
let Some(pool) = self.pools.get_mut(idx) else {
return;
};
let Some(info) = pool.decommission.as_mut() else {
return;
};
if info.start_time == checkpoint.start_time
&& info.queued == checkpoint.queued
&& is_decommission_active(info.complete, info.failed, info.canceled)
{
info.progress_save_retry_after = Some(retry_after);
}
}
fn load_from_config_data(&mut self, data: Vec<u8>) -> Result<()> {
if data.is_empty() {
return Ok(());
@@ -2050,9 +1987,30 @@ impl PoolMeta {
}
pub fn update_after(&mut self, idx: usize, duration: Duration) -> Result<bool> {
Ok(self
.decommission_progress_checkpoint(idx, duration, OffsetDateTime::now_utc())?
.is_some())
let pool_count = self.pools.len();
ensure_valid_decommission_pool_index(pool_count, idx)?;
let (last_update, item_threshold_reached) = match self.pools.get(idx) {
Some(pool) if let Some(info) = pool.decommission.as_ref() => (
pool.last_update,
info.items_since_last_progress_save() >= DECOMMISSION_PROGRESS_SAVE_ITEM_THRESHOLD,
),
Some(_) => {
return Err(decommission_metadata_not_initialized_error("update decommission metadata timestamp"));
}
None => return Err(invalid_decommission_pool_index_error(pool_count, idx)),
};
let now = OffsetDateTime::now_utc();
if now.unix_timestamp() - last_update.unix_timestamp() >= duration.whole_seconds() || item_threshold_reached {
let Some(pool) = self.pools.get_mut(idx) else {
return Err(invalid_decommission_pool_index_error(pool_count, idx));
};
pool.last_update = now;
return Ok(true);
}
Ok(false)
}
pub fn validate(&self, pools: Vec<Arc<Sets>>) -> Result<bool> {
@@ -2193,16 +2151,6 @@ pub struct PoolDecommissionInfo {
pub terminal_reload_failures: Vec<String>,
#[serde(skip)]
pub progress_save_item_baseline: usize,
#[serde(skip)]
pub progress_save_retry_after: Option<OffsetDateTime>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
struct DecommissionProgressCheckpoint {
start_time: Option<OffsetDateTime>,
queued: bool,
counted_items: usize,
checkpoint_at: OffsetDateTime,
}
impl PoolDecommissionInfo {
@@ -2237,7 +2185,6 @@ impl PoolDecommissionInfo {
fn mark_progress_saved(&mut self) {
self.progress_save_item_baseline = self.counted_items();
self.progress_save_retry_after = None;
}
pub fn bucket_push(&mut self, bucket: &DecomBucketInfo) {
@@ -2542,40 +2489,6 @@ impl ECStore {
snapshot.save(self.pools.clone()).await
}
async fn save_decommission_progress_checkpoint(&self, idx: usize) -> Result<bool> {
// Lock order: save gate, then the short pool metadata read/write sections. Peer
// reloads are intentionally performed by the caller after both locks are released.
let _save_guard = self.pool_meta_save_gate.lock().await;
let (snapshot, checkpoint) = {
let pool_meta = self.pool_meta.read().await;
let Some(checkpoint) = pool_meta.decommission_progress_checkpoint(
idx,
DECOMMISSION_PROGRESS_SAVE_INTERVAL,
OffsetDateTime::now_utc(),
)?
else {
return Ok(false);
};
let mut snapshot = pool_meta.clone();
let Some(pool) = snapshot.pools.get_mut(idx) else {
return Err(invalid_decommission_pool_index_error(snapshot.pools.len(), idx));
};
pool.last_update = checkpoint.checkpoint_at;
(snapshot, checkpoint)
};
if let Err(err) = snapshot.save(self.pools.clone()).await {
let retry_after = OffsetDateTime::now_utc() + DECOMMISSION_PROGRESS_SAVE_RETRY_BACKOFF;
let mut pool_meta = self.pool_meta.write().await;
pool_meta.defer_decommission_progress_checkpoint(idx, checkpoint, retry_after);
return Err(err);
}
let mut pool_meta = self.pool_meta.write().await;
Ok(pool_meta.commit_decommission_progress_checkpoint(idx, checkpoint))
}
async fn save_current_pool_meta_for_decommission_start(
&self,
indices: &[usize],
@@ -2958,7 +2871,7 @@ impl ECStore {
Ok(())
}
async fn track_decommission_entry_progress_stage(
async fn save_decommission_entry_progress_stage(
&self,
idx: usize,
bucket: &str,
@@ -2969,6 +2882,22 @@ impl ECStore {
let mut pool_meta = self.pool_meta.write().await;
track_decommission_current_object_stage(&mut pool_meta, idx, bucket, object, stage)
.map_err(|err| with_decommission_entry_context(stage, bucket, object, err))?;
touch_decommission_progress(&mut pool_meta, idx)
.map_err(|err| with_decommission_entry_context(stage, bucket, object, err))?;
}
if let Some(err) = resolve_decommission_progress_save_result(self.save_current_pool_meta().await) {
warn!(
event = EVENT_DECOMMISSION_ENTRY,
component = LOG_COMPONENT_ECSTORE,
subsystem = LOG_SUBSYSTEM_POOLS,
pool_index = idx,
bucket = %bucket,
object = %object,
stage,
error = ?err,
"Decommission progress stage save failed"
);
}
Ok(())
@@ -3236,7 +3165,7 @@ impl ECStore {
let bucket_name = bucket.clone();
let object_name = rd.object_info.name.clone();
self.track_decommission_entry_progress_stage(
self.save_decommission_entry_progress_stage(
idx,
bucket_name.as_str(),
object_name.as_str(),
@@ -3330,7 +3259,7 @@ impl ECStore {
}
decommission_cancel_signal_result(rx.is_cancelled())?;
self.track_decommission_entry_progress_stage(
self.save_decommission_entry_progress_stage(
idx,
bucket.as_str(),
entry.name.as_str(),
@@ -3338,7 +3267,7 @@ impl ECStore {
)
.await?;
self.track_decommission_entry_progress_stage(
self.save_decommission_entry_progress_stage(
idx,
bucket.as_str(),
entry.name.as_str(),
@@ -3405,42 +3334,34 @@ impl ECStore {
}
};
self.track_decommission_entry_progress_stage(
idx,
bucket.as_str(),
entry.name.as_str(),
DECOMMISSION_STAGE_ENTRY_FINISHED,
)
.await?;
self.save_decommission_entry_progress_stage(idx, bucket.as_str(), entry.name.as_str(), DECOMMISSION_STAGE_ENTRY_FINISHED)
.await?;
if should_save_progress {
match self.save_decommission_progress_checkpoint(idx).await {
Ok(true) => {
if let Some(notification_sys) = runtime_sources::notification_sys()
&& let Err(err) = resolve_decommission_entry_reload_result(
notification_sys.reload_pool_meta().await,
bucket.as_str(),
entry.name.as_str(),
)
{
warn!("{err}");
}
}
Ok(false) => {}
Err(err) => {
if let Some(err) = resolve_decommission_progress_save_result(Err(err)) {
warn!(
event = EVENT_DECOMMISSION_ENTRY,
component = LOG_COMPONENT_ECSTORE,
subsystem = LOG_SUBSYSTEM_POOLS,
pool_index = idx,
bucket = %bucket,
object = %entry.name,
state = "progress_save_failed",
error = %err,
"Decommission progress save failed; continuing and will retry at the next checkpoint"
);
}
let save_result = self.save_current_pool_meta().await;
if let Some(err) = resolve_decommission_progress_save_result(save_result) {
warn!(
event = EVENT_DECOMMISSION_ENTRY,
component = LOG_COMPONENT_ECSTORE,
subsystem = LOG_SUBSYSTEM_POOLS,
pool_index = idx,
bucket = %bucket,
object = %entry.name,
state = "progress_save_failed",
error = %err,
"Decommission progress save failed; continuing and will retry at the next checkpoint"
);
} else {
let mut pool_meta = self.pool_meta.write().await;
pool_meta.mark_decommission_progress_saved();
if let Some(notification_sys) = runtime_sources::notification_sys()
&& let Err(err) = resolve_decommission_entry_reload_result(
notification_sys.reload_pool_meta().await,
bucket.as_str(),
entry.name.as_str(),
)
{
warn!("{err}");
}
}
}
@@ -5343,11 +5264,11 @@ pub(crate) fn fallback_free_capacity_dedup(disks: &[rustfs_madmin::Disk]) -> usi
#[cfg(test)]
mod pools_tests {
use super::{
DECOMMISSION_PROGRESS_SAVE_INTERVAL, DECOMMISSION_PROGRESS_SAVE_ITEM_THRESHOLD, DECOMMISSION_PROGRESS_SAVE_RETRY_BACKOFF,
DecomBucketInfo, DecommissionStartPoolState, DecommissionTerminalState, ListCallback, PoolDecommissionInfo, PoolMeta,
PoolSpaceInfo, PoolStatus, apply_decommission_status_space_info, bind_decommission_cancelers,
bind_missing_decommission_cancelers, cancel_decommission_canceler, classify_decommission_terminal_state,
count_decommission_item, decommission_cancel_signal_result, decommission_item_size, decommission_meta_bucket_options,
DECOMMISSION_PROGRESS_SAVE_INTERVAL, DECOMMISSION_PROGRESS_SAVE_ITEM_THRESHOLD, DecomBucketInfo,
DecommissionStartPoolState, DecommissionTerminalState, ListCallback, PoolDecommissionInfo, PoolMeta, PoolSpaceInfo,
PoolStatus, apply_decommission_status_space_info, bind_decommission_cancelers, bind_missing_decommission_cancelers,
cancel_decommission_canceler, classify_decommission_terminal_state, count_decommission_item,
decommission_cancel_signal_result, decommission_item_size, decommission_meta_bucket_options,
decommission_start_pool_state, dedup_indices, default_decommission_bucket_concurrency,
ensure_decommission_cancel_allowed, ensure_decommission_clear_allowed, ensure_decommission_listing_disks_available,
ensure_decommission_not_rebalancing, ensure_decommission_start_allowed, ensure_decommission_start_keeps_active_pool,
@@ -5372,8 +5293,9 @@ mod pools_tests {
should_preserve_decommission_canceled_state, should_reject_decommission_cancel_as_terminal,
should_retry_decommission_cancel_reload, should_retry_decommission_listing, should_skip_canceled_decommission_routine,
split_decommission_buckets, take_and_cancel_decommission_canceler, take_decommission_canceler,
track_decommission_current_object, track_decommission_current_object_stage, validate_start_decommission_request,
wait_decommission_listing_retry, wait_decommission_worker_drain, with_decommission_entry_context,
touch_decommission_progress, track_decommission_current_object, track_decommission_current_object_stage,
validate_start_decommission_request, wait_decommission_listing_retry, wait_decommission_worker_drain,
with_decommission_entry_context,
};
use crate::data_movement;
use crate::disk::endpoint::Endpoint;
@@ -6616,7 +6538,7 @@ mod pools_tests {
}
#[test]
fn test_track_decommission_stage_does_not_advance_checkpoint_state() {
fn test_touch_decommission_progress_updates_last_update_and_save_baseline() {
let mut meta = PoolMeta {
pools: vec![PoolStatus {
id: 0,
@@ -6631,13 +6553,11 @@ mod pools_tests {
..Default::default()
};
track_decommission_current_object_stage(&mut meta, 0, "bucket", "object", "migrate_object")
.expect("valid decommission progress should be tracked");
touch_decommission_progress(&mut meta, 0).expect("valid decommission progress should be touched");
assert_eq!(meta.pools[0].last_update, OffsetDateTime::UNIX_EPOCH);
assert!(meta.pools[0].last_update > OffsetDateTime::UNIX_EPOCH);
let info = meta.pools[0].decommission.as_ref().expect("decommission info should exist");
assert_eq!(info.items_since_last_progress_save(), 5);
assert_eq!(info.stage, "migrate_object");
assert_eq!(info.items_since_last_progress_save(), 0);
}
#[test]
@@ -6712,134 +6632,6 @@ mod pools_tests {
assert_eq!(info.items_since_last_progress_save(), 1);
}
#[test]
fn test_pool_meta_update_after_does_not_advance_last_update_before_save() {
let last_update = OffsetDateTime::UNIX_EPOCH;
let mut meta = PoolMeta {
pools: vec![PoolStatus {
id: 0,
cmd_line: "pool-0".to_string(),
last_update,
decommission: Some(PoolDecommissionInfo {
start_time: Some(last_update),
items_decommissioned: DECOMMISSION_PROGRESS_SAVE_ITEM_THRESHOLD,
..Default::default()
}),
}],
..Default::default()
};
assert!(
meta.update_after(0, DECOMMISSION_PROGRESS_SAVE_INTERVAL)
.expect("item threshold should request a checkpoint")
);
assert_eq!(meta.pools[0].last_update, last_update);
}
#[test]
fn test_decommission_progress_checkpoint_commits_exact_snapshot_watermark() {
let start_time = OffsetDateTime::UNIX_EPOCH;
let checkpoint_at = start_time + Duration::seconds(30);
let mut meta = PoolMeta {
pools: vec![PoolStatus {
id: 0,
cmd_line: "pool-0".to_string(),
last_update: start_time,
decommission: Some(PoolDecommissionInfo {
start_time: Some(start_time),
items_decommissioned: DECOMMISSION_PROGRESS_SAVE_ITEM_THRESHOLD,
..Default::default()
}),
}],
..Default::default()
};
let checkpoint = meta
.decommission_progress_checkpoint(0, DECOMMISSION_PROGRESS_SAVE_INTERVAL, checkpoint_at)
.expect("valid decommission state should produce a checkpoint")
.expect("item threshold should produce a checkpoint");
meta.count_item(0, 1, false);
assert!(meta.commit_decommission_progress_checkpoint(0, checkpoint));
let info = meta.pools[0].decommission.as_ref().expect("decommission info should exist");
assert_eq!(info.progress_save_item_baseline, checkpoint.counted_items);
assert_eq!(info.items_since_last_progress_save(), 1);
assert_eq!(meta.pools[0].last_update, checkpoint_at);
}
#[test]
fn test_decommission_progress_checkpoint_backoff_does_not_advance_baseline() {
let start_time = OffsetDateTime::UNIX_EPOCH;
let checkpoint_at = start_time + Duration::seconds(30);
let retry_after = checkpoint_at + DECOMMISSION_PROGRESS_SAVE_RETRY_BACKOFF;
let mut meta = PoolMeta {
pools: vec![PoolStatus {
id: 0,
cmd_line: "pool-0".to_string(),
last_update: start_time,
decommission: Some(PoolDecommissionInfo {
start_time: Some(start_time),
items_decommissioned: DECOMMISSION_PROGRESS_SAVE_ITEM_THRESHOLD,
..Default::default()
}),
}],
..Default::default()
};
let checkpoint = meta
.decommission_progress_checkpoint(0, DECOMMISSION_PROGRESS_SAVE_INTERVAL, checkpoint_at)
.expect("valid decommission state should produce a checkpoint")
.expect("item threshold should produce a checkpoint");
meta.defer_decommission_progress_checkpoint(0, checkpoint, retry_after);
assert!(
meta.decommission_progress_checkpoint(0, DECOMMISSION_PROGRESS_SAVE_INTERVAL, checkpoint_at)
.expect("retry backoff check should succeed")
.is_none()
);
assert_eq!(meta.pools[0].last_update, start_time);
assert_eq!(
meta.pools[0]
.decommission
.as_ref()
.expect("decommission info should exist")
.progress_save_item_baseline,
0
);
}
#[test]
fn test_decommission_progress_checkpoint_count_scales_with_threshold() {
let start_time = OffsetDateTime::UNIX_EPOCH;
let checkpoint_at = start_time;
let mut meta = PoolMeta {
pools: vec![PoolStatus {
id: 0,
cmd_line: "pool-0".to_string(),
last_update: start_time,
decommission: Some(PoolDecommissionInfo {
start_time: Some(start_time),
..Default::default()
}),
}],
..Default::default()
};
let mut checkpoint_count = 0;
for _ in 0..(DECOMMISSION_PROGRESS_SAVE_ITEM_THRESHOLD * 10) {
meta.count_item(0, 1, false);
if let Some(checkpoint) = meta
.decommission_progress_checkpoint(0, DECOMMISSION_PROGRESS_SAVE_INTERVAL, checkpoint_at)
.expect("valid decommission state should produce a checkpoint")
{
checkpoint_count += 1;
assert!(meta.commit_decommission_progress_checkpoint(0, checkpoint));
}
}
assert_eq!(checkpoint_count, 10);
}
#[test]
fn test_ensure_decommission_not_rebalancing_rejects_running_rebalance() {
let err = ensure_decommission_not_rebalancing(true).expect_err("rebalance running should be rejected");
+159 -1
View File
@@ -15,6 +15,20 @@ from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
SCHEDULED_ALERT_WORKFLOWS = (
".github/workflows/audit.yml",
".github/workflows/build.yml",
".github/workflows/ci.yml",
".github/workflows/coverage.yml",
".github/workflows/e2e-replication-nightly.yml",
".github/workflows/e2e-s3tests.yml",
".github/workflows/fuzz.yml",
".github/workflows/mint.yml",
".github/workflows/minio-interop.yml",
".github/workflows/nightly-gnu.yml",
".github/workflows/performance-ab.yml",
".github/workflows/runner-hygiene.yml",
)
def words(value: str) -> set[str]:
@@ -252,6 +266,79 @@ def check_profile_definitions(root: Path) -> list[str]:
return errors
def check_scheduled_alerts(root: Path) -> list[str]:
errors: list[str] = []
for relative in SCHEDULED_ALERT_WORKFLOWS:
path = root / relative
try:
lines = path.read_text().splitlines()
except FileNotFoundError:
errors.append(f"{relative}: missing scheduled validation workflow")
continue
try:
start = lines.index(" alert-on-failure:") + 1
except ValueError:
errors.append(f"{relative}: missing alert-on-failure job")
continue
end = next(
(index for index in range(start, len(lines)) if re.fullmatch(r" [A-Za-z0-9_-]+:", lines[index])),
len(lines),
)
job = "\n".join(line.split("#", 1)[0] for line in lines[start:end])
required = (
"always()",
"github.event_name == 'schedule'",
"contains(needs.*.result, 'failure')",
"issues: write",
"uses: ./.github/actions/schedule-failure-issue",
"github-token: ${{ secrets.GITHUB_TOKEN }}",
)
missing = [token for token in required if token not in job]
if missing:
errors.append(f"{relative}: alert-on-failure missing {', '.join(missing)}")
watchdog_path = root / ".github/workflows/scheduled-validation-watchdog.yml"
try:
watchdog = "\n".join(
line.split("#", 1)[0] for line in watchdog_path.read_text().splitlines()
)
except FileNotFoundError:
errors.append(".github/workflows/scheduled-validation-watchdog.yml: missing completion watchdog")
return errors
for relative in SCHEDULED_ALERT_WORKFLOWS:
path = root / relative
if not path.is_file():
continue
source = path.read_text()
match = re.search(r"^name:\s*[\"']?([^\"'\n]+)", source, re.MULTILINE)
if not match:
errors.append(f"{relative}: missing workflow name")
elif f'- "{match.group(1).strip()}"' not in watchdog:
errors.append(f"{relative}: missing from scheduled completion watchdog")
required = (
"github.event.workflow_run.event == 'schedule'",
"github.event.workflow_run.conclusion != 'success'",
"github.event.workflow_run.conclusion != 'failure'",
"actions: read",
"issues: write",
"uses: ./.github/actions/schedule-failure-issue",
"github-token: ${{ secrets.GITHUB_TOKEN }}",
"workflow-name: ${{ github.event.workflow_run.name }}",
"source-event: ${{ github.event.workflow_run.event }}",
"source-ref-name: ${{ github.event.workflow_run.head_branch }}",
"source-sha: ${{ github.event.workflow_run.head_sha }}",
"source-run-id: ${{ github.event.workflow_run.id }}",
"source-run-attempt: ${{ github.event.workflow_run.run_attempt }}",
)
missing = [token for token in required if token not in watchdog]
if missing:
errors.append(
".github/workflows/scheduled-validation-watchdog.yml: missing " + ", ".join(missing)
)
return errors
def check_profile_listing(root: Path, profile: str, listing: Path) -> list[str]:
try:
expected_digest = profile_selection(root, profile)
@@ -281,6 +368,7 @@ def validate(root: Path) -> list[str]:
errors.extend(check_runner_selection(root))
errors.extend(check_s3_tests_runner(root))
errors.extend(check_profile_definitions(root))
errors.extend(check_scheduled_alerts(root))
return errors
@@ -363,6 +451,7 @@ class SelfTests(unittest.TestCase):
mock.patch(__name__ + ".check_fuzz_targets", return_value=[]),
mock.patch(__name__ + ".check_runner_selection", return_value=[]),
mock.patch(__name__ + ".check_profile_definitions", return_value=[]),
mock.patch(__name__ + ".check_scheduled_alerts", return_value=[]),
):
self.assertEqual(len(validate(root)), 1)
@@ -413,6 +502,75 @@ class SelfTests(unittest.TestCase):
with mock.patch.object(sys, "platform", "linux"):
self.assertEqual(len(check_profile_listing(root, "e2e-full", listing)), 1)
def test_scheduled_alerts_require_completion_watchdog(self) -> None:
with tempfile.TemporaryDirectory() as tmp:
root = Path(tmp)
alert = (
" alert-on-failure:\n"
" if: always() && github.event_name == 'schedule' && "
"contains(needs.*.result, 'failure')\n"
" permissions:\n"
" issues: write\n"
" steps:\n"
" - uses: ./.github/actions/schedule-failure-issue\n"
" with:\n"
" github-token: ${{ secrets.GITHUB_TOKEN }}\n"
)
names: list[str] = []
for relative in SCHEDULED_ALERT_WORKFLOWS:
path = root / relative
path.parent.mkdir(parents=True, exist_ok=True)
names.append(path.stem)
path.write_text(f'name: "{path.stem}"\n{alert}')
watchdog = root / ".github/workflows/scheduled-validation-watchdog.yml"
watchdog_source = (
"\n".join(f'- "{name}"' for name in names)
+ "\ngithub.event.workflow_run.event == 'schedule'\n"
+ "github.event.workflow_run.conclusion != 'success'\n"
+ "github.event.workflow_run.conclusion != 'failure'\n"
+ "actions: read\n"
+ "issues: write\n"
+ "uses: ./.github/actions/schedule-failure-issue\n"
+ "github-token: ${{ secrets.GITHUB_TOKEN }}\n"
+ "workflow-name: ${{ github.event.workflow_run.name }}\n"
+ "source-event: ${{ github.event.workflow_run.event }}\n"
+ "source-ref-name: ${{ github.event.workflow_run.head_branch }}\n"
+ "source-sha: ${{ github.event.workflow_run.head_sha }}\n"
+ "source-run-id: ${{ github.event.workflow_run.id }}\n"
+ "source-run-attempt: ${{ github.event.workflow_run.run_attempt }}\n"
)
watchdog.write_text(watchdog_source)
self.assertEqual(check_scheduled_alerts(root), [])
first = root / SCHEDULED_ALERT_WORKFLOWS[0]
mutations = (
("contains(needs.*.result, 'failure')", "false"),
("issues: write", "issues: read"),
("uses: ./.github/actions/schedule-failure-issue", "uses: actions/checkout@v7"),
("github-token: ${{ secrets.GITHUB_TOKEN }}", "github-token: missing"),
)
for required, replacement in mutations:
original = first.read_text()
first.write_text(original.replace(required, replacement))
self.assertEqual(len(check_scheduled_alerts(root)), 1)
first.write_text(original)
watchdog.write_text(watchdog_source.replace(f'- "{names[0]}"\n', ""))
self.assertEqual(len(check_scheduled_alerts(root)), 1)
watchdog_mutations = (
("actions: read", "actions: none"),
("issues: write", "issues: read"),
("uses: ./.github/actions/schedule-failure-issue", "uses: actions/checkout@v7"),
("github-token: ${{ secrets.GITHUB_TOKEN }}", "github-token: missing"),
("source-event: ${{ github.event.workflow_run.event }}", "source-event: wrong"),
("source-ref-name: ${{ github.event.workflow_run.head_branch }}", "source-ref-name: wrong"),
("source-sha: ${{ github.event.workflow_run.head_sha }}", "source-sha: wrong"),
)
for required, replacement in watchdog_mutations:
watchdog.write_text(watchdog_source.replace(required, replacement))
self.assertEqual(len(check_scheduled_alerts(root)), 1)
def main() -> int:
if sys.argv[1:] == ["--self-test"]:
suite = unittest.defaultTestLoader.loadTestsFromTestCase(SelfTests)
@@ -436,7 +594,7 @@ def main() -> int:
for error in errors:
print(f"ERROR: {error}", file=sys.stderr)
return 1
print("OK: e2e modules, runner selection, fuzz matrices, profiles, and bounded diagnostics are wired")
print("OK: e2e modules, runner selection, fuzz matrices, profiles, scheduled alerts, and bounded diagnostics are wired")
return 0