Skip to content

AttributeError: self.attached_quantity is undefined if not verify_entitlements #59

@ogajduse

Description

@ogajduse

Problem Statement

def verify_allocation_entitlements(self, entitlement_quantity, subscription_name):
"""Checks that the entitlements in the allocation match those defined in settings."""
logger.info(f"Verifying the entitlement quantity of {subscription_name} on the allocation.")
data = {
"headers": {"Authorization": f"Bearer {self.access_token}"},
"proxies": self.manifest_data.get("proxies"),
"params": {"include": "entitlements"},
}
self.entitlement_data = simple_retry(
self.requester.get,
cmd_args=[f"{self.allocations_url}/{self.allocation_uuid}"],
cmd_kwargs=data,
).json()
current_entitlement = [
d
for d in self.entitlement_data["body"]["entitlementsAttached"]["value"]
if d["subscriptionName"] == subscription_name
]
if not current_entitlement:
return
logger.debug(f"Current entitlement is {current_entitlement}")
self.attached_quantity = current_entitlement[0]["entitlementQuantity"]

Due to verify_allocation_entitlements exiting using the first return statement from the top and not setting self.attached_quantity, the process_subscription_pools does not have self.attached_quantity available, therefore Manifester fails with AttributeError: 'Manifester' object has no attribute 'attached_quantity'

verify_entitlements = self.verify_allocation_entitlements(
entitlement_quantity=subscription_data["quantity"],
subscription_name=subscription_data["name"],
)
if not verify_entitlements:
# If no entitlements of a given subscription are
# attached, refresh the pools and try again
if not self.attached_quantity:

Logs

[D 250303 22:30:33 manifester:112] Generating access token
[D 250303 22:30:33 helpers:28] Sending request to endpoint ['https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token']
[D 250303 22:30:34 helpers:30] Response status code is 200
[D 250303 22:30:34 helpers:28] Sending request to endpoint ['https://api.access.redhat.com/management/v1/allocations/versions']
[D 250303 22:30:34 helpers:30] Response status code is 200
[D 250303 22:30:34 helpers:28] Sending request to endpoint ['https://api.access.redhat.com/management/v1/allocations']
[D 250303 22:30:41 helpers:30] Response status code is 200
[D 250303 22:30:41 manifester:172] Received response {'body': {'uuid': '41a1ce12-3a3d-403e-ad79-960a5bcb396d', 'name': 'satqe-lHWpsQAh', 'type': 'Satellite', 'version': '6.16', 'createdDate': '2025-03-03T22:30:37.000Z', 'createdBy': 'rhsatqe', 'lastModified': '2025-03-03T22:30:41.000Z', 'entitlementsAttachedQuantity': 0, 'simpleContentAccess': 'enabled'}} when attempting to create allocation.
[I 250303 22:30:41 manifester:186] Subscription allocation created with name satqe-lHWpsQAh and UUID 41a1ce12-3a3d-403e-ad79-960a5bcb396d
[D 250303 22:30:41 helpers:28] Sending request to endpoint ['https://api.access.redhat.com/management/v1/allocations']
[D 250303 22:30:42 helpers:30] Response status code is 200
[D 250303 22:30:42 helpers:28] Sending request to endpoint ['https://api.access.redhat.com/management/v1/allocations/41a1ce12-3a3d-403e-ad79-960a5bcb396d/pools']
[D 250303 22:30:43 helpers:30] Response status code is 200
[D 250303 22:30:43 manifester:269] Finding a matching pool for Red Hat Enterprise Linux Server, Premium (Physical or Virtual Nodes).
[D 250303 22:30:43 manifester:275] The following pools are matches for this subscription: [{'id': '388b00cc7f7ff5d4c22c64827a2d3f0b', 'sku': 'RH00003', 'subscriptionName': 'Red Hat Enterprise Linux Server, Premium (Physical or Virtual Nodes)', 'subscriptionNumber': '14703430', 'contractNumber': '17027663', 'startDate': '2022-01-01T05:00:00.000Z', 'endDate': '2027-01-01T04:59:59.000Z', 'serviceLevel': 'Premium', 'entitlementsAvailable': 3859}, {'id': '8a85f9a17d76f31b017da574cb151766', 'sku': 'RH00003', 'subscriptionName': 'Red Hat Enterprise Linux Server, Premium (Physical or Virtual Nodes)', 'subscriptionNumber': '10450270', 'contractNumber': '12860073', 'startDate': '2022-01-01T05:00:00.000Z', 'endDate': '2027-01-01T04:59:59.000Z', 'serviceLevel': 'Premium', 'entitlementsAvailable': 924}]
[D 250303 22:30:43 manifester:281] Pool 388b00cc7f7ff5d4c22c64827a2d3f0b is a match for this subscription and has 3859 entitlements available.
[D 250303 22:30:43 helpers:28] Sending request to endpoint ['https://api.access.redhat.com/management/v1/allocations/41a1ce12-3a3d-403e-ad79-960a5bcb396d/entitlements']
[D 250303 22:30:47 helpers:30] Response status code is 200
[D 250303 22:30:47 manifester:330] Successfully added 1 entitlements of Red Hat Enterprise Linux Server, Premium (Physical or Virtual Nodes) to the allocation.
[D 250303 22:30:47 helpers:28] Sending request to endpoint ['https://api.access.redhat.com/management/v1/allocations']
[D 250303 22:30:47 helpers:30] Response status code is 200
[D 250303 22:30:47 helpers:28] Sending request to endpoint ['https://api.access.redhat.com/management/v1/allocations/41a1ce12-3a3d-403e-ad79-960a5bcb396d/pools']
[D 250303 22:30:49 helpers:30] Response status code is 200
[D 250303 22:30:49 manifester:269] Finding a matching pool for Red Hat Enterprise Linux for Virtual Datacenters, Premium.
[D 250303 22:30:49 manifester:275] The following pools are matches for this subscription: [{'id': '8a85f9a17d76f31b017da575ed3517cc', 'sku': 'RH00001', 'subscriptionName': 'Red Hat Enterprise Linux for Virtual Datacenters, Premium', 'subscriptionNumber': '10450307', 'contractNumber': '12860073', 'startDate': '2022-01-01T05:00:00.000Z', 'endDate': '2027-01-01T04:59:59.000Z', 'serviceLevel': 'Premium', 'entitlementsAvailable': 1}]
[D 250303 22:30:49 helpers:28] Sending request to endpoint ['https://api.access.redhat.com/management/v1/allocations/41a1ce12-3a3d-403e-ad79-960a5bcb396d/pools']
[D 250303 22:30:51 helpers:30] Response status code is 200
[D 250303 22:30:51 manifester:269] Finding a matching pool for Red Hat Satellite Infrastructure Subscription.
[D 250303 22:30:51 manifester:275] The following pools are matches for this subscription: [{'id': '365d1e363e640ce369a512a517b9af6', 'sku': 'MCT3718', 'subscriptionName': 'Red Hat Satellite Infrastructure Subscription', 'subscriptionNumber': '15810531', 'contractNumber': '17212124', 'startDate': '2024-11-11T05:00:00.000Z', 'endDate': '2025-11-11T04:59:59.000Z', 'serviceLevel': 'Premium', 'entitlementsAvailable': 357}, {'id': '8a85f98d6977b2190169e77499ab5757', 'sku': 'MCT3718', 'subscriptionName': 'Red Hat Satellite Infrastructure Subscription', 'subscriptionNumber': '6101388', 'startDate': '2019-04-03T04:00:00.000Z', 'endDate': '2027-01-01T04:59:59.000Z', 'serviceLevel': 'Premium', 'entitlementsAvailable': 49}, {'id': '8a85f9a17d76f31b017da574cc501768', 'sku': 'MCT3718', 'subscriptionName': 'Red Hat Satellite Infrastructure Subscription', 'subscriptionNumber': '10450247', 'contractNumber': '12860073', 'startDate': '2022-01-01T05:00:00.000Z', 'endDate': '2027-01-01T04:59:59.000Z', 'serviceLevel': 'Premium', 'entitlementsAvailable': 190}]
[D 250303 22:30:51 manifester:281] Pool 365d1e363e640ce369a512a517b9af6 is a match for this subscription and has 357 entitlements available.
[D 250303 22:30:51 helpers:28] Sending request to endpoint ['https://api.access.redhat.com/management/v1/allocations/41a1ce12-3a3d-403e-ad79-960a5bcb396d/entitlements']
[D 250303 22:30:52 helpers:30] Response status code is 404
[I 250303 22:30:52 manifester:227] Verifying the entitlement quantity of Red Hat Satellite Infrastructure Subscription on the allocation.
[D 250303 22:30:52 helpers:28] Sending request to endpoint ['https://api.access.redhat.com/management/v1/allocations/41a1ce12-3a3d-403e-ad79-960a5bcb396d']
[D 250303 22:30:52 helpers:30] Response status code is 200
[D 250303 22:30:52 manifester:112] Generating access token
[D 250303 22:30:52 helpers:28] Sending request to endpoint ['https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token']
[D 250303 22:30:53 helpers:30] Response status code is 200
[D 250303 22:30:53 helpers:28] Sending request to endpoint ['https://api.access.redhat.com/management/v1/allocations/41a1ce12-3a3d-403e-ad79-960a5bcb396d']
[D 250303 22:30:54 helpers:30] Response status code is 204
[D 250303 22:30:54 helpers:28] Sending request to endpoint ['https://api.access.redhat.com/management/v1/allocations']
[D 250303 22:30:54 helpers:30] Response status code is 200

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions