Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CASMCMS-8451: Fail sessions that specify nodes that are not in the tenant #228

Merged
merged 2 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 that specify nodes that aren't in the current tenant will fail

## [2.10.1] - 2023-10-31
### Fixed
Expand Down
7 changes: 7 additions & 0 deletions src/bos/operators/session_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions src/bos/server/controllers/v2/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def patch_v2_components_list(data):
component_id = component_data['id']
if component_id not in DB or not _is_valid_tenant_component(component_id):
return connexion.problem(
status=404, title="Component could not found.",
status=404, title="Component not found.",
detail="Component {} could not be found".format(component_id))
components.append((component_id, component_data))
except Exception as err:
Expand Down Expand Up @@ -251,7 +251,7 @@ def get_v2_component(component_id):
LOGGER.debug("GET /components/id invoked get_component")
if component_id not in DB or not _is_valid_tenant_component(component_id):
return connexion.problem(
status=404, title="Component could not found.",
status=404, title="Component not found.",
detail="Component {} could not be found".format(component_id))
component = DB.get(component_id)
component = _set_status(component)
Expand Down Expand Up @@ -281,7 +281,7 @@ def patch_v2_component(component_id):
LOGGER.debug("PATCH /components/id invoked patch_component")
if component_id not in DB or not _is_valid_tenant_component(component_id):
return connexion.problem(
status=404, title="Component could not found.",
status=404, title="Component not found.",
detail="Component {} could not be found".format(component_id))
try:
data = connexion.request.get_json()
Expand Down Expand Up @@ -325,7 +325,7 @@ def delete_v2_component(component_id):
LOGGER.debug("DELETE /components/id invoked delete_component")
if component_id not in DB or not _is_valid_tenant_component(component_id):
return connexion.problem(
status=404, title="Component could not found.",
status=404, title="Component not found.",
detail="Component {} could not be found".format(component_id))
return DB.delete(component_id), 204

Expand Down
Loading