Skip to content

flyApply discards an unclassified plan entry; azApply can never prune an orphan whose type left the template #1457

Closed

Description

@lex00

Two more appliers drop work and report a result that looks complete. Found by
checking whether #1447's shape was gcp-only. It is not.

Survey

applier drops something silently? shape
awsApply no the whole template goes to CloudFormation, which reports on its own resources
azApply apply no, prune yes an owned orphan whose type is absent from the current template is never a candidate
gcpApply yes unmapped kind — #1447
flyApply yes a plan entry matching none of the six request predicates

Three of four, in three different shapes, none of them visible in the return
value.

1. flyApply — a plan entry that matches nothing is discarded

lexicons/fly/src/op/activities/fly-apply.ts:849-856:

for (const [entityName, req] of Object.entries(plan)) {
  if (isAppRequest(req)) appReqs.push(req);
  else if (isMachineRequest(req)) machineReqs.push([entityName, req]);
  else if (isVolumeRequest(req)) volumeReqs.push([entityName, req]);
  else if (isIpRequest(req)) ipReqs.push([entityName, req]);
  else if (isCertRequest(req)) certReqs.push([entityName, req]);
  else if (isSecretRequest(req)) secretReqs.push([entityName, req]);
}

No final else. Every predicate is a regex over req.endpoint
(isAppRequest is /^\/v1\/apps\/?$/, isMachineRequest is
/^\/v1\/apps\/[^/]+\/machines\/?$/, and so on). An entry whose endpoint
matches none of them lands in no bucket, is never issued, and appears in none of
the eleven arrays flyApply returns.

This is worse than #1447's version, which at least prints skip: to stdout.
Here there is no output at all — the entity is simply absent from a result that
otherwise reads as a full apply.

The trigger is a serializer/applier version skew: the #738 serializer emits a
request shape the applier's predicates do not recognise. That is exactly what
happens when a new Fly resource type is added to the lexicon and only the
serializer half lands.

Fix: an else that records the entry. Either fail the activity naming the
unrecognised endpoint, or carry it as a not-attempted entry in the result. Given
the whole point of the plan is that the serializer produced it, failing loudly is
defensible — an entry the applier cannot classify is a bug in one half or the
other, not a resource the user chose to skip.

2. azApply — an orphan whose type left the template can never be pruned

lexicons/azure/src/op/activities/az-apply.ts:416-428:

const byType = new Map<string, { keep: Set<string>; apiVersion: string }>();
for (const r of desired) {                 // desired == the CURRENT template
  ...
  byType.set(r.type, entry);
}

for (const item of await listGroupResources(ctx, http, signal)) {
  const entry = byType.get(item.type);
  if (!entry || !isChantOwned(item.tags) || entry.keep.has(item.name)) continue;
  ...
}

byType is keyed off the resources the template currently declares. The
!entry guard therefore skips any live resource of a type the template no longer
mentions at all — including a chant-owned one.

Concretely: declare one Microsoft.Storage/storageAccounts, apply, then delete
it from source. The template now contains zero resources of that type, so
byType has no entry for it, so the live storage account is skipped by the
!entry guard before isChantOwned is ever consulted. It is owned, it is
undeclared, and prune will never touch it — on this run or any future one.

Prune the last resource of a type and you have created a permanent orphan.
Prune one of several and it works correctly, which is why this survives testing.

There is a real constraint behind the guard: deleteArmResource needs an
apiVersion, and the only source of one today is a template resource of that
type. So this cannot be fixed by deleting the guard. Options:

  • Take apiVersion from the live listGroupResources item where ARM returns one.
  • Keep a per-type apiVersion map in the lexicon rather than deriving it from the
    template.
  • Keep the guard, and report the skip: notPrunable: [{ type, reason: "no-api-version" }]. Least work, and it converts a permanent silent orphan
    into a visible one.

The third is the minimum. Doing nothing is not, because the guarantee in
guide/ops.mdx is that prune deletes owned orphans, and this one silently
cannot.

Note this compounds with #1448: the arm path most people reach through
ApplyOp doesn't use pruneArmOrphans at all — it shells out to --mode Complete, which has the opposite failure (deletes too much, including foreign
resources). So Azure currently has one prune that deletes more than it should and
one that deletes less, and ApplyOp uses the first.

Why these are filed together

Same root cause, three symptoms: no applier is required to account for every
resource it was handed. #1446 proposes the seam that makes it structural —
assertion 3 of the conformance suite ("every resource in the input plan appears
in exactly one of applied / pruned / not-attempted") fails for gcp and fly today,
and its prune assertion is what catches the azure one.

Each of the three is independently fixable and none of them needs #1446 to land
first.

Related

Activity

  1. added
    bug
    on Aug 3, 2026
  2. added a commit that references this issue on Aug 3, 2026
  3. lex00 commented on Aug 4, 2026

    @lex00
    ContributorAuthor

    Follow-up filed as #1472 for the half this issue left open.

    #1457 turned the azure case from a silent skip into a reported one (notPrunable, reason: "no-api-version") — a permanent invisible orphan became a permanent visible one. It is still not deleted, because deleteArmResource needs an apiVersion and ARM's resource-group listing returns none (ArmListItem is id/name/type/tags).

    #1472 covers actually deleting it, and leans toward the ARM provider metadata endpoint (resourceTypes[].apiVersions[]) over a hand-maintained per-type map — with a check first on whether floci-az implements it, since that decides whether the acceptance can run on the emulator or needs real Azure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions