Skip to content

Conversation

@agrasth
Copy link
Contributor

@agrasth agrasth commented Jun 3, 2025

  • All tests passed. If this feature is not already covered by the tests, I added new tests.
  • All static analysis checks passed.
  • This pull request is on the dev branch.
  • I used gofmt for formatting the code before submitting the pull request.

Virtual Repository Layer Filtering Optimization

Description

This PR introduces an optimization for handling Docker image layers in virtual repositories. The enhancement focuses on filtering layers to only include those from the default deployment repository when setting build properties, improving performance and reducing unnecessary operations.

Changes

  • Added new function filterLayersForVirtualRepository to efficiently filter image layers
  • Added repository configuration fetching functionality
  • Improved logging for better debugging and transparency
  • Added proper error handling for repository configuration retrieval
  • Optimized the layer filtering process to only process necessary layers

Technical Details

  • The optimization checks if the repository is virtual before processing layers
  • For virtual repositories, it filters layers to only include those from the default deployment repository
  • For non-virtual repositories, it maintains the existing behavior
  • Added proper error handling and logging for better observability
  • Implemented repository configuration caching to avoid repeated API calls

Impact

  • Reduces unnecessary property setting operations for virtual repositories
  • Maintains backward compatibility with existing functionality
  • No breaking changes to the public API

@agrasth agrasth requested review from bhanurp and itsmeleela June 3, 2025 06:56
@agrasth agrasth force-pushed the feature/optimize-virtual-repo-layer-filtering branch from 8d37bc1 to b7e3e6d Compare June 3, 2025 07:43
@agrasth agrasth force-pushed the feature/optimize-virtual-repo-layer-filtering branch from b7e3e6d to 96fe58b Compare June 3, 2025 10:27
@agrasth agrasth force-pushed the feature/optimize-virtual-repo-layer-filtering branch from 96fe58b to dc4668b Compare June 10, 2025 08:47
@agrasth agrasth force-pushed the feature/optimize-virtual-repo-layer-filtering branch from dc4668b to 093be7f Compare June 10, 2025 09:24
@agrasth agrasth force-pushed the feature/optimize-virtual-repo-layer-filtering branch from 093be7f to 512633b Compare June 10, 2025 11:55
Copy link
Contributor

@bhanurp bhanurp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove all redundant comments and empty new lines in between code, for example the comment // Make the HTTP GET request is not required since it is obvious from code it is http get request

log.Info("Making API call for virtual repository", originalRepo, "to get DefaultDeploymentRepo")
repoConfig, err := getRepositoryConfiguration(originalRepo, serviceManager)
if err != nil {
log.Debug("Failed to get repository configuration for virtual repository", originalRepo, ":", err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the error returned should be enough why do we need debug you can add errorutils.CheckErrorf(err)

var filteredLayers []utils.ResultItem
for _, layer := range imageLayers {
if layer.Repo == repoConfig.DefaultDeploymentRepo {
filteredLayers = append(filteredLayers, layer)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it tags which are available in default deployment repo or is it layers of docker image?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's about layers of the Docker image, not tags.

@agrasth agrasth force-pushed the feature/optimize-virtual-repo-layer-filtering branch from 512633b to 9f3b145 Compare June 11, 2025 04:41
@agrasth agrasth force-pushed the feature/optimize-virtual-repo-layer-filtering branch from 9f3b145 to 05fa697 Compare June 11, 2025 04:44
@agrasth agrasth requested a review from bhanurp June 11, 2025 04:45
@agrasth agrasth merged commit 7d96134 into jfrog:dev Jun 11, 2025
6 of 7 checks passed
@agrasth agrasth added the improvement Automatically generated release notes label Jun 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Automatically generated release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants