-
Notifications
You must be signed in to change notification settings - Fork 4
KMS: enforce TLS requirement #1069
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| from typing import Annotated, List, Optional | ||
| from uuid import UUID | ||
|
|
||
| from fastapi import APIRouter, Depends, HTTPException, Request, Response | ||
| from fastapi import APIRouter, Depends, HTTPException, Response | ||
| from pydantic import BaseModel | ||
|
|
||
| from simplyblock_core.db_controller import DBController | ||
|
|
@@ -42,24 +42,23 @@ class StoragePoolParams(BaseModel): | |
| cr_plural: str = "" | ||
|
|
||
|
|
||
| @api.post('/', name='clusters:storage-pools:create', status_code=201, responses={201: {"content": None}}) | ||
| def add(request: Request, cluster: Cluster, parameters: StoragePoolParams) -> Response: | ||
| @api.post('/', name='clusters:storage-pools:create', status_code=201) | ||
| def add(cluster: Cluster, parameters: StoragePoolParams): | ||
| for pool in db.get_pools(cluster.get_id()): | ||
| if pool.pool_name == parameters.name: | ||
| raise HTTPException(409, f'Pool {parameters.name} already exists') | ||
|
|
||
| id_or_false = pool_controller.add_pool( | ||
| pool_id = pool_controller.add_pool( | ||
| parameters.name, parameters.pool_max, parameters.volume_max_size, parameters.max_rw_iops, parameters.max_rw_mbytes, | ||
| parameters.max_r_mbytes, parameters.max_w_mbytes, cluster.get_id(), | ||
| parameters.cr_name, parameters.cr_namespace, parameters.cr_plural, | ||
| dhchap=parameters.dhchap, | ||
| ) | ||
|
|
||
| if not id_or_false: | ||
| raise ValueError('Failed to create pool') | ||
| if not pool_id: | ||
| raise HTTPException(500, 'Failed to create pool') | ||
|
|
||
| pool = db.get_pool_by_id(id_or_false) | ||
| return pool.to_dict() | ||
|
Comment on lines
-45
to
-62
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure about the modifications here, why are they necessary? In particular:
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My implementation is a bit incomplete here. I wanted to have exception based handling rather than depending on So I'll revert variable change. And then add a query parameter to so that user can decide if they need response or not.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great, thanks! I don't think we have these parameters in this codebase yet so I think we can just copy the approach from vela. I think this is also an opportunity to properly type the endpoint and return the appropriate DTO instead of a random dict. |
||
| return db.get_pool_by_id(pool_id).to_dict() | ||
|
|
||
|
|
||
| instance_api = APIRouter(prefix='/{pool_id}') | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was meant to be part of the original review, apparently it got lost in transit:
This makes sense to introduce semantically, but belongs in the settings module imho. I see that
simplyblock_core.settings.Settings.validate_tls_filesfails to extend the check to mTLS:Once this is fixed, we could simply check
Settings().tls_connect == "authenticated", which is much more readable. I can open a PR to introduce the change if you like, given that it's quite small it might make more sense to include in this PR.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, thanks. would it be great if you can propose changes with a new PR 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On it.