mirror of
https://github.com/microsoft/onefuzz.git
synced 2025-06-15 19:38:11 +00:00
Disable storageclient logs when setting admins (#1304)
This commit is contained in:
@ -562,12 +562,14 @@ class Client:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def apply_migrations(self) -> None:
|
def apply_migrations(self) -> None:
|
||||||
|
logger.info("applying database migrations")
|
||||||
name = self.results["deploy"]["func-name"]["value"]
|
name = self.results["deploy"]["func-name"]["value"]
|
||||||
key = self.results["deploy"]["func-key"]["value"]
|
key = self.results["deploy"]["func-key"]["value"]
|
||||||
table_service = TableService(account_name=name, account_key=key)
|
table_service = TableService(account_name=name, account_key=key)
|
||||||
migrate(table_service, self.migrations)
|
migrate(table_service, self.migrations)
|
||||||
|
|
||||||
def set_instance_config(self) -> None:
|
def set_instance_config(self) -> None:
|
||||||
|
logger.info("setting instance config")
|
||||||
name = self.results["deploy"]["func-name"]["value"]
|
name = self.results["deploy"]["func-name"]["value"]
|
||||||
key = self.results["deploy"]["func-key"]["value"]
|
key = self.results["deploy"]["func-key"]["value"]
|
||||||
tenant = UUID(self.results["deploy"]["tenant_id"]["value"])
|
tenant = UUID(self.results["deploy"]["tenant_id"]["value"])
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import json
|
import json
|
||||||
|
import logging
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
@ -12,12 +13,32 @@ from azure.common.client_factory import get_client_from_cli_profile
|
|||||||
from azure.cosmosdb.table.tableservice import TableService
|
from azure.cosmosdb.table.tableservice import TableService
|
||||||
from azure.mgmt.storage import StorageManagementClient
|
from azure.mgmt.storage import StorageManagementClient
|
||||||
|
|
||||||
|
storage_client_logger = logging.getLogger("azure.cosmosdb.table.common.storageclient")
|
||||||
TABLE_NAME = "InstanceConfig"
|
TABLE_NAME = "InstanceConfig"
|
||||||
|
|
||||||
|
|
||||||
|
## Disable logging from storageclient. This module displays an error message
|
||||||
|
## when a resource is not found even if the exception is raised and handled internally.
|
||||||
|
## This happen when a table does not exist. An error message is displayed but the exception is
|
||||||
|
## handled by the library.
|
||||||
|
def disable_storage_client_logging() -> None:
|
||||||
|
if storage_client_logger:
|
||||||
|
storage_client_logger.disabled = True
|
||||||
|
|
||||||
|
|
||||||
|
def enable_storage_client_logging() -> None:
|
||||||
|
if storage_client_logger:
|
||||||
|
storage_client_logger.disabled = False
|
||||||
|
|
||||||
|
|
||||||
def create_if_missing(table_service: TableService) -> None:
|
def create_if_missing(table_service: TableService) -> None:
|
||||||
if not table_service.exists(TABLE_NAME):
|
try:
|
||||||
table_service.create_table(TABLE_NAME)
|
disable_storage_client_logging()
|
||||||
|
|
||||||
|
if not table_service.exists(TABLE_NAME):
|
||||||
|
table_service.create_table(TABLE_NAME)
|
||||||
|
finally:
|
||||||
|
enable_storage_client_logging()
|
||||||
|
|
||||||
|
|
||||||
def update_allowed_aad_tenants(
|
def update_allowed_aad_tenants(
|
||||||
|
Reference in New Issue
Block a user