Skip to content

ABS: poll again on HTTP 502 and 503 instead of failing the request (P4DEVOPS-16690) - #277

Merged
Ramesh7 merged 2 commits into
mainfrom
P4DEVOPS-16690_abs_retry_502_503
Nov 26, 2026
Merged

Ramesh7 merged 2 commits into
mainfrom
P4DEVOPS-16690_abs_retry_502_503

Conversation

@Ramesh7

@Ramesh7 Ramesh7 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Status

Ready for review

Description

ABS.validate_queue_status_response raised for every status except 200, 202 and 401, so one 502 or 503 from ABS (or the proxy in front of it) failed the whole floaty get. run-me-maybe already treats 502 and 503 as "come back later". See P4DEVOPS-16690.

  • 502 and 503 are now handled like 202: the queue is polled again. The existing limit of 360 polls (about an hour) still bounds it.
  • Every other status, including 404, 422 and 500, still raises HTTP <code>: <request> request to ABS failed! with the response body.
  • No change to the floaty options or to the output on success.

Testing

bundle exec rspec: 147 examples, 0 failures (Ruby 3.1.4). New specs in spec/vmfloaty/abs_spec.rb: validate_queue_status_response for 200/202, 502/503 (no raise, message when verbose), 404 with body, 422 and 500, 401; check_queue returns the body for a 503 and the hosts for a 200. Three of the new specs fail without the change.

Not checked:

  • A full retrieve run against ABS. The polling loop sleeps, so I covered check_queue and the validation only.
  • A 502 or 503 on the initial request: the code now continues to the poll loop. I did not test that path.
  • Ruby 2.7, 3.0, 3.2 to 4.0 from CI. I ran 3.1.4 only.
  • Rubocop: the two files already had 65 offenses on main. This change adds Metrics warnings for validate_queue_status_response (complexity and length), and I did not clean them up.

Related Issues

  • https://perforce.atlassian.net/browse/P4DEVOPS-16690
  • puppetlabs/frankenbuilder: companion PR that retries when floaty get prints no JSON
  • puppetlabs/always-be-scheduling#1303: ABS answers permanent failures with 422 and a JSON body (not needed for this change)

Todos

  • Tests
  • Documentation (no README section covers ABS status codes)

…4DEVOPS-16690)

validate_queue_status_response raised for every status except 200, 202 and
401, so a 502 or 503 from ABS (or the proxy in front of it) failed the whole
floaty get on the first answer. run-me-maybe already treats 502 and 503 as
'come back later'. Treat them like a 202: the queue is polled again, bounded by
the existing 360 polls. Any other status, including 404, 422 and 500, still
raises with the response body.
@Ramesh7
Ramesh7 requested a review from a team as a code owner November 24, 2026 10:43
@Ramesh7
Ramesh7 requested a review from isaac-jha November 24, 2026 16:27
@isaac-jha
isaac-jha requested a balanced review from Copilot November 24, 2026 16:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

A 502/503 response with a JSON object body still causes polling to abort with NoMethodError; the response must bypass JSON parsing, with regression coverage for recovery after a JSON 503.

1 open issue
What changed in this PR

This PR updates vmfloaty’s ABS backend to treat HTTP 502 and 503 as transient responses, allowing VM requests to continue through the existing bounded polling loop.

Changes:

  • Accepts 502/503 during response validation and provides a verbose retry message.
  • Adds specs for status handling and queue responses while preserving errors for other unsuccessful statuses.
File Description
spec/​vmfloaty/​abs_spec.rb Adds validation and queue-response coverage.
lib/​vmfloaty/​abs.rb Allows 502/503 responses through validation for continued polling.

Review effort: Balanced

Comment thread lib/vmfloaty/abs.rb Resolved
@isaac-jha

Copy link
Copy Markdown
Contributor

@Ramesh7 We may want to go ahead and fix this one as well since we hit a similar issue with vanagon builds:

  • A risk across all three PRs: vmfloaty's job_id is "#{user}-#{epoch_ms}". Parallel frankenbuilder runs under the same Jenkins user can collide, and with ABS#1315 the second one now gets a permanent rejection. That isn't retried. It's rare, but a random suffix on the vmfloaty job_id would close it, the same fix vanagon-private#95 made.

…to the job_id

check_queue parsed a JSON body of a 502/503 into a Hash, and retrieve then called
strip on it and raised NoMethodError. Return the body as text for 502 and 503
before any parsing.

The job_id was user-epoch_ms. Parallel runs under one user can share a
millisecond, and ABS now rejects a different request that reuses a job_id
(always-be-scheduling#1315), which is not retried. Append 8 random hex digits.
@Ramesh7

Ramesh7 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Addressed in f36d50c.

JSON body on a 502/503 (Copilot). check_queue now returns the body as text for 502 and 503 before any JSON parsing, so retrieve never gets a Hash and strip no longer raises. Tests: JSON object, JSON array and empty body on a 503/502, and a retrieve run of 202, 503 with JSON, 502, then 200 that returns the hosts. Two checks that nothing else changed: a 202 body is still parsed, and a 404 still raises. These tests fail without the change (6 failures).

job_id collision (Isaac). The job_id is now user-<epoch ms>-<8 random hex>, as in vanagon-private#95. --continue still uses the given id unchanged. Nothing in the repo parses the job_id format. Tests cover the format, 50 ids in the same millisecond all differing, the same id on every poll of one retrieve, and --continue.

Checks. bundle exec rspec: 159 examples, 0 failures (Ruby 3.1.4). Rubocop on the two files: 71 offenses, 68 before this commit, all style warnings in code and specs I added.

Not verified. Other Ruby versions (CI matrix passed), and a live ABS. The dependabot_merge.yml run shows as failed here and on the previous commit. It is not a PR check and I did not look into it.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The review reports no active issues with the ABS retrieval resilience and job ID changes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@Ramesh7
Ramesh7 merged commit 00d3fda into main Nov 26, 2026
8 checks passed
@Ramesh7
Ramesh7 deleted the P4DEVOPS-16690_abs_retry_502_503 branch November 26, 2026 04:30
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.

3 participants