Skip to content

Zip only the summary and this call's report folders with -PackageZip - #67

Merged
stefoy merged 54 commits into
awslabs:mainfrom
pmorgenrood:upstream-pr/summary-package-zip
Nov 25, 2026
Merged

stefoy merged 54 commits into
awslabs:mainfrom
pmorgenrood:upstream-pr/summary-package-zip

Conversation

@pmorgenrood

@pmorgenrood pmorgenrood commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Build-MainSummaryFromZip.ps1 -PackageZip builds its portable zip with Compress-Archive -Path (Join-Path $OutputDirectory '*'), so the zip takes everything in -OutputDirectory, not only what the call reconstructed. When the folder already holds other files, they go into the zip too: an earlier reconstruction, the wrapper's per-subscription ResourcesReport<stamp>/ folders (with their ObfuscationDictionary_*.json and Full_*.json), a loose dictionary, or a plain inventory.

On Windows a leading dot does not hide a file, so when -OutputDirectory is the wrapper's inventory root (C:\InventoryReports), the wrapper's resume state file .resume-state-<tenant>.json is zipped as well. That file holds the tenant id and the completed subscription ids. On Linux and macOS the wildcard skips dot-files, so only that one file stays out there.

Change

New-RdaAllSubHtmlSummaryFromZip records the ResourcesReport_<stamp>/ folders it reconstructs from the input zip, and the files it writes in them. -PackageZip zips only those files, plus the summary html, which must sit in -OutputDirectory. The zip is written entry by entry with .NET's zip classes (the first version passed the list to Compress-Archive -LiteralPath). This is the approach #57 takes for ResourceInventory.ps1 and Merge-RecoveryData: zip an explicit list of the files the call wrote instead of a wildcard over the folder.

  • No new parameter or exit code. The rebuild now stops with an error in more cases, before it writes anything (see Update below).
  • A new output folder (the default <zip name>_MainSummary) gives the same zip as before.
  • Other files in the folder are left where they are; they are kept out of the zip and, since this update, out of the summary.

Zip contents, before and after

Input: a consolidated zip with two per-subscription zips. -OutputDirectory: a folder that already holds an earlier reconstruction, one wrapper per-subscription folder, a dictionary, a plain inventory and .resume-state-<id>.json.

Before, on Windows (16 entries):

.resume-state-12345678-1234-1234-1234-123456789012.json
Inventory_ResourcesReport_20251201000000003.json
MainSummary.html
ObfuscationDictionary_ResourcesReport_20251201000000003.json
ResourcesReport_20251201000000001/Inventory_ResourcesReport_20251201000000001.json
ResourcesReport_20251201000000001/ResourcesReport_20251201000000001.html
ResourcesReport_20260102030405001/Inventory_ResourcesReport_20260102030405001.json
ResourcesReport_20260102030405001/ResourcesReport_20260102030405001.html
ResourcesReport_20260102030405002/Inventory_ResourcesReport_20260102030405002.json
ResourcesReport_20260102030405002/ResourcesReport_20260102030405002.html
ResourcesReport20251201000000002/Consumption_ResourcesReport_20251201000000002.csv
ResourcesReport20251201000000002/Full_ResourcesReport_20251201000000002.json
ResourcesReport20251201000000002/Inventory_ResourcesReport_20251201000000002.json
ResourcesReport20251201000000002/Metrics_ResourcesReport_20251201000000002.json
ResourcesReport20251201000000002/ObfuscationDictionary_ResourcesReport_20251201000000002.json
ResourcesReport20251201000000002/ResourcesReport_20251201000000002.html

Before, on Linux: the same list without the .resume-state-*.json entry (15 entries).

After, on Windows and Linux (5 entries):

MainSummary.html
ResourcesReport_20260102030405001/Inventory_ResourcesReport_20260102030405001.json
ResourcesReport_20260102030405001/ResourcesReport_20260102030405001.html
ResourcesReport_20260102030405002/Inventory_ResourcesReport_20260102030405002.json
ResourcesReport_20260102030405002/ResourcesReport_20260102030405002.html

Summary rows (changed since the first version)

The first version left MainSummary.html listing every ResourcesReport* folder in -OutputDirectory, and re-rendered all of them, so with a reused folder the summary in the zip kept rows whose links did not resolve inside the zip. The current head lists, reads and re-renders only the report folders and files this call rebuilt from -InputZip. Other folders in -OutputDirectory are not in the summary, are not re-rendered and are not changed.

Testing

  • New Tests/SummaryPackageZip.Tests.ps1 runs Build-MainSummaryFromZip.ps1 against a stand-in consolidated zip in the wrapper's layout, once into a folder holding the files above and once into a new folder. It checks the exact entry list, that the resume state file, the other folders, the dictionaries and the plain inventory are not in the zip, that the other files are still on disk, and that every summary link resolves after extracting the zip from a new folder. Since the first version it also covers the cases in the Update section below.
    • First version (7 tests): before this change, 3 of 7 failed on Windows and 2 of 7 on Linux, where the resume state test passed because the wildcard skips dot-files; with it, 7 of 7 passed on Windows and on Linux (PowerShell 7.6).
    • Current head, measured on Linux with PowerShell 7: 106 of 108 pass and 2 are skipped (one needs a file system that ignores letter case, one needs a Windows share path). The same file on the first version: 14 pass, 93 fail, 1 skipped.
  • Tests/AllSubHtmlSummary.Tests.ps1: 21 of 21 pass on the current head (Linux); on the first version, 18 of 21. The first version passed its 16 of 16 on Windows and on Linux.
  • New Tests/VmBillingStrictMode.Tests.ps1 (3 of 3) and Tests/MaskedTokenShapes.Tests.ps1 (20 of 20) pass on the current head; on the first version, 0 of 3 and 12 of 20.
  • For the first version: the full Tests/ folder before and after gave the same 162 failing tests on both (they need a sample report zip in Tests/), and PSScriptAnalyzer with PSScriptAnalyzerSettings.psd1 reported nothing for the changed files. These two were not measured again for this update.

How to test

# A consolidated zip (AllSubscriptions_ResourcesReport_*.zip) and a folder that
# already holds other files, for example an earlier reconstruction and a file
# named .resume-state-test.json.
./Build-MainSummaryFromZip.ps1 -InputZip ./AllSubscriptions_ResourcesReport_<stamp>.zip -OutputDirectory ./reused -PackageZip

# List the package written next to the folder. Expect MainSummary.html and one
# ResourcesReport_<stamp>/ folder per subscription in the input zip, nothing else.
Add-Type -AssemblyName System.IO.Compression.FileSystem
$Zip = [System.IO.Compression.ZipFile]::OpenRead((Resolve-Path ./reused.zip).Path)
$Zip.Entries.FullName
$Zip.Dispose()

# Automated:
Invoke-Pester ./Tests/SummaryPackageZip.Tests.ps1 -Output Detailed

On Windows, before this change, the listing includes .resume-state-test.json and every other file in the folder.

Update: what the current head adds

The first version only changed what goes into the -PackageZip zip. Review found more ways a rebuild into a reused folder could pick up, overwrite or lose files, so the head now also does the following.

  • Only this zip's reports. The summary lists, reads and re-renders only the report folders and files rebuilt from -InputZip (see Summary rows above). If a folder of the same name already holds other files, those are neither read nor bundled. A second report zip or report folder with a name already used is skipped with a warning, and the first is kept. A report zip with no Inventory_*.json is skipped with a warning. Names are compared as the file system there compares them, so two names that differ only in letter case are one folder on Windows and macOS and two on Linux.
  • The zip is checked before anything is taken out of it. The rebuild stops before it writes anything when the input zip, or a report zip inside it, is outside these limits: more than 2000 entries, an entry over 16 GB, more than 32 GB in all, an entry or the whole packed more than 100 to 1 (or into 0 bytes), or an entry path that is rooted or holds ... The whole rebuild, rendered files and the summary included, must also fit 2000 files and 32 GB. The bundle is checked against the same limits as written, before it gets its name.
  • One rebuild at a time per folder. While it runs, a rebuild holds a lock on the empty file .rda-rebuild.lock in -OutputDirectory. A second rebuild into the same folder, by any user, stops before it changes anything and says another rebuild is writing there. The lock file stays in the folder; it is never in the summary or the bundle.
  • Nothing is lost when a rebuild fails. Each rebuilt file is written under a private name (<file>.rda-<id>.partial); the file it replaces is moved aside (<file>.rda-<id>.bak) until every file is in place. A failed or stopped rebuild puts the earlier files back, and names any file it could not put back or remove, with what to do. The main summary is written the same way, so a failed write keeps the earlier summary whole; this also applies to the summary Run-AllSubscriptions.ps1 writes. A rebuild that fails removes the empty folders it made (on macOS a folder it made stays, holding only the lock file).
  • New stops, before anything is written: -OutputDirectory is a drive or file system root (also through a link); a report folder in it is a link or junction; -PackageZip would overwrite -InputZip; the summary html is not in -OutputDirectory; a path holds a link on PowerShell 7.0 or 7.1, which cannot follow links. The extraction folder is made new and, on Linux and macOS, readable by this user only.
  • A report with no html. When a report's zip holds no html, one is rendered as <folder>.html. A file of that name already in the folder is replaced only when the render works. A report whose inventory cannot be read keeps its html link in the summary.
  • Privacy banners no longer call a sample proof. The main summary's banner follows -Obfuscate (the wrapper passes it on), as in Mark the main summary row of a subscription whose consumption failed #64. Each subscription's report, which can only check a sample of its names, no longer says Suitable for sharing: it says only a sample was checked and to review the report before sharing it. Masked names with a type hint (prod_aks_<guid>, prod_vmss_<guid>, prod_databricks_<guid>) now count as masked.
  • VM billing check. The per-subscription report's check of running VMs against billed VMs now counts a VM whose power state is running, transient or empty as running. It still compares counts only, which the code notes as a known shortcut.
  • Paths and strict mode. Every file and folder is read and written by its literal path, so names with [ or ] work, and the rebuild and the report renderer run under Set-StrictMode -Version Latest (a report without a VirtualMachines section or a Version key included).
  • No new parameter or exit code. Each new stop is an error, as the existing stops are.

Merge order. Both #64 and #67 are on main and can merge alone. Merge #64 first, then #67. #67 carries the same privacy-banner and masked-name edits as #64, so after #64 it has one conflict, in Functions/AllSubHtmlSummary.Functions.ps1 where the main summary is written: take #67's side (it writes under a private name, then moves the file into place, by literal path).

Open limits: not run live against main (main needs the Azure CLI), and not run on Windows.

-PackageZip zipped everything in -OutputDirectory with a wildcard. When
the folder already held other files (an earlier reconstruction, the
wrapper's per-subscription folders, an obfuscation dictionary, a plain
inventory), they went into the portable zip too. On Windows a leading
dot does not hide a file, so the wrapper's .resume-state-<tenant>.json,
which lists subscription ids, was included when the folder was the
inventory root.

Record the ResourcesReport_* folders this call reconstructs and zip only
those plus the summary html (when it sits in the folder). A new output
folder gives the same zip as before.

Adds Tests/SummaryPackageZip.Tests.ps1, which runs the script against a
stand-in consolidated zip into a folder holding those files.
pmorgenrood pushed a commit to pmorgenrood/resource-discovery-for-azure that referenced this pull request Oct 30, 2026
Peter-John Morgenrood added 27 commits November 9, 2026 10:27
Build-MainSummaryFromZip.ps1 into an -OutputDirectory that already held
other ResourcesReport* folders listed and counted all of them in
MainSummary.html, and re-rendered their html too. With -PackageZip the
bundle holds only the folders rebuilt from -InputZip, so the packaged
summary linked to folders it did not contain, and over an obfuscated input
it showed the obfuscated banner beside a plain folder's subscription name.

New-RdaAllSubHtmlSummary takes an optional -ReportFolders list of the folder
names to list. The rebuild passes the folders it rebuilt and re-renders only
those. A new default output folder holds no other folders and is unchanged.
The summary joins each report link with Join-Path, so on Windows a link
holds '\'. The packaged-summary tests compared the links with '/'-joined
names and would fail there on correct output. Turn '\' into '/' before
comparing, as Get-ZipEntryNames in the same file does; a '/' path still
resolves after extraction on every platform.
A folder in -OutputDirectory with the same name as one rebuilt from
-InputZip can already hold other files: a revealed report with real names,
an older report or a consumption file. -PackageZip zipped the whole folder,
so those files travelled with the bundle. The bundle now holds the summary
and, per rebuilt folder, only the files this call wrote there; the re-render
also uses only those files. The other files stay where they are.
Two report zips with the same name in different folders of the input zip
were both extracted into one folder, the second over the first, and both
were counted. The first one is now used, the second is skipped with a
line that names it, and the count says how many folders were rebuilt.
The bundle held only the files this call wrote, but the summary still took
the first Inventory_*.json and html of each folder, so a valid inventory an
earlier call left in a folder of the same name could put its names in the
packaged summary, or a link to a file left out of the bundle. The summary
builder takes an optional -ReportFiles list, and the rebuild passes the
files it wrote.
…file system path

An input zip that holds extracted report folders instead of report zips
copied two folders of the same name into one, the second over the first,
and counted both; the first is now used and the second skipped with a
line, as for report zips. The output folder is resolved to its file system
path (ProviderPath), which the .NET zip calls and the list of written files
need on a PowerShell drive.
…HtmlFile as a file system path

Two report zips whose names differ only in case are one folder on Windows
and macOS, but the duplicate check compared names exactly, so the second
was extracted over the first; names are now compared case aside. An
-HtmlFile given through a PowerShell drive was read as a drive path while
the output folder was a file system path, so -PackageZip left the summary
out; both are now file system paths.
…nd write the bundle under a private name

Names were compared case aside on every system, so on Linux a folder or
file of an earlier call whose name differs only in case could be read into
the summary; names are now compared exactly on Linux and case aside on
Windows and macOS (Get-RdaPathComparer). -PackageZip deleted and rewrote
<OutputDirectory>.zip even when that was -InputZip; it now stops before it
changes anything. The bundle is written under a private name beside it and
moved into place, so a write that fails leaves no part-written bundle.
Names were compared by the system's default (exact on Linux, case aside
elsewhere), but a Linux mount can ignore case and a Windows or macOS
folder can keep it apart. Get-RdaPathComparer now looks for the path under
its name with the letter case flipped (reading and writing nothing) and
compares exactly or case aside as that file system does; the input zip
check, the duplicate check and the file lists use it.
…s, and keep -HtmlFile beside them

The probe tested the folder that holds the path, read a path typed in the
other case as a second item, and could throw on an unreadable listing. It
now probes a name inside the folder, counts entries that differ only in
case as two items only when there are two, and falls back to the system
default when it cannot read the listing. The list of rebuilt folders is
made unique as the file system compares names, so two folders whose names
differ only in case are both listed where they are two. -HtmlFile must be
in -OutputDirectory, beside the folders its links point to; otherwise the
rebuild stops instead of writing broken links or leaving the summary out of
the bundle.
…y real reports

A summary rebuilt from a zip expanded the whole input, and each report zip
in it, with no limit, so a crafted zip could fill the disk. The input zip
and each report zip are now checked first against fixed report zip limits
(2000 entries, 16 GB an entry, 32 GB in all, 100 to 1,
no rooted or .. path). The staging folder is a new folder of its own (never
an existing one) and readable by this user only on Linux and macOS. A report
zip without an inventory is skipped and not counted, so a zip of only those
says no report was found. Bundle entries use the names as they are on disk,
which the summary's links use, and the case probe of an empty folder looks
inside it with a probe file it removes again.
… when a render fails

Report zips were checked one by one, so many valid ones together could
write far past the limits; a report zip without an inventory wrote its html
over a file already in a folder of that name and then deleted it. The
rebuild now first reads which report zips and entries it will write,
skipping a zip without an inventory or a second zip of a name, and stops
before writing anything when they hold more than 2000 files or 32 GB in all.
The re-render writes to a private name beside the html and replaces it only
when it worked, so a failed render keeps the original. The staging folder's
mode uses chmod where .NET has no SetUnixFileMode (PowerShell before 7.3).
…en, and stage safely

The budget counted only the files taken from the report zips, not the html
the re-render writes for a report without one or the summary, so a rebuild
within it could still write, and bundle, more than 2000 files. Those files
now count, and the bundle is checked as written (2000 files, 32 GB) before
it takes its name. The input zip is checked before -OutputDirectory is
created, so a refused zip creates nothing. The staging folder is made and
made private inside the try, a failed chmod stops the rebuild, and only a
folder this call made is removed. The tests read the folder mode with stat
and take their case expectations from the file system.
…mit, and write the summary safely

An input zip of extracted report folders was copied without the rebuild's
budget; those folders are now planned against it before anything is
copied. The finished bundle is checked with all the report zip limits (16
GB an entry and 100 to 1 too), since recompressing can pack it tighter. The
main summary is written under a private name and moved over the old one only
when the write worked. A refused or failed rebuild removes an empty
-OutputDirectory it made.
…ave no folder a refusal made

A rebuild into a reused folder wrote each inventory and html straight over
the file already there, so a read or disk failure part-way left an earlier
report cut short. Every file is now written under a private name beside its
target, and all of them take their names only after the last one is written.
The -HtmlFile check runs before -OutputDirectory is made, and a rebuild that
finds no report removes the folders it made, parents included. A folder that
was already there is kept. Assert-RdaZipWithinLimit takes a singular name, as
the analyzer asks.
…the bundle, and refuse a root output folder

The rebuilt files took their places one by one, so a file that could not
take its place left the files before it replaced. Each old file is now moved
aside first and all are put back when any later step fails or the run is
stopped. -PackageZip compared the bundle and the input zip by their written
paths, so a linked folder could make the bundle replace the input zip; both
paths now follow links first. A drive or file system root is refused as
-OutputDirectory. The bundle's summary check uses the file system's own name
comparison, as the -HtmlFile check does.
…and follow links in a link's own target

When putting the earlier files back after a failed swap, one file that could
not be put back stopped the rest and hid the cause. Each is now tried in turn,
and the error keeps the cause and names every earlier file left under its
private name. A file is marked as swapped before it moves, so a stop right
after the move is undone too. Links in the parent folders of a link's target
are followed, and a path part whose link cannot be read is kept as given. A
share root given with its separator is refused like a drive root. The script
help says which private files a killed run can leave and what to do with them.
…left out of place, and refuse rooted zip entries on any system

A report folder already in -OutputDirectory that is a link or junction would
take the writes outside it; the rebuild now stops before writing. Where this
PowerShell cannot read a link's target (7.0 and 7.1), a -PackageZip path with
a link in it stops instead of being compared by its written form. Putting
files back names a new file it could not remove as well as an earlier file it
could not put back, says which file to replace, and names only files from
before the run. A private file or folder that cannot be removed is named in a
warning. A zip entry starting with / or \ or a drive letter is refused on
every system. The script help says what each kept file is for.
…name, and warn once per leftover

The link check read the reparse-point attribute, which OneDrive and dedup
folders carry too, so a rebuild into a OneDrive folder was refused; it now
reads PowerShell's own link type (symbolic link or junction). A report whose
zip has no html was rendered over a file of that name already in a reused
folder, and that file was listed for the summary and the bundle before the
render worked; the render now takes a free name and is listed only once
written. A private file that cannot be removed after a failed swap is named
in one warning, not two.
…lready there only after a good render

The free name chosen last round added one more html to a reused folder on
every rerun. The render now goes to <folder>.html: a file of that name is
moved aside only after the render works, put back if the move in fails (or
kept and named if it cannot be), and removed once the new file is in place,
so a rerun keeps one html per report. A failed render of a report with no
html says so instead of "kept original". A comment names the macOS /tmp
case on PowerShell 7.0/7.1, and the script help says how the render names
its file.
…rendered files only when a render runs

A stop between moving the earlier html aside and moving the render in ran
only the finally block, which removed the earlier html. The earlier html is
now removed only once the new one is in; otherwise it is put back, or kept
and named when it cannot be. The rebuild budget counted an html for each
report without one even with -KeepOriginalReports or without the renderer,
so a valid input near the 2000-file limit was refused; it now counts it only
when a render will run.
…he renderer by its literal path, and say what is on disk after a skipped render

Two zip entries whose names differ only in case are one file where the file
system ignores case, but both spellings were listed, so the bundle held that
file twice under one name. Each folder's written files are now a set with
the file system's comparer. The renderer was looked up as a wildcard path, so
a repo folder with brackets in its name skipped the re-render; it is now a
literal path. The skipped-render line is written after the earlier html is
put back, and says when it is not in place instead of "kept original".
…ad and write paths with brackets literally

A report folder can treat letter case apart from -OutputDirectory, but its
files were compared with the output folder's rule: the summary could take a
file the run did not write, the bundle could leave one out, and putting files
back could drop an earlier file as if it were from this run. Each folder's
files are now compared with that folder's own rule. The main summary write
and the renderer's own read and write took a path with brackets as a
wildcard, so a rebuild under such a folder failed or skipped its renders;
they now use literal paths.
…the rendered html's size by its literal path

The summary compared each listed file's whole path with the report folder's
case rule, though the folder part of that path follows the run folder's rule,
so a report could be dropped without a message. Files are now grouped by
folder with the run folder's rule and matched by file name with the report
folder's rule, which is asked only of a folder with listed files. The
renderer read its html's size through a wildcard path; it is now literal.
Under Set-StrictMode -Version Latest the link checks read LinkType from a
path that did not exist yet, and the privacy sample counted a single match
without an array, so a rebuild into a new folder stopped. Both are read
safely now. The rebuild entry point and the renderer found their shared
functions through a wildcard path, so a repo folder with brackets in its name
could not run them; they now use literal paths. The comparer's comment says
where a probe file can be made.
The summary found a report's html only after reading its inventory, so a report whose inventory could not be read showed no link though its html was there. The html is now found first and the link kept.
…rer is right and runs under strict mode

With one service the report showed its record count as the number of service types, and under strict mode a single or no sample match stopped the render. Both counts are taken of a list now, as on the summary-wording branch. The strict-mode rebuild test also checks that no render was skipped.
Peter-John Morgenrood added 19 commits November 9, 2026 17:31
Without -Obfuscated, a run whose sampled names look masked printed
'Privacy: obfuscated', while the banner asks for a check before sharing.
The console line now says 'obfuscated (sample only; check before
sharing)' in that case. The two comments above the banner are one.

(cherry picked from commit 3ed4fc5)
… masked names

The per-subscription renderer said a report held no real identifiers and was suitable for sharing when a sample of its names looked masked, and the rebuild puts every report it renders in the shareable bundle. It now says only a sample was checked and to check the report before sharing, with the same text as the summary-wording branch so the two merge cleanly.
With links not followable, the case failed whenever the temp folder sat under a link (as /var does on macOS). It now builds its paths from the temp folder with links followed.
… followed

On PowerShell 7.0/7.1 the root check fell back to the path as written when it could not follow a link, so a link to a root passed. It now stops there, as -PackageZip does.
A consumption file in a folder with brackets in its name was taken as a wildcard path, so the VM billing check was skipped or could read another file. The summary-wording branch makes the same change on lines it also rewrites; when both land, its version of those lines is kept.
Two rebuilds into the same output folder could move, replace or put back
each other's files: a rollback took a file another call had just put in
place as its own. A rebuild now takes a lock on the folder, in this user's
temp folder, before it checks or changes anything there, and a second one
stops with a message until the first finishes. The operating system frees
the lock when the process ends.
The lock file sat in this user's temp folder, keyed on the user name, so a
second user, or the same user with another temp folder, took a different
lock and could still write into the same folder. Any failure to open it
was also reported as another rebuild running. The lock is now
.rda-rebuild.lock in the output folder, held with no sharing and removed
when let go; only a lock held by another caller is reported as another
rebuild, and any other failure is passed on with its own message.
- The lock file was removed when the lock was let go, so on Linux and
  macOS a caller that opened it just before could lock the removed file
  while another locked a new one, and both would write. It now stays in
  the folder; it is removed only with a folder this call made, after a
  failed or refused rebuild.
- A failed rebuild removes the empty report folders it made while it still
  holds the lock, then lets go and removes a -OutputDirectory it made.
- A rebuild whose lock fails for a reason other than another rebuild
  removes the empty folders it made before it stops.
…g the lock

A failed rebuild into a folder it made let go of the lock before it removed
the lock file, so on Linux and macOS a caller that opened the file in that
gap could lock the removed file while another made a new one. On Linux and
macOS the file is now removed while the lock is held; Windows cannot remove
an open file and lets no one open it while held, so there it is let go
first and left to a rebuild that takes it in between.
A VM counts as running when its PowerState says running or transient,
or is empty; the check counted only 'running', so a rebuilt report could
miss a real billing gap.
… empty

- On Linux and macOS a caller that opened the lock file just before its
  holder removed it could lock the removed file. After the lock is taken
  the path is checked again; if the file is gone the rebuild is refused as
  if the lock were held (a shortcut comment names the moment that check
  cannot see).
- An empty folder this call made is removed with Directory.Delete, which
  fails without a prompt on a folder another rebuild has started to use,
  instead of a check followed by Remove-Item.
… is there

On Linux and macOS, a rebuild that opened the lock file just before a
failed rebuild into a folder it made removed it, and locked it after,
went ahead when a third rebuild had made a new lock file in the folder
by then: two rebuilds wrote into the same folder. The rebuild that
removes its lock file now first writes a removed mark into it while it
holds the lock. A rebuild that finds the mark through its own handle
opens the path again: it then locks the file in the folder, or is
refused because another rebuild holds it. A mark left on a file in the
folder (it could not be removed) is emptied, so later rebuilds go ahead.
…that cannot be told

The removed mark still let a caller that opened the lock file twice just
before two removals hold a removed file, and writing the mark could throw
from the failure path and hide the rebuild's own error. The mark is gone.
On Linux, Test-RdaLockFileInFolder reads /proc/self/fd/<n>, which names a
removed file with ' (deleted)', so a caller holding a removed lock file is
refused whatever file is at the path now. Where that cannot be told
(macOS), a failed rebuild no longer removes the lock file, so the folder
it made stays, holding only that file (shortcut comment names the
upgrade). Windows is as before: an open file cannot be removed there.
…iffers

Three tests of a refused rebuild (no report found, the budget, and the folders it made) and the failed-rebuild folder test were skipped whole on macOS, where only their last check differs: the folder a rebuild made stays there, holding only its lock file. They now run everywhere, and Assert-RdaMadeFolderLeft checks the folder is gone, or holds only .rda-rebuild.lock where a removed lock file cannot be told. With Test-RdaCanSeeRemovedLock forced false (as on macOS) they pass; only the three Linux-only tests, skipped on macOS, fail then.
…tcut

Its comment said a per-VM join is impossible because the two files mask ids through different dictionaries; the output contract gives a masked resource one token in every file. The comment now names the count comparison as a shortcut (a VM with no billing can be missed when the counts match) and the branch that replaces it with a join by ID.
Under -Obfuscate the collector names a Databricks, AKS-managed or scale-set resource prod_databricks_<guid>, prod_aks_<guid> or prod_vmss_<guid> (nonprod_ alike), but the masked-report check of Summary.ps1 and of the main summary matched only prod_<guid> and nonprod_<guid>. A masked report made mostly of such resources could read as identifiable. Both patterns now allow those three hints; Tests/MaskedTokenShapes.Tests.ps1 (the same file on sync/pr-64, sync/pr-67 and upstream-pr/summary-wording) checks every shape.
…t mode

Assert-RdaZipWithinLimit skipped the ratio check for an entry whose packed
size is 0, so a non-empty entry that says it is packed into nothing passed
the 100 to 1 limit; it is now refused (empty entries still pass), and so
is a whole zip whose files pack into 0 bytes.

Under Set-StrictMode -Version Latest the VM billing check of Summary.ps1
threw on a billing file with no Virtual Machines row (the catch then hid
the banner for that real zero) and on an inventory with no
VirtualMachines section. Both reads are guarded. The shortcut comment
names the upgrade (join by ID, with Set as the scale-set fallback)
without naming a branch.
Under Set-StrictMode -Version Latest, Summary.ps1 threw on an inventory with no Version key when no -Version was given. The read is guarded with the same line upstream-pr/summary-wording has; the strict-mode test renders such an inventory.
pmorgenrood pushed a commit to pmorgenrood/resource-discovery-for-azure that referenced this pull request Nov 17, 2026
@pmorgenrood
pmorgenrood force-pushed the upstream-pr/summary-package-zip branch from f2ed20a to e9aeef1 Compare November 17, 2026 23:59
@pmorgenrood
pmorgenrood force-pushed the upstream-pr/summary-package-zip branch from e9aeef1 to acebc85 Compare November 18, 2026 17:21
pmorgenrood pushed a commit to pmorgenrood/resource-discovery-for-azure that referenced this pull request Nov 18, 2026
pmorgenrood pushed a commit to pmorgenrood/resource-discovery-for-azure that referenced this pull request Nov 18, 2026
pmorgenrood pushed a commit to pmorgenrood/resource-discovery-for-azure that referenced this pull request Nov 18, 2026
@stefoy
stefoy merged commit f8ebada into awslabs:main Nov 25, 2026
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.

2 participants