Skip to content

Commit

Permalink
update err handling
Browse files Browse the repository at this point in the history
  • Loading branch information
RockfordMankiniUCSD committed Oct 8, 2024
1 parent 8191929 commit b39c264
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions src/dsmlp/app/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,20 @@ def validate_pod(self, request: Request):

### if tgpt-validator == enabled
### run special tritongpt validator that gets permitted UIDs from namespace instead of sicad

try:
namespace = self.kube.get_namespace(request.namespace)
tgpt_label = self.kube.get_tgpt_label(namespace)

if(self.kube.get_tgpt_label(namespace) == "enabled"):
self.logger.info("Triton GPT Mode Activated. Only running TritonGPT Validator.")
TritonGPTValidator(self.kube, self.logger).validate_pod(request)
return
except Exception as err:
self.logger.exception(err)
self.logger.info("Failed to evaluate TGPT label logic. Falling back on regular validator components. Error: " + str(err))
for component_validator in self.component_validators:
component_validator.validate_pod(request)

if(tgpt_label == "enabled"):
self.logger.info("Triton GPT Mode Activated. Only running TritonGPT Validator.")
TritonGPTValidator(self.kube, self.logger).validate_pod(request)
return

for component_validator in self.component_validators:
component_validator.validate_pod(request)
Expand Down
2 changes: 1 addition & 1 deletion tests/app/test_tgpt_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def test_bad_request(self):
)

assert_that(self.logger.messages, has_item(
f"EXCEPTION TritonGPT Validator: user with access to UIDs ['30', '3000'] attempted to run a pod as 300. Pod denied."))
f"INFO Denied request username=system:kube-system namespace=user10 reason=TritonGPT Validator: user with access to UIDs ['30', '3000'] attempted to run a pod as 300. Pod denied. uid=705ab4f5-6393-11e8-b7cc-42010a800002"))

def test_good_request_not_enabled_permitted_on(self):
self.when_validate(
Expand Down

0 comments on commit b39c264

Please sign in to comment.