my $cleanup_state = sles4sap::sap_deployment_automation_framework::subscription_cleanup->new();
Class is used to hold data structure containing all information regarding orphaned resources cleanup. Content of this object is preserved between calls of new() using state.
Structure:
openqa: openQA job data: job_id, instance, start_time, retention_sec. retention_sec is the retention period in seconds used to mark resources as orphaned. Value of 'SDAF_CLEANUP_RETENTION_SEC' openQA setting (Default 12H).
summary: Resource counters: found, deleted, failed, skipped. Updated by executing _update_summary.
results: Detailed results per resource type.
_time_test($input_time, $retention_sec);
Checks $input_time against $retention_sec. Returns '1' (true) if time is older than retention period, otherwise 0 (false).
input_time: Time to check against retention period in ISO 8601 format. Example: 2026-01-01T12:00:00 or 2026-01-01T12:00:00.123456+02:00. Microseconds are supported only together with a +HH:MM offset. Time without offset is UTC.
retention_sec: Retention period in seconds
my @kql = _kql_query(
search_target => 'resourcecontainers',
name_regex => '^SDAF-OpenQA-sap_system');
Returns an ARRAY of KQL statements for az_graph_query() which help finding resources matching following cleanup criteria:
Name matches name_regex (case-sensitive).
Tag no_cleanup_tag() is not defined.
Tags deployment_id and openqa_created_date are defined and not empty.
Returned fields: id, name, deployment_id, openqa_created_date.
my $cleanup_result = sles4sap::sap_deployment_automation_framework::subscription_cleanup->new();
$cleanup_result->get_orphaned_resource_groups();
Queries for all orphaned SDAF resource groups not meeting retention criteria and updates main class data. A workload zone is added only if a 'sap_system' resource group with the same deployment_id is already in the deletion list $self->{results}{sap_systems} or does not exist at all.
my $cleanup_result = sles4sap::sap_deployment_automation_framework::subscription_cleanup->new();
$cleanup_result->get_orphaned_resources();
Queries for all orphaned SDAF deployer VM resources not meeting retention criteria.
my $cleanup_result = sles4sap::sap_deployment_automation_framework::subscription_cleanup->new();
$cleanup_result->destroy_orphaned_groups();
Destroys all 'sap_system' and 'workload_zone' resource groups which were marked as orphaned by `get_orphaned_resource_groups()`. If 'sap_system' group fails to be deleted corresponding 'workload_zone' deletion is skipped to avoid unnecessary failure. With OpenQA setting 'SDAF_CLEANUP_DRYRUN' enabled, no resource group is deleted.
my $cleanup_result = sles4sap::sap_deployment_automation_framework::subscription_cleanup->new();
$cleanup_result->destroy_orphaned_resources();
Destroys all Deployer VM resources marked as orphaned. Resources are destroyed always in a batch according to a resource group they belong to. With OpenQA setting 'SDAF_CLEANUP_DRYRUN' enabled, no resource group is deleted.
$self->_update_summary();
Counts resources in all categories of $self->{results} and writes the counters into $self->{summary}.
found: All resources marked as orphaned
deleted: Resources with result 'deleted'
failed: Resources with result 'failed'
skipped: Resources with result 'skipped'
my $cleanup_result = sles4sap::sap_deployment_automation_framework::subscription_cleanup->new();
$cleanup_result->export_cleanup_report();
Updates summary counter to keep data up to date. Converts report data structure to json and uploads it as a log file.