Skip to content

fix(installer): [develop] preflight dependencies and verify populated upgrades - #8306

Open
somethingwithproof wants to merge 14 commits into
Cacti:developfrom
somethingwithproof:fix/installer-completion-contracts
Open

somethingwithproof wants to merge 14 commits into
Cacti:developfrom
somethingwithproof:fix/installer-completion-contracts

Conversation

@somethingwithproof

@somethingwithproof somethingwithproof commented Oct 11, 2026 •

Copy link
Copy Markdown
Member

This change makes Cacti installation and upgrades check their prerequisites and results before reporting completion. Shared web and CLI components perform an offline dependency preflight, prepare an upgrade plan, verify required schema and authentication state, and retain a bounded diagnostic report. This makes partial upgrades easier to detect and recover from while keeping database restoration a separate operator action.

Implementation details

An incomplete dependency tree or partially applied upgrade could reach database changes before an actionable failure. This adds a shared offline preflight for web and CLI entry points, an explicit source-checkout preparation command, a reviewable upgrade plan with backup/recovery guidance, and schema/authentication postconditions before recording the target version.

The installer retains an administrator-downloadable report containing controlled operation names, migration versions, timings and outcomes. It excludes credentials, commands, SQL and exception text. Collector synchronization now visits every collector, preserves incomplete outcomes as completion warnings, and propagates unexpected failures to CLI exit status. A missing 1.3 template column migration and nullable collector TLS arguments were found by populated upgrade tests and corrected.

This follows #8266 and includes its current head. The installer-only formatting changes in #8302 have been removed from that PR to keep ownership clear. Security baseline entries are placed to merge with #7790 without changing queue behavior.

Recorded local validation:

  • All nine new installer components: 100% line coverage; 26 tests and 63 assertions, with success/failure/timeout/invalid-input branches exercised.
  • Focused installer unit/integration suite: 83 tests and 368 assertions, including real HTTP session/CSRF recovery.
  • PHPStan level 8, PHP lint and project formatting checks; security sink and architectural guards; actionlint for changed workflows.
  • New components parse with PHP 8.2; Cacti's PHP >=8.3 requirement remains enforced.
  • The recorded PR-head snapshot passed 572 ordered pair merge checks and twenty cumulative merge simulations across develop and 1.2.x.
  • The preparation command succeeds on a clean source checkout and repairs a deliberately missing dependency entry point.

Complete local Docker suites pass for 1.2.22 on MariaDB 11.8 and 1.2.31 on MariaDB 10.11, including all four Chromium checks in each run, repeated upgrades, failure injection and lock exclusion. The recorded validation reported passing required GitHub checks, including the four tagged release/database jobs and the PHP 8.3/8.4/8.5 component coverage gates. Each local complete suite passes 22 scenarios. CI adds tagged 1.2.22 and 1.2.31 fixtures on MariaDB 10.11 and 11.8, containing LDAP users/providers, compatible and missing plugins, two collector databases, customized templates, an existing RRD file and 100,000 buffered samples. Tests verify preservation, real local/LDAP login, key pages/assets, sessions/CSRF, diagnostics authorization, repeat execution, and injected failure paths.

The report retains the latest run and supports diagnosis/manual recovery. It does not implement automatic migration replay or transactional DDL rollback. Synthetic fixtures are preservation tests, not production-scale polling benchmarks. The component gate enforces 100% line coverage for new components; it does not claim 100% coverage of the legacy installer.

Fixes #7885. Related / partial implementation: #3816, #7285.

Release notes are consolidated in #8320. Review and merge this child before that final documentation PR.

Conflict resolution against develop 9899fdf preserves #8317’s LDAP-table guard and prevents intermediate version downgrades during forced replays, while retaining dependency preflight, schema/authentication postconditions, run diagnostics and the shared CommandRunner. The preflight design continues to replace runtime Composer installs; its dependency-failure tests remain, and the obsolete refreshVendorDependencies fixture is not restored. Regenerated security baselines contain three substantive changes relative to develop (two controlled dependency-loader entries added and the old inline process launch removed), plus indentation changes. Both inventory verifiers pass.

Validation on mise-selected PHP 8.5.11: all 2,482 Unit tests pass (four skips), 69 installer Unit/Integration cases pass, PHP-CS-Fixer and full level-8 PHPStan pass. The complete disposable PHP 8.4 Docker installer matrix passes for release 1.2.22/MariaDB 11.8 and release 1.2.31/MariaDB 10.11, including populated LDAP/plugin/template/collector state, four browser scenarios per run, repeated forced repairs and failed-replay version/lock protection. No live databases were modified and no changelog entries were added to this child.

Review fixes: installer reports preserve valid JSON within the 4096-byte settings column, retain the newest operation and disclose omitted entries. Web and CLI installation now record each migration version, including failures. Native successful and failed upgrade checks pass; the component suite passes 29 tests at 100% coverage on PHP 8.3.35. New PHP files carry the full project copyright and license header.

Revision and checks

Description scope: target develop, 44 changed files, head 4dd8a15b2. Checked 2026-10-23 03:06:04 UTC.

GitHub check snapshot: 2 passed. Local test figures and earlier CI runs above are recorded evidence for their stated revisions and environments; they do not assert that every check passes at this head.

Update: the web upgrade path now records the new database version only after the schema and authentication checks pass, matching the CLI path, so a failed check no longer leaves the database marked as upgraded.

Merge order: this PR and #8302, #8451, #8540, #8673, #8704, #8730 change .github/workflows/pr-changed-coverage.yml. Suggested order for that file: #8540, #8704, then this PR, then #8730, #8673, #8451, #8302. This PR and #8302, #8461, #8475 change tests/Helpers/SourceSlice.php. Suggested order for that file: #8461, then this PR, then #8475, #8302. This PR and #8730 change the same lines of install/functions.php, lib/installer.php and the installer tests under tests/e2e/ and tests/integration/ in different ways, so no order is suggested between them; they need to be reconciled. Whichever merges later will be rebased.

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

Downloadable reports omit web migration versions and can exceed the database column used to persist them.

2 open findings
What changed in this PR

Adds installer dependency preflight, upgrade diagnostics, postcondition checks, collector synchronization reporting, and populated upgrade validation.

Changes:

  • Adds offline dependency checks and preparation tooling.
  • Adds upgrade plans, reports, schema/authentication verification, and collector warnings.
  • Expands upgrade coverage across release, database, LDAP, plugin, and browser fixtures.
File Description
.github/​workflows/​installer-components-coverage.yml Adds component coverage matrix.
.github/​workflows/​installer-coverage.yml Expands installer integration matrix.
.github/​workflows/​release-artifact.yml Validates packaged dependencies.
cli/​install_cacti.php Displays plans and warnings.
cli/​prepare_install.sh Prepares source dependencies.
cli/​upgrade_database.php Adds postconditions and reporting.
docs/​INSTALLER_RECOVERY.md Documents upgrade recovery.
include/​global_arrays.php Registers report authorization.
install/​background.php Adds dependency preflight.
install/​functions.php Adds synchronization and verification helpers.
install/​install.php Adds dependency preflight.
install/​preflight.php Implements shared entry-point guard.
install/​report.php Serves authorized diagnostics.
install/​step_json.php Adds dependency preflight.
install/​upgrades/​1_3_0.php Adds missing template column.
lib/​Installer/​AuthenticationRequirements.php Validates authentication mappings.
lib/​Installer/​CollectorSynchronizer.php Classifies collector outcomes.
lib/​Installer/​CommandRunner.php Runs bounded subprocesses.
lib/​Installer/​CompletionWarnings.php Serializes completion warnings.
lib/​Installer/​DependencyPreflight.php Checks runtime dependencies and assets.
lib/​Installer/​RunReport.php Models installer diagnostics.
lib/​Installer/​RunState.php Defines report states.
lib/​Installer/​SchemaRequirements.php Parses required schema columns.
lib/​Installer/​UpgradePlan.php Models planned upgrade effects.
lib/​installer.php Integrates plans, reports, and postconditions.
lib/​poller.php Handles nullable collector TLS fields.
locales/​po/​cacti.pot Updates translation messages.
phpunit-installer-components.xml Configures component coverage.
tests/​e2e/​installer_application_check.sh Verifies upgraded application behavior.
tests/​e2e/​installer_failure_paths.php Adds failure-injection scenarios.
tests/​e2e/​installer_populated_fixture.sql Provides populated upgrade data.
tests/​e2e/​installer_resilience_docker.sh Expands Docker upgrade scenarios.
tests/​e2e/​tests/​installer-upgrade.spec.ts Adds browser upgrade checks.
tests/​fixtures/​InstallerPlugin/​INFO Defines fixture plugin metadata.
tests/​fixtures/​InstallerPlugin/​setup.php Implements fixture plugin hooks.
tests/​integration/​InstallerVendorRefreshContractTest.php Verifies preflight ordering.
tests/​security/​baselines/​architectural_hotspots.baseline.tsv Updates architectural inventory.
tests/​security/​baselines/​sink_inventory.baseline.tsv Updates security sink inventory.
tests/​Unit/​Installer/​InstallerComponentsTest.php Tests new installer components.
tests/​Unit/​Installer/​InstallerResilienceTest.php Updates resilience contracts.
tests/​Unit/​Installer/​VendorBootGuardTest.php Removes obsolete refresh tests.
tests/​Unit/​Security/​Csrf/​ItemActionPostOnlyTest.php Normalizes test quoting.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lib/Installer/RunReport.php Resolved
Comment thread lib/installer.php Resolved
@somethingwithproof somethingwithproof changed the title fix(installer): preflight dependencies and verify populated upgrades fix(installer): [develop] preflight dependencies and verify populated upgrades Oct 12, 2026
bmfmancini
bmfmancini previously approved these changes Oct 12, 2026

@TheWitness TheWitness left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's a nit but put in the full copyright header

@somethingwithproof somethingwithproof left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added the full project copyright and license header to the new PHP files in 5bd7a6e, as requested in your review.

somethingwithproof added a commit to somethingwithproof/cacti that referenced this pull request Oct 14, 2026
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@somethingwithproof
somethingwithproof force-pushed the fix/installer-completion-contracts branch from 196bb36 to 94cb034 Compare October 17, 2026 06:08
Comment thread cli/prepare_install.sh Fixed
Comment thread tests/e2e/installer-coverage.sh Fixed
Comment thread tests/e2e/installer-coverage.sh Fixed
@somethingwithproof
somethingwithproof force-pushed the fix/installer-completion-contracts branch 3 times, most recently from fe597f6 to 095c00b Compare October 17, 2026 20:31
github-actions Bot pushed a commit to somethingwithproof/cacti that referenced this pull request Nov 23, 2026
…ented PRs

Cacti#8012 and Cacti#8340 closed without merging; their successors Cacti#8513 and Cacti#8512
carry their own work, and Cacti#8513 already adds its own fragment. Cacti#8306 now
adds changelog.d/8306.issue itself, so this copy would collide with it.
Cacti#8302 is now formatting-only after its defect fixes moved to Cacti#8810, which
carries changelog.d/8809.issue.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
github-actions Bot pushed a commit to somethingwithproof/cacti that referenced this pull request Nov 24, 2026
…ented PRs

Cacti#8012 and Cacti#8340 closed without merging; their successors Cacti#8513 and Cacti#8512
carry their own work, and Cacti#8513 already adds its own fragment. Cacti#8306 now
adds changelog.d/8306.issue itself, so this copy would collide with it.
Cacti#8302 is now formatting-only after its defect fixes moved to Cacti#8810, which
carries changelog.d/8809.issue.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
github-actions Bot pushed a commit to somethingwithproof/cacti that referenced this pull request Nov 24, 2026
…ented PRs

Cacti#8012 and Cacti#8340 closed without merging; their successors Cacti#8513 and Cacti#8512
carry their own work, and Cacti#8513 already adds its own fragment. Cacti#8306 now
adds changelog.d/8306.issue itself, so this copy would collide with it.
Cacti#8302 is now formatting-only after its defect fixes moved to Cacti#8810, which
carries changelog.d/8809.issue.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@somethingwithproof
somethingwithproof force-pushed the fix/installer-completion-contracts branch from cc94dd4 to 251c63e Compare November 25, 2026 08:04
github-actions Bot pushed a commit to somethingwithproof/cacti that referenced this pull request Nov 25, 2026
…ented PRs

Cacti#8012 and Cacti#8340 closed without merging; their successors Cacti#8513 and Cacti#8512
carry their own work, and Cacti#8513 already adds its own fragment. Cacti#8306 now
adds changelog.d/8306.issue itself, so this copy would collide with it.
Cacti#8302 is now formatting-only after its defect fixes moved to Cacti#8810, which
carries changelog.d/8809.issue.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@github-actions
github-actions Bot force-pushed the fix/installer-completion-contracts branch from 251c63e to 1e25641 Compare November 25, 2026 20:51
github-actions Bot pushed a commit to somethingwithproof/cacti that referenced this pull request Nov 26, 2026
…ented PRs

Cacti#8012 and Cacti#8340 closed without merging; their successors Cacti#8513 and Cacti#8512
carry their own work, and Cacti#8513 already adds its own fragment. Cacti#8306 now
adds changelog.d/8306.issue itself, so this copy would collide with it.
Cacti#8302 is now formatting-only after its defect fixes moved to Cacti#8810, which
carries changelog.d/8809.issue.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
… upgrades

Adds a shared offline dependency preflight for web and CLI installs, schema and authentication postconditions before the target version is recorded, and a bounded run report that records each migration version. Fixes Cacti#7885.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
The web upgrade wrote the target version at the end of
upgradeDatabase(), before validateRequiredSchema() and
install_verify_authentication() ran.  When either check failed the run
was reported as failed, but the database already claimed to be current,
so a retry skipped the migrations.

upgradeDatabase() now advances the version only through intermediate
steps, and writeInstalledVersion() stays the only writer of the target
version, after both checks pass.  This matches cli/upgrade_database.php.

Also add PHPDoc to getUpgradePlan(), getCompletionWarnings() and
runOperation(), drop is_array() checks getUpgradePlan() had already
enforced, and add a changelog fragment for the data_template.templates
column the 1.3.0 upgrade now adds.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
upgradeDatabase() compares get_cacti_db_version() before writing
intermediate versions. The upgrade-report fixture updated version to
1.2.28 but left the static cache on the running tree, so PHP 8.4
MariaDB jobs never recorded 1.2.30 and exited 255.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
The 100% changed-code job never loaded installer or poller sources, so
every touched file stayed instrumented:false. Run InstallerChangedCoverage
and the installer component clover report, and teach the gate to read
Clover XML.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
The do/while (true) loop left an implicit return after the loop that no
path could reach. Loop while the encoded report is oversized and return
it afterwards; trimming and the storage-limit exception are unchanged.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Exercise the remaining changed installer lines with checked outcomes:
collector inventory and replication failures, unreadable or incomplete
schema metadata, unreadable providers, plugin compatibility and an
unreadable upgrade plan, an intermediate migration that succeeds before
the target fails, a failed background install, the empty report 404,
and the missing, verified, failed-verification and thrown migration
paths of cli/upgrade_database.php.

Load the global API stand-ins from a fixture file instead of eval().

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
The two changed-coverage fixtures carried a one-line notice. Use the
standard Cacti Group license block that the other new PHP files in this
change already carry.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…nged lines

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
The web installer entry points rejected any web SAPI without pcntl,
although pcntl only builds for the CLI SAPI. Composer's generated
platform check and the installer's own module table already treat it
as not applicable to the web server.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
… test files

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
An enabled LDAP provider with no server, or an enabled user whose realm
has no provider, failed the upgrade after its migrations had run and
left the version unadvanced. Both already deny those logins, and 1.2
leaves such users behind when a domain is deleted, so a working
installation could not upgrade without editing user_auth by hand.

Report them as completion warnings on the web completion page, in the
CLI output and in the run report instead. Unreadable provider
parameters still stop the upgrade: every provider would then run
without its stored settings, including any group restriction.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
New installations also showed an empty upgrade plan and the pre-upgrade
backup advice, in both the web confirmation step and the CLI.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@github-actions
github-actions Bot force-pushed the fix/installer-completion-contracts branch from 1e25641 to da20098 Compare November 26, 2026 08:52
@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

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

Labels

area:database Namespaced Cacti workflow label area:installer Namespaced Cacti workflow label release:1.3 Namespaced Cacti workflow label type:enhancement Namespaced Cacti workflow label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add release-to-release database and configuration upgrade fixture tests

5 participants