Skip to content
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

chore: better ingest logging + reduce debug logspam #117

Merged
merged 1 commit into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion chord_drs/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
"logger",
]

logging.basicConfig(level=logging.DEBUG)
logging.basicConfig(level=logging.NOTSET)

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)

# Remove `DEBUG:asyncio:Using selector: EpollSelector` spam
logging.getLogger("asyncio").setLevel(logging.INFO)
# Remove `DEBUG:urllib3.connectionpool:Starting new HTTPS connection` spam
logging.getLogger("urllib3.connectionpool").setLevel(logging.INFO)
19 changes: 14 additions & 5 deletions chord_drs/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,8 @@ def object_ingest():
public: bool = data.get("public", "false").strip().lower() == "true"
file = request.files.get("file")

logger.info(f"Received ingest request metadata: {data}")

# This authz call determines everything, so we can mark authz as done when the call completes:
has_permission: bool = (
authz_middleware.evaluate_one(
Expand Down Expand Up @@ -415,19 +417,26 @@ def object_ingest():
candidate_drs_object: DrsBlob | None = DrsBlob.query.filter_by(checksum=checksum).first()

if candidate_drs_object is not None:
c_project_id = candidate_drs_object.project_id
c_dataset_id = candidate_drs_object.dataset_id
c_data_type = candidate_drs_object.data_type
c_public = candidate_drs_object.public

if (
candidate_drs_object.project_id == project_id
and candidate_drs_object.dataset_id == dataset_id
and candidate_drs_object.data_type == data_type
and candidate_drs_object.public == public
c_project_id == project_id
and c_dataset_id == dataset_id
and c_data_type == data_type
and c_public == public
):
logger.info(
f"Found duplicate DRS object via checksum (will fully deduplicate): {candidate_drs_object}"
)
drs_object = candidate_drs_object
else:
logger.info(
f"Found duplicate DRS object via checksum (will deduplicate JUST bytes): "
f"Found duplicate DRS object via checksum (will deduplicate JUST bytes; req resource: "
f"({project_id}, {dataset_id}, {data_type}, {public}) vs existing resource: "
f"({c_project_id}, {c_dataset_id}, {c_data_type}, {c_public})): "
f"{candidate_drs_object}"
)
object_to_copy = candidate_drs_object
Expand Down