Skip to content

Commit 9e4b83e

Browse files
authored
Merge pull request #6529 from opsmill/stable-to-develop
Stable to develop
2 parents fdc1f94 + 715dd45 commit 9e4b83e

File tree

31 files changed

+770
-477
lines changed

31 files changed

+770
-477
lines changed

.vale/styles/spelling-exceptions.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
agent
22
Alibaba
3+
allocation_weight
34
Ansible
45
anonymized
56
append_git_suffix
@@ -68,6 +69,7 @@ Infrahub's
6869
infrahubctl
6970
IP
7071
IPAddress
72+
IPHost
7173
IPAM
7274
is_empty
7375
is_ip_within

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,21 @@ This project uses [*towncrier*](https://towncrier.readthedocs.io/) and the chang
1111

1212
<!-- towncrier release notes start -->
1313

14+
## [Infrahub - v1.2.11](https://github.com/opsmill/infrahub/tree/infrahub-v1.2.11) - 2025-05-23
15+
16+
### Added
17+
18+
- Add the `CoreWeightedPoolResource` generic to better control which resource should be used when allocating from a pool. The higher the weight of the resource, the more likely it is to be selected for allocation.
19+
20+
### Changed
21+
22+
- The scrollbar in the infinite scroll tables, is now only visible when your mouse hovers the table.
23+
24+
### Fixed
25+
26+
- Fix a problem in the logic to calculate a diff that could cause it to quit too early under certain unlikely circumstances
27+
- Fixes an issue where the next page of data was loaded even when the infinite scroll table wasn't scrolled.
28+
1429
## [Infrahub - v1.2.10](https://github.com/opsmill/infrahub/tree/infrahub-v1.2.10) - 2025-05-13
1530

1631
### Added

backend/infrahub/core/constants/infrahubkind.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,4 @@
7878
USERVALIDATOR = "CoreUserValidator"
7979
VALIDATOR = "CoreValidator"
8080
WEBHOOK = "CoreWebhook"
81+
WEIGHTED_POOL_RESOURCE = "CoreWeightedPoolResource"

backend/infrahub/core/node/resource_manager/ip_address_pool.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,15 @@ async def get_resource(
8181
return node
8282

8383
async def get_next(self, db: InfrahubDatabase, prefixlen: int | None = None) -> IPAddressType:
84-
# Measure utilization of all prefixes identified as resources
8584
resources = await self.resources.get_peers(db=db) # type: ignore[attr-defined]
8685
ip_namespace = await self.ip_namespace.get_peer(db=db) # type: ignore[attr-defined]
8786

88-
for resource in resources.values():
87+
try:
88+
weighted_resources = sorted(resources.values(), key=lambda r: r.allocation_weight.value or 0, reverse=True)
89+
except AttributeError:
90+
weighted_resources = list(resources.values())
91+
92+
for resource in weighted_resources:
8993
ip_prefix = ipaddress.ip_network(resource.prefix.value) # type: ignore[attr-defined]
9094
prefix_length = prefixlen or ip_prefix.prefixlen
9195

backend/infrahub/core/node/resource_manager/ip_prefix_pool.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,15 @@ async def get_resource(
8888
return node
8989

9090
async def get_next(self, db: InfrahubDatabase, prefixlen: int) -> IPNetworkType:
91-
# Measure utilization of all prefixes identified as resources
9291
resources = await self.resources.get_peers(db=db) # type: ignore[attr-defined]
9392
ip_namespace = await self.ip_namespace.get_peer(db=db) # type: ignore[attr-defined]
9493

95-
for resource in resources.values():
94+
try:
95+
weighted_resources = sorted(resources.values(), key=lambda r: r.allocation_weight.value or 0, reverse=True)
96+
except AttributeError:
97+
weighted_resources = list(resources.values())
98+
99+
for resource in weighted_resources:
96100
subnets = await get_subnets(
97101
db=db,
98102
ip_prefix=ipaddress.ip_network(resource.prefix.value), # type: ignore[attr-defined]

backend/infrahub/core/protocols.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,10 @@ class CoreWebhook(CoreNode):
227227
validate_certificates: BooleanOptional
228228

229229

230+
class CoreWeightedPoolResource(CoreNode):
231+
allocation_weight: IntegerOptional
232+
233+
230234
class LineageOwner(CoreNode):
231235
pass
232236

backend/infrahub/core/schema/definitions/core/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,13 @@
6868
core_user_validator,
6969
)
7070
from .repository import core_generic_repository, core_read_only_repository, core_repository
71-
from .resource_pool import core_ip_address_pool, core_ip_prefix_pool, core_number_pool, core_resource_pool
71+
from .resource_pool import (
72+
core_ip_address_pool,
73+
core_ip_prefix_pool,
74+
core_number_pool,
75+
core_resource_pool,
76+
core_weighted_pool_resource,
77+
)
7278
from .template import core_object_component_template, core_object_template
7379
from .transform import core_transform, core_transform_jinja2, core_transform_python
7480
from .webhook import core_custom_webhook, core_standard_webhook, core_webhook
@@ -96,6 +102,7 @@
96102
builtin_ip_prefix,
97103
builtin_ip_address,
98104
core_resource_pool,
105+
core_weighted_pool_resource,
99106
core_generic_account,
100107
core_base_permission,
101108
core_credential,

backend/infrahub/core/schema/definitions/core/resource_pool.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,26 @@
3232
],
3333
)
3434

35+
core_weighted_pool_resource = GenericSchema(
36+
name="WeightedPoolResource",
37+
namespace="Core",
38+
label="Weighted Pool Resource",
39+
description="Resource to be used in a pool, its weight is used to determine its priority on allocation.",
40+
include_in_menu=False,
41+
branch=BranchSupportType.AWARE,
42+
generate_profile=False,
43+
attributes=[
44+
Attr(
45+
name="allocation_weight",
46+
label="Weight",
47+
description="Weight determines allocation priority, resources with higher values are selected first.",
48+
kind="Number",
49+
optional=True,
50+
order_weight=10000,
51+
)
52+
],
53+
)
54+
3555
core_ip_prefix_pool = NodeSchema(
3656
name="IPPrefixPool",
3757
namespace="Core",

backend/infrahub/database/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,10 @@ async def get_db(retry: int = 0) -> AsyncDriver:
496496
auth=(config.SETTINGS.database.username, config.SETTINGS.database.password),
497497
encrypted=config.SETTINGS.database.tls_enabled,
498498
trusted_certificates=trusted_certificates,
499-
notifications_disabled_categories=[NotificationDisabledCategory.UNRECOGNIZED],
499+
notifications_disabled_categories=[
500+
NotificationDisabledCategory.UNRECOGNIZED,
501+
NotificationDisabledCategory.DEPRECATION, # TODO: Remove me with 1.3
502+
],
500503
notifications_min_severity=NotificationMinimumSeverity.WARNING,
501504
)
502505

backend/infrahub/graphql/mutations/resource_manager.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,8 @@ async def mutate_delete(
272272

273273
if violating_branches:
274274
raise ValidationError(
275-
input_value=f"Unable to delete number pool {number_pool.node.value}.{
276-
number_pool.node_attribute.value
277-
} is in use (branches: {','.join(violating_branches)})"
275+
input_value=f"Unable to delete number pool {number_pool.node.value}.{number_pool.node_attribute.value}"
276+
f" is in use (branches: {','.join(violating_branches)})"
278277
)
279278

280279
return await super().mutate_delete(info=info, data=data, branch=branch)

0 commit comments

Comments
 (0)