From 48a2b7db484b45a6ad1f891eff7972d2de04bbe0 Mon Sep 17 00:00:00 2001 From: Ryan Bak Date: Thu, 26 Oct 2023 15:18:35 -0400 Subject: [PATCH] CASMCMS-8451: Fail sessions that specify nodes that are not in the tenant --- CHANGELOG.md | 2 ++ src/bos/operators/session_setup.py | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94fc9d04..a3729b1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## Unreleased +### Changed +- Sessions the specify nodes that aren't in the current tenant will fail ## [2.10.0] - 10-18-2023 ### Fixed diff --git a/src/bos/operators/session_setup.py b/src/bos/operators/session_setup.py index 3cf5de51..3c34c304 100644 --- a/src/bos/operators/session_setup.py +++ b/src/bos/operators/session_setup.py @@ -137,6 +137,13 @@ def _get_boot_set_component_list(self, boot_set) -> Set[str]: # Populate from nodelist for node_name in boot_set.get('node_list', []): nodes.add(node_name) + if nodes: + tenant_nodes = self._apply_tenant_limit(nodes) + if nodes != tenant_nodes: + invalid_nodes = ",".join(list(nodes.difference(tenant_nodes))) + raise SessionSetupException( + f"The session template includes nodes which do not exist" + f" or are not available to this tenant: {invalid_nodes}") # Populate from node_groups for group_name in boot_set.get('node_groups', []): if group_name not in self.inventory.groups: