Skip to content

Commit

Permalink
Merge branch 'master' into rhel-oval-deprecation
Browse files Browse the repository at this point in the history
* upstream/master: (39 commits)
  Bump sqlalchemy from 2.0.35 to 2.0.36
  Bump pyfakefs from 5.7.0 to 5.7.1
  Bump fastapi from 0.115.0 to 0.115.2
  Bump uvicorn from 0.31.0 to 0.32.0
  Create new event loop for tests (AlmaLinux/build-system#367)
  Fix x86_64_v2 repos for ALK10
  Fixed setting up proxy while bootstraping repositories
  Update urls
  - Change export path for almalinux-kitten-10
  - Renave extras repo to extras-common
  Preparing errata bulk releases for UI (AlmaLinux/build-system#325)
  - Adding force parameter to bulk releases errata
  - Setting IN_PROGRESS status in router
  - black formatting
  Add ability to add new platforms to the product (#1008)
  Bump aiohttp from 3.10.9 to 3.10.10
  Bump pyfakefs from 5.6.0 to 5.7.0
  Bug fixes in the product-exporter script
  Bump black from 24.8.0 to 24.10.0
  Bump sentry-sdk[fastapi] from 2.15.0 to 2.16.0
  Fix path appending in the products-exporter script
  Add ppc64le repository for EPEL-7 flavor
  Add ppc64le repos for CentOS7 platform.
  Bump aiohttp from 3.10.8 to 3.10.9
  ...
  • Loading branch information
javihernandez committed Oct 23, 2024
2 parents d36ac66 + 4fb4ee6 commit 0bf9aa8
Show file tree
Hide file tree
Showing 24 changed files with 1,302 additions and 756 deletions.
67 changes: 50 additions & 17 deletions alws/crud/errata.py
Original file line number Diff line number Diff line change
Expand Up @@ -2146,24 +2146,17 @@ async def bulk_new_errata_records_release(
# TODO: Maybe check whether all ids were released
logging.info("All records successfully released: %s", records_ids)

async def bulk_errata_records_release(records_ids: List[str]):

async def bulk_errata_records_release(
records_ids: List[str], force: bool = False
):
pulp = PulpClient(
settings.pulp_host,
settings.pulp_user,
settings.pulp_password,
)
release_tasks = []
repos_to_publish = []
async with open_async_session(key=get_async_db_key()) as session:
await session.execute(
update(models.NewErrataRecord)
.where(models.NewErrataRecord.id.in_(records_ids))
.values(
release_status=ErrataReleaseStatus.IN_PROGRESS,
last_release_log=None,
)
)

async with open_async_session(key=get_async_db_key()) as session:
session: AsyncSession
db_records = await session.execute(
Expand Down Expand Up @@ -2194,7 +2187,9 @@ async def bulk_errata_records_release(records_ids: List[str]):
(
repo_mapping,
missing_pkg_names,
) = get_albs_packages_from_record(db_record, pulp_packages)
) = get_albs_packages_from_record(
db_record, pulp_packages, force
)
except Exception as exc:
db_record.release_status = ErrataReleaseStatus.FAILED
db_record.last_release_log = str(exc)
Expand Down Expand Up @@ -2362,7 +2357,9 @@ async def get_updateinfo_xml_from_pulp(
return cr_upd.xml_dump() if cr_upd.updates else None


async def prepare_resetting(items_to_insert: List, record: models.NewErrataRecord, session: AsyncSession):
async def prepare_resetting(
items_to_insert: List, record: models.NewErrataRecord, session: AsyncSession
):
search_params = prepare_search_params(record)
prod_repos_cache = await load_platform_packages(
platform=record.platform,
Expand Down Expand Up @@ -2415,7 +2412,9 @@ async def reset_matched_errata_packages(record_id: str, session: AsyncSession):
await session.flush()


async def get_errata_records_threshold(issued_date_str: str, session: AsyncSession):
async def get_errata_records_threshold(
issued_date_str: str, session: AsyncSession
):
issued_date = datetime.datetime.strptime(
issued_date_str, '%Y-%m-%d %H:%M:%S'
)
Expand All @@ -2442,7 +2441,7 @@ async def get_errata_records_threshold(issued_date_str: str, session: AsyncSessi


async def reset_matched_erratas_packages_threshold(
issued_date: str,
issued_date: str,
):
async with open_async_session(key=get_async_db_key()) as session:
records = await get_errata_records_threshold(issued_date, session)
Expand All @@ -2451,5 +2450,39 @@ async def reset_matched_erratas_packages_threshold(
await prepare_resetting(items_to_insert, record, session)
session.add_all(items_to_insert)
await session.flush()
logging.info(f'Packages for records {[record.id for record in records]}'
f' have been matched if their date is later than {issued_date}')
logging.info(
f'Packages for records {[record.id for record in records]}'
f' have been matched if their date is later than {issued_date}'
)


async def set_errata_packages_in_progress(
records_ids: List[str],
session: AsyncSession,
):
db_records = await session.execute(
select(models.NewErrataRecord).where(
models.NewErrataRecord.id.in_(records_ids)
)
)
records = db_records.scalars().all()
records_to_update = [
record.id
for record in records
if record.release_status != ErrataReleaseStatus.IN_PROGRESS
]
skipped_records = [
record.id
for record in records
if record.release_status == ErrataReleaseStatus.IN_PROGRESS
]
if records_to_update:
await session.execute(
update(models.NewErrataRecord)
.where(models.NewErrataRecord.id.in_(records_to_update))
.values(
release_status=ErrataReleaseStatus.IN_PROGRESS,
last_release_log=None,
)
)
return records_to_update, skipped_records
Loading

0 comments on commit 0bf9aa8

Please sign in to comment.