-
-
Notifications
You must be signed in to change notification settings - Fork 76
Release v0.39.0 #322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Release v0.39.0 #322
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b2c0b97
test: pin the PVE-only host that a leftover PBS directory turns dual
tis24dev df46e51
fix: a role needs the product installed, not the files it left behind
tis24dev 1a8d775
fix: restore reads the host type from the same check the backup uses
tis24dev 218ed93
fix: the PBS validate brick stops concluding the host is PBS
tis24dev 7790cf0
fix: a failed role no longer discards the other role and the system p…
tis24dev abe1826
fix: the marker table reports both dpkg probes, present or not
tis24dev 9de04d6
chore: drop the three detection helpers only tests called
tis24dev 708528c
fix: a version command that answers late no longer costs the run its …
tis24dev f6efdfc
test: cover the residue warning, including the silence it has to keep
tis24dev 38c804e
fix: close the gaps an adversarial review found in the issue #315 work
tis24dev 7c76b5e
fix: report detection residue at info, so leftovers stop costing a ru…
tis24dev e6c3954
deps(deps): bump the minor-updates group across 1 directory with 3 up…
dependabot[bot] 5454843
ci: bump the actions-updates group across 1 directory with 4 updates …
dependabot[bot] dffc261
fix: an unreadable dpkg status stops counting as proof a package is a…
tis24dev 8c939a3
fix: the dpkg verdict comes from the read that was checked, not from …
tis24dev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "os" | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "github.com/tis24dev/proxsave/internal/environment" | ||
| "github.com/tis24dev/proxsave/internal/logging" | ||
| "github.com/tis24dev/proxsave/internal/types" | ||
| ) | ||
|
|
||
| // replayedWarnings returns what ReplayConsoleSince prints for entries recorded after | ||
| // mark. That method replays warning and worse only, so an empty result is proof the | ||
| // entries in between were below warning. | ||
| func replayedWarnings(t *testing.T, bootstrap *logging.BootstrapLogger, mark int) string { | ||
| t.Helper() | ||
| old := os.Stderr | ||
| r, w, err := os.Pipe() | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| os.Stderr = w | ||
| done := make(chan string, 1) | ||
| go func() { | ||
| var sb strings.Builder | ||
| buf := make([]byte, 4096) | ||
| for { | ||
| n, err := r.Read(buf) | ||
| sb.Write(buf[:n]) | ||
| if err != nil { | ||
| break | ||
| } | ||
| } | ||
| done <- sb.String() | ||
| }() | ||
| bootstrap.ReplayConsoleSince(mark) | ||
| _ = w.Close() | ||
| os.Stderr = old | ||
| return <-done | ||
| } | ||
|
|
||
| // TestResidueIsReportedBelowWarning pins the level, not just the presence of the line. | ||
| // A residue is recorded only when a product was NOT proved installed, and that leaves | ||
| // two cases: a correct verdict, where the product is genuinely absent and the backup is | ||
| // complete, or an unknown verdict, which already carries its own warnings. Reporting | ||
| // this at warning pinned an otherwise healthy host at exit 1 on every single run, for | ||
| // leftovers its operator often cannot delete. | ||
| func TestResidueIsReportedBelowWarning(t *testing.T) { | ||
| bootstrap := logging.NewBootstrapLogger() | ||
| mark := bootstrap.EntryCount() | ||
|
|
||
| reportDetectionResidue(bootstrap, &environment.EnvironmentInfo{ | ||
| Type: types.ProxmoxVE, | ||
| PBSResidual: "directory (/etc/proxmox-backup)", | ||
| }) | ||
|
|
||
| if got := bootstrap.EntryCount() - mark; got != 1 { | ||
| t.Fatalf("recorded %d entries, want 1", got) | ||
| } | ||
| if replayed := replayedWarnings(t, bootstrap, mark); replayed != "" { | ||
| t.Fatalf("the residue line replayed as warning-or-worse, so it still promotes a clean run off exit 0:\n%s", replayed) | ||
| } | ||
| } | ||
|
|
||
| // TestResidueStaysQuietWhenAProductWasFound: a product that was found records no | ||
| // residue, so a healthy host of either kind must produce no line at all. A message that | ||
| // appeared on every run would be ignored by the time it mattered. | ||
| // | ||
| // It is the RESIDUE FIELD being empty that makes it quiet, not the ladder stopping | ||
| // early: since the versionless-command rung keeps walking, a host whose command | ||
| // answered without a version does reach the residue rungs, and detectPVE/detectPBS | ||
| // still return an empty residue because the product was proved installed. That is | ||
| // covered on the detection side by TestAVersionlessCommandStillProvesTheInstall. | ||
| func TestResidueStaysQuietWhenAProductWasFound(t *testing.T) { | ||
| for _, info := range []*environment.EnvironmentInfo{ | ||
| {Type: types.ProxmoxVE}, | ||
| {Type: types.ProxmoxBS}, | ||
| {Type: types.ProxmoxDual}, | ||
| {Type: types.ProxmoxVE, PVEResidual: " "}, | ||
| } { | ||
| bootstrap := logging.NewBootstrapLogger() | ||
| before := bootstrap.EntryCount() | ||
| reportDetectionResidue(bootstrap, info) | ||
| if got := bootstrap.EntryCount() - before; got != 0 { | ||
| t.Fatalf("type %s with residual %q logged %d entries, want silence", info.Type, info.PVEResidual, got) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // TestResidueIsReportedOncePerProduct: the host in issue #315 has PBS residue and no | ||
| // PBS, and the operator looking at a type they did not expect never sees the trace, | ||
| // which is debug only. | ||
| func TestResidueIsReportedOncePerProduct(t *testing.T) { | ||
| for _, tc := range []struct { | ||
| name string | ||
| info *environment.EnvironmentInfo | ||
| want int | ||
| }{ | ||
| { | ||
| name: "pbs residue on a pve host", | ||
| info: &environment.EnvironmentInfo{Type: types.ProxmoxVE, PBSResidual: "directory (/etc/proxmox-backup)"}, | ||
| want: 1, | ||
| }, | ||
| { | ||
| name: "both products left something behind", | ||
| info: &environment.EnvironmentInfo{ | ||
| Type: types.ProxmoxUnknown, | ||
| PVEResidual: "directory (/etc/pve)", | ||
| PBSResidual: "directory (/etc/proxmox-backup)", | ||
| }, | ||
| want: 2, | ||
| }, | ||
| } { | ||
| t.Run(tc.name, func(t *testing.T) { | ||
| bootstrap := logging.NewBootstrapLogger() | ||
| before := bootstrap.EntryCount() | ||
| reportDetectionResidue(bootstrap, tc.info) | ||
| if got := bootstrap.EntryCount() - before; got != tc.want { | ||
| t.Fatalf("logged %d entries, want %d", got, tc.want) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| // TestResidueReportSurvivesNilArguments: it runs on the bootstrap path, before the | ||
| // main logger exists, and must not be the thing that takes a run down. | ||
| func TestResidueReportSurvivesNilArguments(t *testing.T) { | ||
| reportDetectionResidue(nil, &environment.EnvironmentInfo{PBSResidual: "directory (/etc/proxmox-backup)"}) | ||
| reportDetectionResidue(logging.NewBootstrapLogger(), nil) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.