Skip to content

Commit

Permalink
Merge branch 'staging' into prod
Browse files Browse the repository at this point in the history
  • Loading branch information
NotChristianGarcia committed Oct 16, 2023
2 parents b6ee01f + a863916 commit bcef1a5
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 8 deletions.
4 changes: 4 additions & 0 deletions configschema.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@
"type": "integer",
"description": "Unique host_id for worker host. Each host should have at least one spawner and health check worker."
},
"test_abaco_service_password": {
"type": "string",
"description": "Abaco service password is required to run tests as it's able to generate tokens."
},
"image_allow_list": {
"type": "array",
"description": "Docker images that users are allowed to use.",
Expand Down
1 change: 1 addition & 0 deletions deployment-template/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"service_site_id": "tacc",
"service_name": "pods",
"service_password": "$env{SERVICE_PASSWORD}",
"test_abaco_service_password": "FILLTHISFORTESTING",
"tenants": [
"tacc",
"dev",
Expand Down
7 changes: 5 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Tapis
tapipy>=1.3.2
tapisservice>=1.3.0
tapipy>=1.4.0
tapisservice>=1.4.0
jsonschema==4.17.3 # Errors after this version with error below.
# Error reading local "notifications" resource. Ensure path is absolute /usr/local/lib/python3.10/site-packages/tapipy/resources/openapi_v3-notifications.yml. e:cannot import name '_legacy_validators' from 'jsonschema' (/usr/local/lib/python3.10/site-packages/jsonschema/__init__.py)


# Service API
pydantic
Expand Down
7 changes: 6 additions & 1 deletion service/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from __init__ import Tenants
from fastapi import FastAPI
from fastapi.middleware import Middleware
from fastapi.exceptions import RequestValidationError

from auth import authorization, authentication
from api_pods import router as router_pods
Expand Down Expand Up @@ -72,7 +73,11 @@
"url": "https://github.com/tapis-project/pods_service",
},
debug=False,
exception_handlers={Exception: error_handler},
exception_handlers={
Exception: error_handler,
RequestValidationError: error_handler,
422: error_handler
},
middleware=[
Middleware(HttpUrlRedirectMiddleware),
Middleware(GlobalsMiddleware),
Expand Down
4 changes: 2 additions & 2 deletions service/models_pods.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,9 @@ def check_networking(cls, v):
raise TypeError(f"networking key must be str. Got type {type(env_key).__name__}.")
res = re.fullmatch(r'[a-z0-9]+', env_key)
if not res:
raise ValueError(f"networking key must be lowercase alphanumeric. Default if 'default'.")
raise ValueError(f"networking key must be lowercase alphanumeric. Default is 'default'.")
if len(env_key) > 64 or len(env_key) < 3:
raise ValueError(f"networking key length must be between 3-64 characters. Inputted length: {len(v)}")
raise ValueError(f"networking key length must be between 3-64 characters. Inputted length: {len(env_key)}")
return v

@root_validator(pre=False)
Expand Down
4 changes: 4 additions & 0 deletions service/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
TAG = conf.version

async def error_handler(request: Request, exc):
logger.debug(f"Top of Pods Service error handler. Got error: {repr(exc)}")
response = None
status_code: int = -1
if conf.show_traceback:
Expand Down Expand Up @@ -46,8 +47,11 @@ async def error_handler(request: Request, exc):
status_code = 500
elif isinstance(exc, RequestValidationError) or isinstance(exc, ValidationError):
error_list = []
logger.debug(f"Got validation error: {repr(exc)}")
for error_dict in exc.errors():
error_list.append(f"{', '.join(str(err) for err in error_dict['loc'])}: {error_dict['msg']}")
if error_list is None:
response = error(msg=f'Unexpected. {repr(exc)}')
response = error(msg=error_list)
status_code = 400
else:
Expand Down
6 changes: 3 additions & 3 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@
def get_service_tapis_client():
sk_url = os.environ.get('sk_url', conf.primary_site_admin_tenant_base_url)
tenant_id = os.environ.get('tenant', 'admin')
service_password = os.environ.get('service_password', conf.service_password)
test_abaco_service_password = os.environ.get('test_abaco_service_password', conf.test_abaco_service_password)
jwt = os.environ.get('jwt', None)
resource_set = os.environ.get('resource_set', 'local')
custom_spec_dict = os.environ.get('custom_spec_dict', None)
download_latest_specs = os.environ.get('download_latest_specs', False)
# if there is no tenant_id, use the service_tenant_id and primary_site_admin_tenant_base_url configured for the service:
t = Tapis(base_url=sk_url or base_url,
tenant_id=tenant_id,
username='abaco',
username='abaco', ### NOTE: Must be abaco as it can generate tokens
account_type='service',
service_password=service_password,
service_password=test_abaco_service_password,
jwt=jwt,
resource_set=resource_set,
custom_spec_dict=custom_spec_dict,
Expand Down

0 comments on commit bcef1a5

Please sign in to comment.