Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cake-bot
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Oleksandr Barabash
cake-bot
Commits
bf693ab9
Commit
bf693ab9
authored
Sep 08, 2022
by
Oleksandr Barabash
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
small fixes, health check added
parent
932acc60
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
4 deletions
+23
-4
app.py
app.py
+18
-1
config.py
config.py
+2
-1
azure_key_vault_client.py
utils/azure_key_vault_client.py
+3
-2
No files found.
app.py
View file @
bf693ab9
...
...
@@ -19,7 +19,7 @@ from marshmallow import ValidationError, EXCLUDE
from
bots
import
TeamsMessagingExtensionsActionPreviewBot
from
bots.exceptions
import
ConversationNotFound
,
DataParsingError
from
config
import
AppConfig
,
COSMOS_CLIENT
,
CosmosDBConfig
from
config
import
AppConfig
,
COSMOS_CLIENT
,
CosmosDBConfig
,
KEY_VAULT_CLIENT
from
entities.json.notification
import
Notification
,
NotificationCosmos
from
utils.cosmos_client
import
ItemNotFound
from
utils.json_func
import
json_loads
...
...
@@ -157,6 +157,23 @@ async def v1_health_check(_request: Request) -> Response:
""" Health check """
# TODO(s1z): Add checks here. DB, etc.
Log
.
i
(
TAG
,
"v1_health_check::ok"
)
key
=
None
container
=
None
try
:
container
=
await
COSMOS_CLIENT
.
get_conversations_container
()
key
=
await
KEY_VAULT_CLIENT
.
get_random_key
()
except
Exception
as
e
:
Log
.
e
(
TAG
,
"v1_health_check::error"
,
e
)
if
key
is
None
:
return
Response
(
status
=
HTTPStatus
.
INTERNAL_SERVER_ERROR
,
body
=
json
.
dumps
({
"error"
:
"Can't connect to KeyVault"
})
)
if
container
is
None
:
return
Response
(
status
=
HTTPStatus
.
INTERNAL_SERVER_ERROR
,
body
=
json
.
dumps
({
"error"
:
"Can't connect to CosmosDB"
})
)
return
Response
(
status
=
HTTPStatus
.
OK
)
...
...
config.py
View file @
bf693ab9
...
...
@@ -71,4 +71,5 @@ class CosmosDBConfig:
COSMOS_CLIENT
=
CosmosClient
(
CosmosDBConfig
.
HOST
,
CosmosDBConfig
.
KEY
)
KEYVAULT_CLIENT
=
AzureKeyVaultClient
(
AppConfig
.
CLIENT_ID
,
AppConfig
.
KEY_VAULT
)
KEY_VAULT_CLIENT
=
AzureKeyVaultClient
(
AppConfig
.
CLIENT_ID
,
AppConfig
.
KEY_VAULT
)
utils/azure_key_vault_client.py
View file @
bf693ab9
...
...
@@ -40,8 +40,9 @@ class AzureKeyVaultClient:
async
def
get_random_key_bl
(
self
)
->
KeyVaultKey
:
""" Blocking get random key """
keys
=
self
.
key_client
.
list_properties_of_keys
()
await
self
.
execute_blocking
(
self
.
key_client
.
list_properties_of_keys
)
keys
=
await
self
.
execute_blocking
(
self
.
key_client
.
list_properties_of_keys
)
all_keys
=
[]
for
key
in
keys
:
all_keys
.
append
(
key
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment