Skip to content

[COST-7490] Add midnight hold mechanism for PR checks#122

Draft
bacciotti wants to merge 3 commits into
mainfrom
cost-7490-midnight-hold
Draft

[COST-7490] Add midnight hold mechanism for PR checks#122
bacciotti wants to merge 3 commits into
mainfrom
cost-7490-midnight-hold

Conversation

@bacciotti
Copy link
Copy Markdown
Contributor

@bacciotti bacciotti commented May 20, 2026

Jira Ticket

COST-7490

Summary

  • Add new Tekton task midnight-hold that acts as a gate before reserve-namespace
  • Task fetches PR labels via GitHub API and estimates IQE job duration using empirical data from historical check runs
  • If the estimated duration would overlap the UTC midnight boundary, the pipeline sleeps until 00:05 UTC before proceeding
  • While sleeping, the task pod remains alive — holding its pipeline slot for up to ~60 min in the worst case
  • Pipelines triggered well outside the midnight window pass through immediately with no delay
  • Scheduled jobs (IS_SCHEDULED_TEST_JOB=true) and non-IQE labels (ok-to-skip-smokes, run-jenkins-tests) are skipped unconditionally

Label → Estimated Duration Mapping

PR Label Estimated Duration
hot-fix-smoke-tests ~30 min
aws-smoke-tests / azure-smoke-tests / gcp-smoke-tests ~80 min
ocp-on-prem-smoke-tests ~130 min
smoke-tests ~170 min
ocp-smoke-tests ~240 min
full-run-smoke-tests ~290 min
(unrecognised) parse IQE_CJI_TIMEOUT, capped at 240 min

Pipeline Change

midnight-hold is inserted between init-pipeline-context and reserve-namespace, ensuring the hold occurs before any ephemeral namespace is allocated.

Notes

This is an interim defensive measure (see COST-7402 for the long-term fix). If the test suite is refactored to be date-resilient, this task can be decommissioned.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request expands the CI management infrastructure to support multiple scheduled jobs, including a new 'onprem' job, and updates the associated scripts, Makefile, and documentation. It also introduces a midnight-hold task to the pipeline, which estimates test duration based on PR labels and delays execution if it would overlap with the UTC midnight boundary to prevent test failures. Feedback highlights a race condition in the time calculation within the midnight-hold task and recommends a more reliable approach for parsing JSON from the GitHub API.

Comment thread tasks/midnight-hold.yaml Outdated
Comment thread tasks/midnight-hold.yaml
@bacciotti bacciotti changed the title feat(pipeline): add midnight hold mechanism for PR checks (COST-7490) [COST-7490] Add midnight hold mechanism for PR checks May 20, 2026
Copy link
Copy Markdown
Contributor Author

@bacciotti bacciotti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Race condition fix (high priority): Fixed in 5db0905 — replaced the three separate date calls with a single epoch-based calculation ($(date -u +%s) % 86400) as suggested.

JSON parsing (medium priority): Acknowledged. The current grep + cut approach is intentionally consistent with how init-pipeline-context.yaml already parses PR labels in this same repository. PR labels in project-koku/koku are controlled strings without special characters, so the fragility risk is low. Switching to jq would require changing the base image (curlimages/curlalpine + apk add jq), which adds complexity not justified for an interim defensive mechanism. Can revisit if the label parsing ever proves fragile in practice.

bacciotti and others added 2 commits May 21, 2026 10:46
Implement a new Tekton task that delays the pipeline if the estimated
IQE test duration would overlap the UTC midnight boundary, preventing
date-sensitive test failures caused by calendar day rollovers.

The task fetches PR labels via the GitHub API to estimate job duration
using empirical data from historical check runs, and sleeps until
00:05 UTC when a midnight conflict is predicted.

Co-authored-by: Cursor <cursoragent@cursor.com>
…ace condition

Co-authored-by: Cursor <cursoragent@cursor.com>
@bacciotti bacciotti force-pushed the cost-7490-midnight-hold branch from 5db0905 to 02cd7f8 Compare May 21, 2026 09:46
…stimates

Co-authored-by: Cursor <cursoragent@cursor.com>
@bacciotti bacciotti marked this pull request as draft May 21, 2026 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant