Skip to content

Comments

NS-661 Refactor usage of temporary agent networks.#742

Draft
andreidenissov-cog wants to merge 7 commits intomainfrom
ASD-NS-661-temp-networks01
Draft

NS-661 Refactor usage of temporary agent networks.#742
andreidenissov-cog wants to merge 7 commits intomainfrom
ASD-NS-661-temp-networks01

Conversation

@andreidenissov-cog
Copy link
Contributor

No description provided.

@andreidenissov-cog andreidenissov-cog force-pushed the ASD-NS-661-temp-networks01 branch from f809c2d to a383098 Compare February 20, 2026 00:27
:return: Whether the reservation is expired or not.
"""
return time.time() >= self.expiration_time_in_seconds

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Convenience function for simpler checks.



class FixedAgentNetworkProvider(AgentNetworkProvider):
"""
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AgentNetworkProvider which returns immutable instance of temp network.
We don't want extra redirection here which would allow dynamic replacement of agent network version.

"public": AgentNetworkStorage(),
"temp": ExpiringAgentNetworkStorage()
"temp": ExpiringCachingAgentNetworkStorage()
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type for our temp networks storage class now changes.

TempNetworkStorageUpdater(server_context.get_network_storage_dict(), watcher_config,
TempNetworkStorageUpdater(server_context.get_network_storage_dict(),
server_context.get_queues())
]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No "watcher_config" in parameters list - our TempNetworkStorageUpdater is not really a "watcher".

@andreidenissov-cog andreidenissov-cog force-pushed the ASD-NS-661-temp-networks01 branch from 53523c6 to 5b8d296 Compare February 20, 2026 18:36
supporting addition Reservations in bulk and retrieval of individual Reservations,
as well as expiration of Reservations based on their lifetime.
"""

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New interface for classes storing Reservations, with methods to add and extract reservations,
set them to expired state AND set another ExpiringReservationsStorage instance
to serve as a persistent backup, so our instance will work as a front cache for Reservations requests.

# Another component to start is the temporary networks updater
temp_networks_updater: TempNetworkStorageUpdater =\
TempNetworkStorageUpdater(self.server_context.get_network_storage_dict(), self.server_context.get_queues())
components_to_start.append(temp_networks_updater)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TempNetworkStorageUpdater is not a "watcher" anymore, so create it separately
and add to the list of components to be started after our HTTP server starts running.

:param base_storage: An ExpiringReservationsStorage instance to use as a source of truth
"""
raise NotImplementedError

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For S3 based reservations storage, we don't have a backup place.

stored in its associated agent spec as metadata.
"""

def __init__(self, bucket_name: str = "", prefix: str = "reservations/",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation especially for S3 operations is mostly copied from S3ReservationsStorage class.
Difference is that we are running our own thread (owned by AbstractExpiringReservationsStorage)
which actively polls for expired Reservation objects.

raise ValueError(f"Access denied to S3 bucket '{self.bucket_name}'") from exception
raise ValueError(f"Error accessing S3 bucket '{self.bucket_name}': {exception}") from exception
# We are good with S3 connection and bucket access at this point,
# let's start underlying logic:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Start AbstractExpiringReservationsStorage thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant