Skip to content

Commit

Permalink
Update Workshop and ResourceClaims reporting (#2174)
Browse files Browse the repository at this point in the history
* Adding count of ordered provisions

Adding additional "ordered" value to the
provisionCount field of the Workshop resource.

* Propagating orederdBy, requester and asset-uuid values to RC
  • Loading branch information
makirill authored Oct 10, 2024
1 parent ba9c32b commit 9e2693c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
3 changes: 3 additions & 0 deletions helm/crds/workshops.babylon.gpte.redhat.com.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ spec:
provisionCount:
type: object
properties:
ordered:
description: Total number of WorkshopProvisions ordered.
type: integer
provisioning:
description: Number of WorkshopProvisions that are provisioning.
type: integer
Expand Down
5 changes: 4 additions & 1 deletion workshop-manager/operator/babylon.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ class Babylon():
poolboy_api_version = os.environ.get('POOLBOY_API_VERSION', 'v1')
poolboy_namespace = os.environ.get('POOLBOY_NAMESPACE', 'poolboy')
demo_domain = os.environ.get('DEMO_DOMAIN', 'demo.redhat.com')
gpte_domain = os.environ.get('GPTE_DOMAIN', 'gpte.redhat.com')

asset_uuid_label = f"{gpte_domain}/asset-uuid"
babylon_ignore_label = f"{babylon_domain}/ignore"
catalog_display_name_annotation = f"{babylon_domain}/catalogDisplayName"
catalog_item_display_name_annotation = f"{babylon_domain}/catalogItemDisplayName"
Expand All @@ -20,9 +22,10 @@ class Babylon():
lab_ui_url_annotation = f"{babylon_domain}/labUserInterfaceUrl"
lab_ui_urls_annotation = f"{babylon_domain}/labUserInterfaceUrls"
notifier_annotation = f"{babylon_domain}/notifier"
ordered_by_annotation = f"{demo_domain}/orderedBy"
purpose_annotation = f"{demo_domain}/purpose"
purpose_activity_annotation = f"{demo_domain}/purpose-activity"
requester_annotation = f"{babylon_domain}/requester"
requester_annotation = f"{demo_domain}/requester"
resource_broker_ignore_label = f"{poolboy_domain}/ignore"
resource_claim_label = f"{poolboy_domain}/resource-claim"
resource_pool_annotation = f"{poolboy_domain}/resource-pool-name"
Expand Down
13 changes: 11 additions & 2 deletions workshop-manager/operator/workshop.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ def action_schedule_stop(self):
stop_timestamp, '%Y-%m-%dT%H:%M:%SZ'
).replace(tzinfo=timezone.utc)

@property
def asset_uuid(self):
return self.labels.get(Babylon.asset_uuid_label)

@property
def ignore(self):
return Babylon.babylon_ignore_label in self.labels
Expand Down Expand Up @@ -70,6 +74,10 @@ def multiuser_services(self):
def requester(self):
return self.annotations.get(Babylon.requester_annotation)

@property
def ordered_by(self):
return self.annotations.get(Babylon.ordered_by_annotation)

@property
def service_url(self):
return self.annotations.get(Babylon.url_annotation)
Expand Down Expand Up @@ -204,12 +212,13 @@ async def update_status(self):
}
})

async def update_provision_count(self, provisioning, failed, completed):
async def update_provision_count(self, provisioning, failed, completed, ordered):

await self.merge_patch_status({
"provisionCount": {
"ordered": ordered,
"provisioning": provisioning,
"failed": failed,
"completed": completed,
}
})
})
7 changes: 7 additions & 0 deletions workshop-manager/operator/workshopprovision.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,15 @@ async def create_resource_claim(self, logger, workshop):
if not self.enable_resource_pools:
resource_claim_definition['metadata']['annotations'][Babylon.resource_pool_annotation] = "disable"

if workshop.asset_uuid:
resource_claim_definition['metadata']['labels'][Babylon.asset_uuid_label] = workshop.asset_uuid

if workshop.requester:
resource_claim_definition['metadata']['annotations'][Babylon.requester_annotation] = workshop.requester

if workshop.ordered_by:
resource_claim_definition['metadata']['annotations'][Babylon.ordered_by_annotation] = workshop.ordered_by

if catalog_item.lab_ui_type:
resource_claim_definition['metadata']['labels'][Babylon.lab_ui_label] = catalog_item.lab_ui_type

Expand Down Expand Up @@ -320,6 +326,7 @@ async def manage_resource_claims(self, logger, workshop):
failed_count += 1

await workshop.update_provision_count(
ordered=self.count,
provisioning=provisioning_count,
failed=failed_count,
completed=resource_claim_count - provisioning_count - failed_count
Expand Down

0 comments on commit 9e2693c

Please sign in to comment.