-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support splitting blobs when stored as OCI layer (#1140)
<!-- markdownlint-disable MD041 --> #### What this PR does / why we need it There are OCI repositories with a layer size limitation. Because OCM potentially maps any external artifact to a single blob stored as layer on OCI registries, this could lead to problems. An obvious problematic scenario is the transport of a multi-platform OCI image. Its blob format is an archive containing all images and all layers of those images. This PR introduces the possibility to specify blob limits for OCI registries. The OCM-to-OCI mapping then splits larger blobs into multiple layers. The `localBlob` access method then uses a comma-separated list of blob layer-blob digest to remember the sequence of layers. The access then combines the layerblobs again to a single stream. #### Which issue(s) this PR fixes <!-- Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`. --> Fixes: open-component-model/ocm-project#12 A follow-up issue open-component-model/ocm-project#338 describes the provisioning of appropriate defaults for common public registries. --------- Co-authored-by: Jakob Möller <[email protected]>
- Loading branch information
1 parent
c2605cc
commit 2cb3187
Showing
12 changed files
with
732 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
api/ocm/extensions/repositories/genericocireg/bloblimits.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package genericocireg | ||
|
||
import ( | ||
"sync" | ||
|
||
configctx "ocm.software/ocm/api/config" | ||
"ocm.software/ocm/api/ocm/extensions/repositories/genericocireg/config" | ||
) | ||
|
||
var ( | ||
defaultBlobLimits config.BlobLimits | ||
lock sync.Mutex | ||
) | ||
|
||
const ( | ||
KB = int64(1000) | ||
MB = 1000 * KB | ||
GB = 1000 * MB | ||
) | ||
|
||
func init() { | ||
defaultBlobLimits = config.BlobLimits{} | ||
|
||
// Add limits for known OCI repositories, here, | ||
// or provide init functions in specialized packages | ||
// by calling AddDefaultBlobLimit. | ||
AddDefaultBlobLimit("ghcr.io", 10*GB) // https://github.com/orgs/community/discussions/77429 | ||
} | ||
|
||
// AddDefaultBlobLimit can be used to set default blob limits | ||
// for known repositories. | ||
// Those limits will be overwritten, by blob limits | ||
// given by a configuration object and the repository | ||
// specification. | ||
func AddDefaultBlobLimit(name string, limit int64) { | ||
lock.Lock() | ||
defer lock.Unlock() | ||
|
||
defaultBlobLimits[name] = limit | ||
} | ||
|
||
func ConfigureBlobLimits(ctx configctx.ContextProvider, target config.Configurable) { | ||
if target != nil { | ||
lock.Lock() | ||
defer lock.Unlock() | ||
|
||
target.ConfigureBlobLimits(defaultBlobLimits) | ||
|
||
if ctx != nil { | ||
ctx.ConfigContext().ApplyTo(0, target) | ||
} | ||
} | ||
} |
Oops, something went wrong.