Build Lifecycle
The build lifecycle in Klarity ImageFactory is a structured process that ensures every golden image is built, tested, and distributed consistently. This guide explains the different states an image can occupy and what happens at each stage of the journey.
Lifecycle Overview
The following diagram illustrates the primary states and transitions in the image build lifecycle:
Detailed Stage Descriptions
TEMPLATE_CREATED
This is the initial state when a template is first saved in the database. The platform performs basic validation of the configuration and prepares the initial metadata for the build.
TEMPLATE_PENDING
In this state, ImageFactory performs provider-specific initialization tasks. For example, in Azure, this might involve creating the gallery image definition if it doesn't already exist. For VMware, it might involve verifying the availability of the source ISO or template.
IMAGE_QUEUED
The build request is placed in a queue, waiting for available capacity in the build environment. The duration of this state depends on the current system load.
IMAGE_BUILDING
This is the core of the build process. The following actions take place:
- A source instance is provisioned from the base distribution.
- System preparations are performed.
- Security hardenings are applied.
- Build components are installed and configured.
- The latest OS package updates are installed.
- The instance is shut down and captured as a machine image.
IMAGE_TESTING
Once the image is captured, a temporary test instance is launched from it. The platform then executes the configured test components, which may include:
- Functional verification of installed software.
- CIS benchmark scans to ensure compliance.
- Generation of a compliance score.
IMAGE_CREATED
The image has successfully passed all build and test stages. It is now distributed to all configured customer cloud accounts and is ready for production use.
Error States
TEMPLATE_ERROR
This state indicates a configuration issue with the template itself that prevents the build from starting. Examples include invalid distribution IDs or incompatible component selections.
IMAGE_ERROR
This state occurs when a failure happens during the building or testing phases. This could be due to a script error, a network timeout, or a failed compliance test. Detailed logs are available in the console to help diagnose the issue.
Build Tracking and Metrics
ImageFactory tracks several metrics for every build to help you monitor performance and identify bottlenecks:
| Metric | Description |
|---|---|
build_start_time | The timestamp when the build moved to the IMAGE_BUILDING state. |
build_end_time | The timestamp when the build reached a terminal state (IMAGE_CREATED or IMAGE_ERROR). |
build_time_sec | The total duration of the build and test process in seconds. |
By understanding these states, you can better monitor your image pipeline and quickly respond to any issues that arise during the automated build process.