Skip to content

Commit

Permalink
Boto3 s3 client configuration and credentials
Browse files Browse the repository at this point in the history
We reuse the CephStore object from thoth-storages. However, it is
incomplete and we need to check some environment variables ourselves.
See thoth-station/storages#2717
  • Loading branch information
VannTen committed Oct 7, 2022
1 parent 3690f51 commit 405e73a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions thoth/document_sync/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@
from datetime import timedelta
from tempfile import NamedTemporaryFile
from typing import Optional
from boto3 import client

import click
from thoth.common import init_logging
from thoth.common import OpenShift
from thoth.storages import AnalysisByDigest
from thoth.storages import AnalysisResultsStore
from thoth.storages import SolverResultsStore
from thoth.storages import CephStore
from thoth.storages.result_base import ResultStorageBase

from prometheus_client import CollectorRegistry, Gauge, Counter, push_to_gateway
Expand Down Expand Up @@ -176,6 +178,17 @@ def sync(
start_date = date.today() - timedelta(days=days)
_LOGGER.info("Listing documents created since %r", start_date.isoformat())

src_config = CephStore(f"{os.getenv('THOTH_CEPH_BUCKET_PREFIX', '')}/{_THOTH_DEPLOYMENT_NAME}")
source = client(
"s3",
aws_access_key_id=src_config.key_id,
aws_secret_access_key=src_config.secret_key,
endpoint_url=src_config.host,
)
dest = client("s3") # Defaults to using same config discovery than aws-cli.
_LOGGER.debug("Source S3 client: %s", vars(source))
_LOGGER.debug("Dest S3 client: %s", vars(dest))

try:
for adapter_class in (AnalysisByDigest, AnalysisResultsStore):
_LOGGER.info("Listing %r documents", adapter_class.RESULT_TYPE)
Expand Down

0 comments on commit 405e73a

Please sign in to comment.