Configuration Snapshot Design
This document describes the design and implementation of the configuration snapshot feature in the light-portal.
Overview
A configuration snapshot captures the state of an instance’s configuration at a specific point in time. It includes all properties, files, and relationships defined for that instance, merging overrides from various levels (Product, Environment, Product Version) into a “burned-in” effective configuration.
Snapshots are created in two scenarios:
- Deployment Trigger: Automatically created when a deployment occurs (to capture the state being deployed).
- User Trigger: Manually created by a user via the UI (e.g., to save a milestone).
Data Model
Snapshot Header (config_snapshot_t)
Captures metadata about the snapshot.
snapshot_id: UUIDsnapshot_type: Type of snapshot (e.g.,DEPLOYMENT,USER_SAVE)instance_id: Target instancehost_id: Tenant identifierdeployment_id: Link to deployment (if applicable)product_version: Locked product version at time of snapshotservice_id: Locked service ID
Snapshot Content
Snapshot data is normalizing into shadow tables that mirror the runtime configuration tables. These tables differ from the runtime tables by including a snapshot_id and lacking some runtime-specific fields.
Key tables include:
snapshot_instance_property_tsnapshot_instance_file_tsnapshot_deployment_instance_property_tsnapshot_product_version_property_tsnapshot_environment_property_t- … (others for APIs, Apps, etc.)
Effective Configuration (config_snapshot_property_t)
A flattened, merged view of all properties for the snapshot. This table represents the “final” configuration values used by the instance.
- Calculated by merging properties from all levels (Deployment > Instance > Product Version > Environment > Product) based on priority.
Backend Implementation
Stored Procedure (create_snapshot)
Located in portal-db/postgres/sp_tr_fn.sql.
This procedure performs the heavy lifting:
- Validates the instance and retrieves scope data (product, environment, etc.).
- Creates the snapshot header record.
- Copies raw data from active runtime tables to snapshot tables (e.g.,
instance_property_t->snapshot_instance_property_t). - Merges properties from all levels into
config_snapshot_property_t.- Handles list/map merging (aggregation).
- Handles scalar overriding (last update wins/priority tiers).
Persistence Layer (ConfigPersistenceImpl.java)
Provides the Java interface to calls the stored procedure:
createConfigSnapshot: CallsCALL create_snapshot(...).getConfigSnapshot: Retrieves snapshot headers with filtering/sorting.updateConfigSnapshot: Updates metadata (description).deleteConfigSnapshot: Deletes a snapshot and its cascaded data (if cascade delete is set up in DB, otherwise manual cleanup might be needed).
Front End Implementation
Config Snapshot Page (ConfigSnapshot.tsx)
- Displays a list of snapshots for a selected instance.
- Supports filtering by
current, ID, date, etc. - Actions:
- Create: Navigates to
/app/form/createConfigSnapshot. - Update: Fetches fresh data and navigates to update form.
- Delete: Calls
deleteSnapshotcommand.
- Create: Navigates to
Gap Analysis & Missing Components
The following components are currently MISSING or incomplete:
-
Command Handlers:
CreateConfigSnapshothandler (for User Trigger) is missing inconfig-command.DeleteConfigSnapshothandler is missing inconfig-command.GetFreshConfigSnapshothandler is missing (required for the “Update” action in UI).
-
Deployment Integration:
CreateDeployment.java(indeployment-command) does NOT callcreateConfigSnapshot.- The automatic snapshot creation on deployment is currently not implemented.
-
API Definition:
- The
createConfigSnapshotanddeleteConfigSnapshotendpoints need to be defined in the schema/routing if they are not already.
- The
Action Plan
-
Implement Command Handlers:
- Create
CreateConfigSnapshothandler inconfig-commandthat invokesConfigPersistence.createConfigSnapshot. - Create
DeleteConfigSnapshothandler inconfig-command. - Create
GetFreshConfigSnapshothandler inconfig-query.
- Create
-
Integrate with Deployment:
- Modify
CreateDeployment.java(or the platform handler it invokes) to callConfigPersistence.createConfigSnapshotimmediately after a successful deployment job is submitted or completed.
- Modify
-
Review Idempotency:
- Ensure
create_snapshothandles re-runs gracefully (Idempotency is partially handled by UUID generation, but business logic should prevent duplicate snapshots for the exact same state if needed).
- Ensure