-
Notifications
You must be signed in to change notification settings - Fork 25
WIP: Handling of merge-index-image for containerized IIB #1263
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
base: main
Are you sure you want to change the base?
Conversation
Reviewer's GuideRefactors merge-index-image bundle-diff logic into a reusable helper and introduces a new containerized merge task that drives an IIB/Konflux-based FBC merge workflow, wiring the new Celery task into the merge API and worker config. Sequence diagram for the new containerized merge-index-image workflowsequenceDiagram
actor User
participant API as IIB_API
participant Celery as Celery_Broker
participant Worker as Celery_Worker
participant Git as Git_Server
participant Reg as Container_Registry
participant Konflux as Konflux_Pipeline
participant IIBReg as IIB_Registry
User->>API: POST /api/v1/merge_index_image
API->>Celery: handle_containerized_merge_request.apply_async(args)
Celery->>Worker: Dispatch handle_containerized_merge_request
Worker->>Worker: reset_docker_config()
Worker->>Worker: set_request_state(preparing_request_for_merge)
Worker->>Worker: prepare_request_for_build(RequestConfigMerge)
Worker->>Worker: Opm.set_opm_version(target_index_resolved)
Worker->>Worker: _update_index_image_build_state()
Worker->>Git: resolve_git_url(source_from_index)
Git-->>Worker: index_git_repo
Worker->>Git: clone_git_repo(index_git_repo, branch)
Git-->>Worker: local_git_repo_path
Worker->>Worker: get_hidden_index_database(source_from_index_resolved)
Worker->>Worker: get_hidden_index_database(target_index_resolved)
Worker->>Worker: _get_present_bundles(source_index_db)
Worker->>Worker: _get_present_bundles(target_index_db)
Worker->>Worker: spawn ValidateBundlesThread for source bundles
Worker->>Worker: spawn ValidateBundlesThread for target bundles
Worker->>Reg: skopeo_inspect(bundle_pullspec) * N
Reg-->>Worker: bundle exists or error
Worker->>Worker: join all ValidateBundlesThread
Worker->>Worker: set_request_state(adding_missing_bundles)
Worker->>Worker: get_missing_bundles_from_target_to_source(...)
Worker->>Worker: add_max_ocp_version_property(missing_bundle_paths)
Worker->>Worker: intermediary_db = _get_or_create_temp_index_db_file()
Worker->>Worker: _opm_registry_add(intermediary_db, missing_bundle_paths)
Worker->>Worker: get_bundles_from_deprecation_list()
Worker->>Worker: get_bundles_latest_version()
loop deprecate in chunks
Worker->>Worker: opm_registry_deprecatetruncate(intermediary_db, chunk)
end
Worker->>Worker: bundles_in_db = get_list_bundles(intermediary_db)
Worker->>Worker: operators_in_db = [bundle.packageName]
Worker->>Worker: fbc_dir = opm_migrate(intermediary_db)
Worker->>Worker: merge_catalogs_dirs(catalog_from_db, git_catalog)
Worker->>Worker: opm_validate(fbc_dir)
Worker->>Worker: write_build_metadata(local_git_repo_path,...)
alt overwrite_target_index_token is not set
Worker->>Git: create_mr(request_id, local_git_repo_path,...)
Git-->>Worker: mr_details
else overwrite_target_index_token is set
Worker->>Git: commit_and_push(local_git_repo_path,...)
end
Worker->>Git: last_commit_sha = get_last_commit_sha()
Worker->>Konflux: find_pipelinerun(last_commit_sha)
Konflux-->>Worker: pipelinerun
Worker->>Konflux: wait_for_pipeline_completion(pipelinerun_name)
Konflux-->>Worker: run (succeeded)
Worker->>Konflux: get_pipelinerun_image_url(pipelinerun_name, run)
Konflux-->>Worker: image_url
Worker->>Worker: output_pull_specs = get_list_of_output_pullspec(request_id, build_tags)
loop for each output_pull_spec
Worker->>IIBReg: _skopeo_copy(docker://image_url, docker://output_pull_spec)
end
Worker->>Worker: _update_index_image_pull_spec(..., output_pull_spec,...)
Worker->>IIBReg: push_index_db_artifact(intermediary_db, operators_in_db)
IIBReg-->>Worker: original_index_db_digest
alt MR was created
Worker->>Git: close_mr(mr_details)
end
Worker->>Worker: set_request_state(complete, success_message)
Celery-->>API: async completion via DB/state
User-->>API: Poll request status
API-->>User: Final merged index image pullspec
Class diagram for new containerized merge task and helpersclassDiagram
class ValidateBundlesThread {
+Queue bundles_queue
+Exception exception
+__init__(bundles_queue)
+run() void
}
class Thread {
<<abstract>>
+start() void
+join() void
+run() void
}
ValidateBundlesThread --|> Thread
class BuildContainerizedMergeModule {
+handle_containerized_merge_request(source_from_index, deprecation_list, request_id, binary_image, target_index, overwrite_target_index, overwrite_target_index_token, distribution_scope, binary_image_config, build_tags, graph_update_mode, ignore_bundle_ocp_version, index_to_gitlab_push_map, parallel_threads) void
}
class BuildMergeIndexImageModule {
+get_missing_bundles_from_target_to_source(source_index_bundles, target_index_bundles, source_from_index, ocp_version, target_index, ignore_bundle_ocp_version) (List~BundleImage~, List~BundleImage~)
}
class RequestConfigMerge {
+_binary_image : str
+overwrite_target_index_token : str
+source_from_index : str
+target_index : str
+distribution_scope : str
+binary_image_config : str
}
class Opm {
+opm_version : str
+set_opm_version(target_index) void
}
class GitUtils {
+resolve_git_url(from_index, index_repo_map) str
+clone_git_repo(repo_url, branch, token_name, git_token, dest_path) void
+create_mr(request_id, local_repo_path, repo_url, branch, commit_message) Dict
+commit_and_push(request_id, local_repo_path, repo_url, branch, commit_message) void
+close_mr(mr_details, repo_url) void
+get_last_commit_sha(local_repo_path) str
+get_git_token(repo_url) (str, str)
}
class KonfluxUtils {
+find_pipelinerun(commit_sha) List
+wait_for_pipeline_completion(pipelinerun_name) Dict
+get_pipelinerun_image_url(pipelinerun_name, run) str
}
class ContainerizedUtils {
+write_build_metadata(repo_path, opm_version, ocp_version, distribution_scope, binary_image, request_id) void
+get_list_of_output_pullspec(request_id, build_tags) List~str~
+cleanup_on_failure(mr_details, last_commit_sha, index_git_repo, overwrite_from_index, request_id, from_index, index_repo_map, original_index_db_digest, reason) void
+push_index_db_artifact(request_id, from_index, index_db_path, operators, operators_in_db, overwrite_from_index, request_type) str
}
class BuildTasks {
+_update_index_image_build_state(request_id, prebuild_info) void
+_get_present_bundles(index_db_path, base_dir) (List~BundleImage~, List~str~)
+_update_index_image_pull_spec(output_pull_spec, request_id, arches, from_index, overwrite_from_index, overwrite_from_index_token, resolved_prebuild_from_index, add_or_rm, is_image_fbc, index_repo_map) void
+_skopeo_copy(source, destination, copy_all, exc_msg) void
}
class OpMOperations {
+_opm_registry_add(base_dir, index_db, bundles) void
+_get_or_create_temp_index_db_file(base_dir, from_index) str
+opm_registry_deprecatetruncate(base_dir, index_db, bundles) void
+opm_migrate(index_db, base_dir) (str, str)
+opm_validate(fbc_dir_path) void
+get_list_bundles(index_db, base_dir) List
+get_hidden_index_database(from_index, base_dir) str
}
class Utils {
+prepare_request_for_build(request_id, request_config) Dict
+request_logger
+add_max_ocp_version_property(bundle_paths, base_dir) void
+reset_docker_config() void
+skopeo_inspect(image, option, return_json) str
+get_bundles_from_deprecation_list(all_bundles, deprecation_list) List~str~
}
class FBCUtils {
+merge_catalogs_dirs(catalog_from_db, catalog_from_git) void
}
class Config {
+get_worker_config() Config
+iib_deprecate_bundles_limit : int
}
BuildContainerizedMergeModule ..> ValidateBundlesThread : uses
BuildContainerizedMergeModule ..> BuildMergeIndexImageModule : calls get_missing_bundles_from_target_to_source
BuildContainerizedMergeModule ..> RequestConfigMerge : constructs
BuildContainerizedMergeModule ..> Opm : sets opm_version
BuildContainerizedMergeModule ..> GitUtils : git operations
BuildContainerizedMergeModule ..> KonfluxUtils : pipeline operations
BuildContainerizedMergeModule ..> ContainerizedUtils : metadata, artifacts
BuildContainerizedMergeModule ..> BuildTasks : index image tasks
BuildContainerizedMergeModule ..> OpMOperations : index.db operations
BuildContainerizedMergeModule ..> Utils : helpers
BuildContainerizedMergeModule ..> FBCUtils : merge catalogs
BuildContainerizedMergeModule ..> Config : deprecate_bundles_limit
Config ..> ContainerizedUtils
OpMOperations ..> BuildTasks
Utils ..> BuildTasks
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
| 'in_progress', | ||
| 'Retrieving the bundles on index.db from source and target index images', | ||
| ) | ||
| source_index_db_path = get_hidden_index_database(source_from_index_resolved, temp_dir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory we should not use this. Because there is no hidden db anymore.
You need to pull both db files as artifacts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The source and target index images are useless - meaning we just take the OCP version from it and that's it. And it is done based on LABEL I believe.
The sqlite database is in registry and catalog is in gitlab repo.
Handling of merge-index-image for containerized IIB Refers to CLOUDDST-29408 Signed-off-by: Jonathan Gangi <[email protected]> Assisted-by: Cursor/Gemini
0781cd7 to
3b7f85d
Compare
Work in Progress - This is a draft!
Handling of merge-index-image for containerized IIB
Refers to CLOUDDST-29408
Signed-off-by: Jonathan Gangi [email protected]
Assisted-by: Cursor/Gemini
Summary by Sourcery
Introduce a containerized workflow for merge-index-image requests and refactor bundle-diff logic for reuse.
New Features:
Enhancements: