Skip to content

(MAINT) Add optional per-job machine_type to provision_service task - #301

Merged
LukasAud merged 1 commit into
mainfrom
per-job-machine-type
Oct 23, 2026
Merged

LukasAud merged 1 commit into
mainfrom
per-job-machine-type

Conversation

@lynsaywright

@lynsaywright lynsaywright commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds an optional machine_type to the provision::provision_service task so a job can request a specific VM size, instead of every consumer getting the service's single default.

  • New task parameter machine_type (Optional[String[1]]), with a PROVISION_MACHINE_TYPE environment variable fallback. The parameter wins, matching how CLOUD/REGION/ZONE are handled. A blank value counts as unset.
  • It is sent as machine_type on each entry in VMs, and omitted when unset, so the request body is byte-for-byte unchanged for existing callers.
  • Works for String, Array and Hash platform values.

Why

The PE 2026.0.0 jobs in puppetlabs-peadm (PR #718) fail with Cannot allocate memory - fork(2) on the service's default n1-standard-2 test VMs. Raising the default would raise cost for every consumer of the service, so we want to size only the jobs that need it.

Depends on provision_service, and merge order matters

This only changes what the task sends. puppetlabs/provision_service#445 must be deployed to production first: the service reads only cloud, images, region and zone per VM today, so an older service silently ignores machine_type and the job still gets n1-standard-2 with no error.

Rollout: deploy provision_service#445 (merge to main, check the puppetlabs-motd nightly against it, then push main to release, per docs/production.md) -> merge this and cut a new provision tag -> bump the provision ref in the consuming repo's .fixtures.yml (peadm pins v3.0.1) -> set PROVISION_MACHINE_TYPE only on the jobs that need it.

Impact on other consumers

Nothing changes unless a caller sets machine_type or PROVISION_MACHINE_TYPE. About 97 repos track this repo's default branch in .fixtures.yml and will pick the code up on their next run; two are pinned (peadm at v3.0.1, puppetlabs-servicenow_cmdb_integration at a SHA). I found no workflow or provision.yaml in puppetlabs that sets machine_type, and the variable is namespaced (PROVISION_MACHINE_TYPE) so an unrelated MACHINE_TYPE in someone's CI is ignored (GitHub code search only covers repos visible to my account).

Things to decide in review

  • For a Hash platform, the parameter or variable overwrites a machine_type already in the Hash. The Hash was already mutated in place for cloud.
  • The facade currently reports some service rejections of machine_type as a 5xx, which this task retries with backoff for a few minutes before failing (see provision_service#445).

Testing

  • 8 new specs: machine_type omitted by default and when blank, added for String/Array/Hash platforms, sent in the request body, PROVISION_MACHINE_TYPE fallback, parameter-over-environment precedence, a plain MACHINE_TYPE being ignored, blank values ignored, and passthrough from .run. The existing .run spec is updated for the new argument. The specs restore PROVISION_MACHINE_TYPE after each example.

With Litmus, which cannot pass extra task parameters, set provision_machine_type under params in provision.yaml (for litmus:provision_list) or PROVISION_MACHINE_TYPE in the job's environment.

  • RuboCop (the repo's pinned versions) reports no offenses.
  • Run locally on Ruby 3.1.7 with a stub spec helper, because this machine has no Ruby >= 3.2 for the Gemfile. All new examples pass. Two #provision examples (when response is empty, when successive retry success) fail identically on unmodified main here, which looks like an environment artifact; CI is the real check.

🤖 Generated with Claude Code

@codecov-commenter

codecov-commenter commented Oct 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.37%. Comparing base (f03a11c) to head (b5020c9).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #301      +/-   ##
==========================================
+ Coverage   91.31%   91.37%   +0.06%     
==========================================
  Files           7        7              
  Lines         518      522       +4     
==========================================
+ Hits          473      477       +4     
  Misses         45       45              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lynsaywright
lynsaywright marked this pull request as ready for review October 22, 2026 14:48
@lynsaywright
lynsaywright requested a review from a team as a code owner October 22, 2026 14:48
@lynsaywright
lynsaywright requested a balanced review from Copilot October 22, 2026 14:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new spec cleanup does not restore an initially absent MACHINE_TYPE, leaving environment state behind after tests.

1 open issue
What changed in this PR

Adds per-job VM sizing to the Provision Service task without changing requests when no machine type is configured. Effective resizing depends on service-side support.

Changes:

  • Adds an optional machine_type parameter with a MACHINE_TYPE environment fallback.
  • Includes the requested size for String, Array, and Hash platforms.
  • Adds request and precedence specs, plus usage documentation.
File Description
tasks/​provision_service.rb Passes machine type through task execution into VM requests.
tasks/​provision_service.json Declares the optional machine type parameter.
spec/​tasks/​provision_service_spec.rb Tests omission, platform formats, fallback, precedence, and passthrough.
README.md Documents configuration and the service-support dependency.

Review effort: Balanced

Comment thread spec/tasks/provision_service_spec.rb Outdated
saved = ENV.delete('MACHINE_TYPE')
example.run
ensure
ENV['MACHINE_TYPE'] = saved if saved
Let callers ask the provision service for a specific VM machine type per
job, so a job that needs a bigger VM does not force a larger default on
every consumer of the service.

- New machine_type task parameter, with a PROVISION_MACHINE_TYPE
  environment variable fallback (the parameter wins). The variable is
  namespaced so an unrelated MACHINE_TYPE set for other tooling is ignored.
  With Litmus it can be set through provision.yaml params.
- It is sent as machine_type on each VM in the request and omitted when
  unset or blank, so the request body is unchanged for existing callers.
- Works for String, Array and Hash platform values.

The service must also accept the field before it has any effect; a service
that does not ignores it silently.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@LukasAud LukasAud left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@LukasAud
LukasAud merged commit 51ceddc into main Oct 23, 2026
5 checks passed
@LukasAud
LukasAud deleted the per-job-machine-type branch October 23, 2026 14:44
CharithaDunuwille added a commit to puppetlabs/puppetlabs-peadm that referenced this pull request Oct 23, 2026
provision v3.1.0 (puppetlabs/provision#302, "Release prep v3.1.0",
merged by Lukas Audzevicius) promotes puppetlabs/provision#301
(per-job machine_type support) and the earlier HTTP-5xx retry fix
(#298) into a real tagged release. Pin .fixtures.yml to that tag
instead of the interim commit SHA.

Add PROVISION_MACHINE_TYPE: n2-standard-4 to the 6 workflows that
exercise PE 2026.0.0 installs, where CI's default provisioned VM size
(n1-standard-2, 2 vCPU/7.3 GB) has been hitting
"Cannot allocate memory - fork(2)" during catalog apply: test-install-
matrix.yaml, test-add-replica-matrix.yaml,
test-replace-failed-postgresql.yaml, test-migration.yaml,
test-fips-install-matrix.yaml, test-install-rhel-9.yaml. The env var
is read directly by provision_service.rb as a fallback when the task's
machine_type param isn't set, and is only sent when non-empty, so this
doesn't change behavior for other callers.

Verified locally: `rake spec_prep` resolves the provision fixture to
v3.1.0 exactly, YAML parses cleanly on all 6 modified workflows.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
CharithaDunuwille added a commit to puppetlabs/puppetlabs-peadm that referenced this pull request Nov 3, 2026
* (PE-45865)(PE-45866)(PE-45867) Adding support for PE 2023.8.12, 2025.12.0, and 2026.0.0

Bump the default install version and CI test matrices for the LTS patch
(2023.8.12) and STS minor (2025.12.0) releases, and add PE 2026.0.0 as a
new supported major line for the first time.

- functions/assert_supported_pe_version.pp: raise $newest from 2025.11 to
  2026.0, since 2026.0.0 is now the newest supported version.
- plans/install.pp, REFERENCE.md, spec/plans/subplans/install_spec.rb:
  default install version bumped to 2023.8.12 (LTS).
- CI workflows: literal version bumps across 19 workflow files, plus
  2026.0.0 added as a new matrix entry wherever multiple versions are
  tested. test-upgrade-matrix.yaml's include/exclude grid was rebuilt to
  keep testing only adjacent one-step upgrades (2021.7.9->2023.8.12,
  2023.8.12->2025.12.0, 2025.12.0->2026.0.0). test-migration.yaml's
  include block now upgrades to 2026.0.0 (the new newest) instead of
  2025.12.0, and its extra-large-with-dr exclude list now also covers
  2026.0.0, matching the pattern used in every prior version-bump PR.

Jira: PE-45865, PE-45866, PE-45867

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Track PE 2026.0.0 as newest in the remaining hardcoded version fields

test-backup-restore.yaml's workflow_dispatch default, test-legacy-compilers.yaml's
install version, and test-legacy-upgrade.yaml's upgrade target have historically
always tracked whichever PE version was newest (confirmed via every prior
version-bump commit back to 2025.8.0). Move them from 2025.12.0 to 2026.0.0
to keep that pattern now that 2026.0.0 is newest.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Move the LTS-default role from 2023.8.x to 2025.12.0

2025.12.0 is the new LTS line. Every CI default/install-target that
tracks "the LTS" (confirmed via git history -- these fields have moved
in lockstep with the LTS version on every prior bump commit) now points
at 2025.12.0 instead of 2023.8.12:

- plans/install.pp's default $version (+ REFERENCE.md, install_spec.rb)
- test-add-replica.yaml / test-add-compiler.yaml / test-install.yaml /
  test-failover.yaml's workflow_dispatch defaults
- test-upgrade.yaml's upgrade_version default
- test-upgrade-latest-dev.yaml / test-upgrade-latest-xlarge-dev-nightly.yaml's
  "upgrade from X to latest dev build" starting version
- test-legacy-upgrade.yaml's initial install version (its separate
  upgrade-target field already tracks newest/2026.0.0, untouched here)
- test-migration.yaml's include: block (migrate-then-upgrade-to-newest
  scenario now starts from the new LTS)

Deliberately left unchanged, with reasoning:
- Matrix-array membership (test-*-matrix.yaml, test-migration.yaml's
  base array, test-upgrade-matrix.yaml) -- 2023.8.x is still a
  supported, tested version, just no longer LTS-designated. Only
  single-value "default"/"target" fields move, not matrix membership.
- test-upgrade-pg-major-ha-nightly.yaml -- deliberately anchored to "a
  release that defaults to PostgreSQL 14" for its PG14->PG17 migration
  regression guard (PE-44245). Whether 2025.12.0 also defaults to PG14
  is unconfirmed; swapping this without that confirmation risks
  silently breaking the regression test it exists to guard, so it's
  left on 2023.8.12 pending product-team confirmation.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Drop PE 2021.7.x from CI test matrices

Per PE-47023, we agreed to stop testing PE 2021 as part of the PEADM
release test matrix: 2021.7.x is well past EOL and carrying it adds
CI/release overhead without enough value to justify it.

Removes 2021.7.9/2021.7.4 from all install/upgrade/migration/failover
CI matrices and manual-dispatch defaults, and trims the now-dead
exclude entries in test-upgrade-matrix.yaml so it only covers
adjacent one-step upgrades (2023.8.12->2025.12.0->2026.0.0).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Fix two remaining stale 2025.11.3 fallbacks in test-backup-restore.yaml

The prior commit ("Track PE 2026.0.0 as newest in the remaining
hardcoded version fields") updated this file's workflow_dispatch
default and job-name fallback to 2026.0.0, but missed two embedded
`|| '2025.11.3'` fallbacks used by the install and reinstall steps.
These are the versions actually used on the `pull_request:
types: [ready_for_review]` trigger, which has no workflow_dispatch
inputs to fall back from -- so until now this file would still
provision/reinstall PE 2025.11.3 on the PR-triggered path regardless
of the version bump above.

These two lines were themselves only just updated from a stale
2023.5.0 to 2025.11.3 by PE-47024 (#723), merged after this PR
branched -- this commit keeps them in step with the same "track
newest" pattern the previous commit already established for this
file's other fields.

* Split provision_replica provision/enable so add_replica can wait for readiness

PE core's atomic `puppet infrastructure provision replica ... --enable`
runs its own replica service-health check with a short, fixed ~21s
wait after reinitializing the replica's Classifier/RBAC/PuppetDB.
Confirmed deterministic in CI (not occasional): a broadened-retry
attempt failed identically on 6/6 full re-provision attempts across
2 PE versions, each hitting the same ~21s-after-check failure, proving
retrying the atomic call doesn't help.

Split tasks/provision_replica.sh's non-legacy path into separate
provision/enable actions, and have plans/add_replica.pp poll
peadm::wait_until_service_ready('pe-master', $replica_target) (up to
60s) in between -- giving peadm its own readiness check instead of
depending on PE core's internal one. Verified working live on both
previously-failing jobs (PE 2023.8.12 and 2025.12.0, extra-large,
test-add-replica.yaml) on a scratch branch before bringing this in.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Fix add_replica_spec for split provision/enable task calls

Splitting provision_replica into separate provision/enable actions
(previous commit) broke one existing spec: 'retries provision_replica
once and succeeds after a transient orchestrator connection-closed
error' expected exactly 2 calls to the task, but the plan now also
makes a 3rd call (the enable step) after a successful provision.

Update the mock to distinguish calls by the action parameter, so only
the provision calls are counted toward the retry assertion, and the
enable call (not under test here) always succeeds.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Regenerate REFERENCE.md for provision_replica's new action parameter

bundle exec rake strings:generate:reference, to document the action
parameter added to tasks/provision_replica.json.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Fix provision_replica's action parameter type for Puppet 9 compatibility

The "Experimental: Puppet 9 / Ruby 4.0" spec job failed with a Puppet
PAL error ("missing keyword: :action") at the add_replica.pp call site,
even though action is always passed explicitly there. The action
parameter was typed Optional[Enum[...]] with a default -- unlike the
pre-existing, unmodified legacy parameter in this same task, which
uses a plain (non-Optional) Boolean with a default and works fine.
Switch action to a plain Enum[provision, enable, both] with a default,
matching that known-working pattern, rather than Optional[Enum[...]].

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Fix add_replica_spec's provision_replica mock to read params correctly

The previous fix mocked peadm::provision_replica with a block signature
of |targets:, action:, **_kwargs|, but bolt_spec's TaskStub always
invokes return blocks with exactly targets:, task:, and params: (task
arguments nested under params:, not splatted as individual top-level
keywords). That mismatch raised "missing keyword: :action" from PAL
during the task call itself, failing the Puppet 8 spec job. Read
action out of the params hash instead.

Also reverts the unrelated, ineffective tasks/provision_replica.json
schema tweak from the previous commit (Optional[Enum[...]] back to
Enum[...] was not the actual cause) and the REFERENCE.md regeneration
that went with it, to keep the diff focused on the real fix. Verified
locally: all 8 examples in spec/plans/add_replica_spec.rb pass.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Use 4-core runners for CI jobs hitting resource exhaustion on PE 2026.0.0

PE 2026.0.0 catalog applies in these jobs intermittently fail with
"Cannot allocate memory - fork(2)" and downstream symptoms (nil OS
facts, admin account lockout counters tripping during restore, CA/CRL
generation timeouts during migration) traced to CI resource
exhaustion. Bump these specific jobs to ubuntu-latest-4-cores; other
workflows are left on ubuntu-latest since their failures have
unrelated root causes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Use 4-core runners for two more jobs hitting resource exhaustion on PE 2026.0.0

The provision-service HTTP 500 that previously masked failures in
these jobs has its own fix verified on a separate branch. Once that
transient provisioning error is out of the way, these jobs hit the
same "Cannot allocate memory - fork(2)" resource exhaustion already
seen and fixed for the other PE 2026.0.0 jobs. Bump to
ubuntu-latest-4-cores to match.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Pin provision fixture past v3.0.1 to pick up provision_service retry fix

provision_service.rb's invoke_cloud_request called exit 1 on a non-200
response from the provisioning backend. SystemExit isn't a
StandardError, so the task's own retry loop (rescue StandardError)
never caught it -- a single transient HTTP 500 from the cloud
provisioning backend failed the whole job immediately, with zero
retries ever attempted despite a retry_attempts=5 parameter.

Upstream commit 781cb01 (MODULES-11965) fixes this by raising a real
ServiceError/ServerError instead of exiting, so the retry loop (now
with backoff+jitter, 4 attempts) actually runs for 5xx responses.
There's no tagged release past v3.0.1 containing this fix yet, so pin
directly to the commit. Verified the task's parameter schema
(tasks/provision_service.json) is byte-identical between v3.0.1 and
this commit, so there's no interface change for peadm's usage.
Verified locally that `rake spec_prep` resolves the fixture to this
exact commit.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Retry the compiler's first puppet agent run on a transient 503

A new compiler's first puppet_runonce in component_install.pp downloads
the pe_repo package set from the primary. If the primary's puppetserver
restarts mid-download, that run fails with "Error 503 on SERVER:
Attempted to borrow a JRubyInstance from the pool during a shutdown",
and nothing currently retries it. Confirmed live: an unmodified run
against a normal primary never hit this, but forcing a primary
pe-puppetserver restart during the compiler's pe_repo fetch reproduced
the exact error.

Retry a bounded number of times (3 attempts, 30s apart) only when the
failure looks like a 503 or a connection error; any other failure (a
genuine catalog/resource error) surfaces on the first attempt, same
retry-vs-fail-fast pattern already used for provision_replica in
add_replica.pp and rbac_token elsewhere.

Added spec/plans/subplans/component_install_spec.rb covering a clean
run, retry-then-succeed, retries-exhausted, and non-transient-not-
retried. Verified locally: all pass, and the existing add_compilers
spec (which stubs out component_install entirely) is unaffected.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Revert "Pin provision fixture past v3.0.1 to pick up provision_service retry fix"

This reverts commit 777d0e9.

* Restore pe-ca database before the certs scope on a database-backed CA (PE-47558)

puppet-backup --scope=certs only saves the on-disk CA files (ssl/,
puppetserver/ca/, the key passphrase), not the pe-ca database. On a
database-backed CA (PE 2026.0+), restoring those files onto a new
primary leaves the old cluster's CA files sitting next to the new
cluster's own pe-ca database -- two different CAs. The certs-scope
restore ends with a configure run that needs both to agree, so it
fails with "The CRL issued by ... is missing", followed by
certificate-unknown errors. Reproduced live on PE 2026.0.0, standard
topology: before the fix, ca.pem (old CA) and the CA served by the
database didn't match; after, they do and `puppet agent -t` is clean.
Not an enable_infra_crl problem -- that warning is inert on a database
CA.

peadm::backup now dumps pe-ca itself (pg_dump, alongside the other
databases) whenever the CA is database-backed and the config scope
isn't already covering it (config's dump already includes pe-ca).
peadm::restore restores that dump before the certs-scope restore,
only when the backup actually has it and the target primary is
database-backed; filesystem-CA migrations are unaffected.

Also updates spec/plans/restore_spec.rb: two existing tests (the
migration puppetdb-export/import ordering test, and the isolated
ca/code/config restore test) exercise recovery_opts combinations where
the new pre-restore check now runs a real run_command; both needed a
mock for that command (returning 'skip', since neither fixture has a
pe-ca dump) to keep testing what they were written to test rather than
tripping over the new call.

Verified locally: full backup/restore/restore_ca/backup_ca spec suite
(25 examples) passes, rubocop/lint/syntax clean.

Caveats (carried over from the original workaround, not yet verified
myself): only tested live on standard topology, no upgrade_version;
large/DR/XL and upgrade-during-migration are untested. The proper fix
belongs in pe-backup-tools (certs scope should include pe-ca on a
database CA) -- this is a peadm-side workaround.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Reapply "Pin provision fixture past v3.0.1 to pick up provision_service retry fix"

This reverts commit a7056b8.

* Revert "Use 4-core runners for two more jobs hitting resource exhaustion on PE 2026.0.0"

This reverts commit 82c38f1.

* Revert "Use 4-core runners for CI jobs hitting resource exhaustion on PE 2026.0.0"

This reverts commit 270451a.

* Use PEADM_4c_ubuntu_runner for CI jobs hitting resource exhaustion on PE 2026.0.0

ubuntu-latest-4-cores (reverted in b5494cb/84905a5) was never
provisioned for this repo -- jobs requesting it sat in queued
indefinitely with no runner ever assigned. PEADM_4c_ubuntu_runner is a
real, confirmed-working self-hosted runner (Ubuntu 24.04, 4 cores,
~15 GiB RAM + swap) now available to this repo.

Note this only changes the orchestrating GitHub Actions runner, not
the separately-provisioned VM where PE actually installs (still a
fixed n1-standard-2, 2 vCPU/7.3 GB, unaffected by this). The real fix
for the "Cannot allocate memory - fork(2)" OOM during PE 2026.0.0
catalog applies still depends on provision_service adding per-job
machine-type support (tracked in PE-47658); this change only ensures
these jobs can actually be scheduled and run.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Revert "Use PEADM_4c_ubuntu_runner for CI jobs hitting resource exhaustion on PE 2026.0.0"

This reverts commit f43a329.

* Consume provision v3.1.0 and request a bigger VM for PE 2026.0.0 CI jobs

provision v3.1.0 (puppetlabs/provision#302, "Release prep v3.1.0",
merged by Lukas Audzevicius) promotes puppetlabs/provision#301
(per-job machine_type support) and the earlier HTTP-5xx retry fix
(#298) into a real tagged release. Pin .fixtures.yml to that tag
instead of the interim commit SHA.

Add PROVISION_MACHINE_TYPE: n2-standard-4 to the 6 workflows that
exercise PE 2026.0.0 installs, where CI's default provisioned VM size
(n1-standard-2, 2 vCPU/7.3 GB) has been hitting
"Cannot allocate memory - fork(2)" during catalog apply: test-install-
matrix.yaml, test-add-replica-matrix.yaml,
test-replace-failed-postgresql.yaml, test-migration.yaml,
test-fips-install-matrix.yaml, test-install-rhel-9.yaml. The env var
is read directly by provision_service.rb as a fallback when the task's
machine_type param isn't set, and is only sent when non-empty, so this
doesn't change behavior for other callers.

Verified locally: `rake spec_prep` resolves the provision fixture to
v3.1.0 exactly, YAML parses cleanly on all 6 modified workflows.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Scope PROVISION_MACHINE_TYPE to only 2026.0.0 matrix combinations

The previous commit set PROVISION_MACHINE_TYPE: n2-standard-4 on the
job's top-level env, which applies to every version in the matrix, not
just 2026.0.0 -- so PE 2023.8.12 and 2025.12.0 jobs that never had an
OOM problem started requesting n2-standard-4 too. Combined with
n2-standard-4 apparently causing the provisioning backend to hang
(reported separately to the provision team), this took the failure
count on PR #718 from 6 to 30, including many previously-passing
versions.

Scope the env var with a matrix-conditional expression instead: empty
string for every combination except where 2026.0.0 is actually being
installed (or, for test-migration.yaml, upgraded to). An empty value
leaves the task's own default untouched (see provision_service.rb:
"Only sent when requested").

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Extend PROVISION_MACHINE_TYPE to the remaining PE 2026.0.0 workflows

6 more workflows install or upgrade to PE 2026.0.0 and were missed by
the earlier rollout: test-legacy-upgrade.yaml and
test-legacy-compilers.yaml always target 2026.0.0 directly (confirmed
failing with the same "Cannot allocate memory - fork(2)" OOM on PR
#718); test-add-compiler-matrix.yml and test-upgrade-matrix.yaml have
it as one matrix combination among several; test-backup-restore.yaml
defaults to it via a workflow_dispatch input;
test-install-latest-xlarge-dev-nightly.yaml always installs the
current main dev build (now past 2026.0.0) and is confirmed failing
with the identical OOM signature on its daily cron run, independent of
PR #718.

Same pattern as the first 6 workflows: request n2-standard-4 via
provision#301 (provision >= v3.1.0), either unconditionally where the
workflow always targets 2026.0.0+, or via a matrix/input-conditional
expression (empty string otherwise, which the task treats as not set)
where only some combinations do.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Extend PROVISION_MACHINE_TYPE to 3 failing FIPS/DR combinations

PE 2023.8.12 extra-large-with-dr, PE 2025.12.0 standard-with-dr, and
PE 2025.12.0 extra-large-with-dr (fips enable) were failing with
connection-level errors (SSH IOError / orchestrator SSL drop, or
"certificate revoked" mid-purge) during long pg_basebackup-heavy
replica provisioning. Requesting a bigger VM (n2-standard-4, same
mechanism already used for the PE 2026.0.0 OOM fix) resolved all 3
when tested on a separate scratch branch.

Evidence this addresses the root cause (vs. masking it) is supportive
but not conclusive -- one passing run per combo. Tracked in PE-47827.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Retry add_replica's provision step on connection-refused orchestrator errors (PE-47833)

PE 2023.8.12 large-with-dr failed with "Connection refused"/"Failed
to open TCP connection" on port 8143 during add_replica.pp's
provision_replica call -- the orchestration service on the new
replica hasn't started listening yet when provision_replica's
internal CLI tries to reach it. Same underlying race as the already-
handled ConnectionClosedException/orchestrator-unknown-error case,
just a different error signature.

Extends the existing bounded retry (both the provision and enable
call sites) to also match this signature. Any other failure (bad
token, genuine provisioning error) is still not retried and surfaces
on the first attempt.

Verified: PE 2023.8.12 large-with-dr -- the combo that originally
failed -- passed with this change (run 40356661031, job
121690848866). spec/plans/add_replica_spec.rb (8 examples) passes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Reactively regenerate the primary's own cert if sign_csr hits "certificate revoked"

peadm::migrate's purge can revoke the primary's own certificate as a
side effect (its serial can coincidentally collide with a purged
node's serial). sign_csr's internal `puppetserver ca sign` does a
local HTTPS self-check against the primary's own puppetserver before
signing, so once the primary's cert is revoked, every subsequent
sign_csr call fails with "certificate verify failed (certificate
revoked)", regardless of whose cert is being signed -- confirmed via
a --log-level trace rerun of PE 2025.12.0 standard-with-dr (run
40404980601, job 121860298309).

Detects that specific error (matching both the lowercase "certificate
revoked" phrasing and the capitalized "Certificate '...' is revoked"
phrasing seen in a related variant) and regenerates the primary's
cert via the same disk-level stop/rm/generate/start sequence already
used for the primary's own cert-regeneration case below, which never
touches the broken HTTPS endpoint, then retries sign_csr once.

Verified: PE 2026.0.0 extra-large passed cleanly with this fix (run
40478287152, job 122101877026). PE 2025.12.0 extra-large->2026.0.0
and PE 2025.12.0 standard-with-dr both had this exact fix trigger and
succeed (cert regenerated, sign_csr retried successfully), though
those two jobs went on to fail later for separate, unrelated reasons
(PE-47829 disk-space bug; a service-readiness gap not yet fixed here).
spec/plans/subplans/modify_certificate_spec.rb (4 examples) passes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Wait for services to be ready after cert regen and restore

Three independent gaps in the same "services not running" symptom
family, all tested in isolation on scratch branches:

- modify_certificate.pp's reactive cert regen (added in 24f4e0b)
  restarts pe-puppetserver but didn't wait for it and its dependent
  services to actually come back up before retrying sign_csr, so a
  caller proceeding immediately afterward (e.g. add_replica's
  provision_replica) could hit every PE service reporting "not
  running".

- migrate.pp's purge loop had no handling at all for the same
  cert-revocation bug: purging a node revokes its cert by serial
  number, and the new primary's own cert can coincidentally share a
  serial with a purged node, breaking the new primary's own
  PuppetDB/orchestrator connections mid-loop. Added the same
  detect/regenerate/retry handling used in modify_certificate.pp.

- restore.pp had zero service-readiness wait after its final
  puppet_runonce, independent of the cert bug -- confirmed live via a
  rerun that hit the same "not running" failure with no cert
  revocation involved (run 40478287152, job 122173825349, PE
  2025.12.0 large-with-dr).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Reactively regenerate the primary's cert if prepare_agent's sign_csr hits "certificate revoked"

4th call site for the same cert-revocation bug family already handled
in peadm::subplans::modify_certificate and peadm::migrate's purge
loop: plans/subplans/prepare_agent.pp calls sign_csr with no error
handling at all when provisioning a new agent/replica. Observed
failing twice in a row on PE 2026.0.0 standard-with-dr with "certificate
verify failed (certificate revoked)" after 6 internal signing retries.

Same detect/regenerate/retry pattern as the other 3 call sites: catch
the failure, confirm it's the revocation signature, regenerate the
primary's own cert via the disk-level stop/rm/generate/start sequence
(bypasses the broken HTTPS path), wait for services, retry once.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Fix spec: avoid regex expect_command (unsupported) and unused arg

expect_command only matches exact command strings in this BoltSpec
version -- a regex silently never matches, so the "rm -f"/"ca generate"
heredoc commands need allow_any_command instead (their exact text
isn't this test's concern). Also drops an unused certdata parameter
flagged by RuboCop, and builds failed Bolt::Result values directly
(_error/_output) since BoltSpec's error_with() helper doesn't populate
_output, which peadm::subplans::prepare_agent reads for its
revoked-vs-not-revoked branch.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Fix spec: task stub return blocks must return a Bolt::ResultSet, not a bare Result

TaskStub#call always wraps the return block's result through
check_resultset, so returning a single Bolt::Result (rather than
Bolt::ResultSet.new([result])) raised "did not return a Bolt::ResultSet"
and masked the real assertions.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Fix spec: use allow_task instead of expect_task for cert_data in the regen test

expect_task's default (no be_called_times) is "at least once", which
should have been satisfied by 2 calls -- but intermittently reported
"Expected ... to be called 1 times" in CI, suggesting stub-state
interaction with the other two examples' explicit be_called_times(1)
on the same task name. cert_data's call count isn't this test's actual
assertion (the sign_csr retry count and regen sequence are), so
allow_task sidesteps the ambiguity entirely.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Also detect/regenerate on submit_csr, not just sign_csr

Confirmed via live testing: after the sign_csr regen fix landed, a new
failure surfaced -- "No certificate request found" on the retried
sign_csr. Root cause: submit_csr (which runs on the agent, connecting
to the primary) hits the exact same revoked-primary-cert problem, but
its failure was silently swallowed by the pre-existing _catch_errors,
so no CSR ever got submitted for sign_csr to retry against.

Same detect/regenerate/retry pattern as sign_csr, applied to submit_csr
first. A non-revocation submit_csr failure still fails silently,
preserving the pre-existing "ignoring errors to simplify logic"
behavior for whatever else it was tolerating.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Request a bigger boot disk for PE 2026.0.0 migration jobs (PE-47829)

provision_service now supports a per-job disk_size_gb override
(provision#303, released as provision v3.2.0). Bump the .fixtures.yml
pin and request 100G for standard/large/extra-large -> 2026.0.0
combos, which were confirmed failing with "No space left on device"
while extracting the PE 2026.0.0 tarball on the default 10G boot disk.
Scoped the same way as the existing PROVISION_MACHINE_TYPE override.

Validated in #740.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Fix yamlfix comment-spacing nit in the new PROVISION_DISK_SIZE_GB comment

CI's Format yaml files job can't auto-commit fixes to workflow files
(GitHub Apps can't push workflow changes without the workflows
permission scope), so apply yamlfix's expected formatting here
directly instead of letting that job fail.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Request bigger VM for PE 2025.12.0 jobs in Install test rhel-9

Jobs 124151599458 (standard-with-dr) and 124151687083
(extra-large-with-dr) both show the primary's puppetserver/orchestrator
becoming unresponsive mid-run during provision_replica's enable-replica
step, after an abnormally long-running operation -- the same category
of suspected memory-pressure symptom already handled for PE 2026.0.0 by
requesting a bigger provision_service VM (provision#301). Extend the
same request to PE 2025.12.0, all architectures.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* (PE-45867) Re-import filesystem CA into CA database after migration restore

Scratch fix for migration *-with-dr failures on PR #718: the certs-scope
restore re-issues the primary cert via the filesystem CA without
updating pe-ca, so the next DB-issued cert reuses its serial.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* (PE-45867) Export CA database to disk before certs backup

With a database-backed CA the on-disk CA keeps the install-time serial
counter, so restoring a certs-scope backup re-issues the new primary's
certificate with a serial the old CA already issued or revoked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* (PE-45867) Drop pglogical from restored pe-ca database

A pe-ca dump from a cluster with a replica carries pglogical objects;
the CA migration service then fails to initialise the database on the
new primary, so the post-restore CA import returns 500.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* (PE-45867) Stop agent before pe-puppetserver; use delta CA import

Stop puppet.service before stopping pe-puppetserver for the pe-ca
restore (a background agent run cancels the stop job), and use the
default delta sync for the post-restore CA import (as in Amit's fix).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* (PE-45867) Remove "regenerate primary cert on revoked" workarounds

With the CA fixed at backup/restore time the new primary's certificate
is never revoked, so these blocks no longer trigger. As written they also
broke the cluster: they regenerate the primary cert via the filesystem CA
(colliding again with the database serial counter) and restart only
pe-puppetserver, leaving every other service on the revoked copy.

Restores migrate.pp, subplans/modify_certificate.pp and
subplans/prepare_agent.pp to main, and drops the spec examples that
covered the workaround.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* (PE-45867) Add specs for the with-dr migration CA fixes

Cover the CA fixes for -with-dr migrations so they can't regress:
- peadm::backup exports a database-backed CA to disk before backing up
  the certs scope, and doesn't for a filesystem-backed CA.
- peadm::restore stops the agent before pe-puppetserver, drops pglogical
  from the restored pe-ca database, and re-imports the filesystem CA into
  the database after the certs restore.

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: rebase-draft <ci@local>
Co-authored-by: mehul-jain1 <mehuljain160@gmail.com>
Co-authored-by: Amit Karsale <amit.karsale@perforce.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants