-
Notifications
You must be signed in to change notification settings - Fork 191
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
[OCIRepository] Optimise OCI artifacts reconciliation #913
Merged
Conversation
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
hiddeco
reviewed
Sep 23, 2022
stefanprodan
force-pushed
the
oci-copy-layer
branch
from
September 23, 2022 15:54
8c59fd7
to
983d399
Compare
Add on optional field to the `OCIRepository.spec.layerSelector` called `operation` that accepts one of the following values: `extract` or `copy`. When the operation is set to `copy`, instead of extracting the compressed layer, the controller copies the compressed blob as it is to storage, thus keeping the original content unaltered. Signed-off-by: Stefan Prodan <[email protected]>
stefanprodan
force-pushed
the
oci-copy-layer
branch
from
September 23, 2022 16:00
983d399
to
4ec51ca
Compare
- Fetch the upstream digest before validation and pulling - Pull artifact only if the upstream digest is different from the one in storage - Add the image tag to the revision string `<tag>/<digest-hex>` for a better UX - Extract the layer processing to a dedicated function Signed-off-by: Stefan Prodan <[email protected]>
stefanprodan
changed the title
[OCIRepository] Add option to copy the OCI layer to storage
[OCIRepository] Optimise OCI artifacts reconciliation
Sep 24, 2022
hiddeco
reviewed
Sep 26, 2022
stefanprodan
force-pushed
the
oci-copy-layer
branch
from
September 26, 2022 10:24
27ca62c
to
543b8ff
Compare
hiddeco
approved these changes
Sep 26, 2022
Signed-off-by: Stefan Prodan <[email protected]>
stefanprodan
force-pushed
the
oci-copy-layer
branch
from
September 26, 2022 10:30
543b8ff
to
3f7d463
Compare
I think I found a bug in this. spec:
interval: 1m0s
layerSelector:
mediaType: application/vnd.docker.image.rootfs.diff.tar.gzip
operation: copy
provider: generic
ref:
tag: 6.1.6
timeout: 60s
url: oci://ghcr.io/stefanprodan/manifests/podinfo
status:
artifact:
checksum: ad804afeae14a8a5c9a45b29f4931104a887844691d040c8737ee3cce6fd6735
lastUpdateTime: "2022-09-26T15:33:27Z"
metadata:
org.opencontainers.image.created: "2022-08-08T12:31:25+03:00"
org.opencontainers.image.revision: 6.1.6/450796ddb2ab6724ee1cc32a4be56da032d1cca0
org.opencontainers.image.source: https://github.com/stefanprodan/podinfo.git
path: ocirepository/default/podinfo-layer/dbdb109711ffb3be77504d2670dbe13c24dd63d8d7f1fb489d350e5bfe930dd3.tar.gz
revision: 6.1.6/dbdb109711ffb3be77504d2670dbe13c24dd63d8d7f1fb489d350e5bfe930dd3
size: 1091
url: http://source-controller.flux-system.svc.cluster.local./ocirepository/default/podinfo-layer/dbdb109711ffb3be77504d2670dbe13c24dd63d8d7f1fb489d350e5bfe930dd3.tar.gz
conditions:
- lastTransitionTime: "2022-09-26T15:33:27Z"
message: stored artifact for digest '6.1.6/dbdb109711ffb3be77504d2670dbe13c24dd63d8d7f1fb489d350e5bfe930dd3'
observedGeneration: 1
reason: Succeeded
status: "True"
type: Ready
- lastTransitionTime: "2022-09-26T15:33:27Z"
message: stored artifact for digest '6.1.6/dbdb109711ffb3be77504d2670dbe13c24dd63d8d7f1fb489d350e5bfe930dd3'
observedGeneration: 1
reason: Succeeded
status: "True"
type: ArtifactInStorage
observedGeneration: 1
url: http://source-controller.flux-system.svc.cluster.local./ocirepository/default/podinfo-layer/latest.tar.gz Note the spec:
interval: 1m0s
layerSelector:
mediaType: application/vnd.docker.image.rootfs.diff.tar.gzip
operation: extract
provider: generic
ref:
tag: 6.1.6
timeout: 60s
url: oci://ghcr.io/stefanprodan/manifests/podinfo
status:
artifact:
checksum: ad804afeae14a8a5c9a45b29f4931104a887844691d040c8737ee3cce6fd6735
lastUpdateTime: "2022-09-26T15:33:27Z"
metadata:
org.opencontainers.image.created: "2022-08-08T12:31:25+03:00"
org.opencontainers.image.revision: 6.1.6/450796ddb2ab6724ee1cc32a4be56da032d1cca0
org.opencontainers.image.source: https://github.com/stefanprodan/podinfo.git
path: ocirepository/default/podinfo-layer/dbdb109711ffb3be77504d2670dbe13c24dd63d8d7f1fb489d350e5bfe930dd3.tar.gz
revision: 6.1.6/dbdb109711ffb3be77504d2670dbe13c24dd63d8d7f1fb489d350e5bfe930dd3
size: 1091
url: http://source-controller.flux-system.svc.cluster.local./ocirepository/default/podinfo-layer/dbdb109711ffb3be77504d2670dbe13c24dd63d8d7f1fb489d350e5bfe930dd3.tar.gz
conditions:
- lastTransitionTime: "2022-09-26T15:33:27Z"
message: stored artifact for digest '6.1.6/dbdb109711ffb3be77504d2670dbe13c24dd63d8d7f1fb489d350e5bfe930dd3'
observedGeneration: 2
reason: Succeeded
status: "True"
type: Ready
- lastTransitionTime: "2022-09-26T15:33:27Z"
message: stored artifact for digest '6.1.6/dbdb109711ffb3be77504d2670dbe13c24dd63d8d7f1fb489d350e5bfe930dd3'
observedGeneration: 2
reason: Succeeded
status: "True"
type: ArtifactInStorage
observedGeneration: 2
url: http://source-controller.flux-system.svc.cluster.local./ocirepository/default/podinfo-layer/latest.tar.gz The checksum remains the same although the new generation of the object has been reconciled successfully, gen 2. But if I create a new object from scratch with extract operation: spec:
interval: 1m0s
layerSelector:
mediaType: application/vnd.docker.image.rootfs.diff.tar.gzip
operation: extract
provider: generic
ref:
tag: 6.1.6
timeout: 60s
url: oci://ghcr.io/stefanprodan/manifests/podinfo
status:
artifact:
checksum: d7e924b4882e55b97627355c7b3d2e711e9b54303afa2f50c25377f4df66a83b
lastUpdateTime: "2022-09-26T15:36:19Z"
metadata:
org.opencontainers.image.created: "2022-08-08T12:31:25+03:00"
org.opencontainers.image.revision: 6.1.6/450796ddb2ab6724ee1cc32a4be56da032d1cca0
org.opencontainers.image.source: https://github.com/stefanprodan/podinfo.git
path: ocirepository/default/podinfo-layer/dbdb109711ffb3be77504d2670dbe13c24dd63d8d7f1fb489d350e5bfe930dd3.tar.gz
revision: 6.1.6/dbdb109711ffb3be77504d2670dbe13c24dd63d8d7f1fb489d350e5bfe930dd3
size: 1105
url: http://source-controller.flux-system.svc.cluster.local./ocirepository/default/podinfo-layer/dbdb109711ffb3be77504d2670dbe13c24dd63d8d7f1fb489d350e5bfe930dd3.tar.gz
conditions:
- lastTransitionTime: "2022-09-26T15:36:19Z"
message: stored artifact for digest '6.1.6/dbdb109711ffb3be77504d2670dbe13c24dd63d8d7f1fb489d350e5bfe930dd3'
observedGeneration: 1
reason: Succeeded
status: "True"
type: Ready
- lastTransitionTime: "2022-09-26T15:36:19Z"
message: stored artifact for digest '6.1.6/dbdb109711ffb3be77504d2670dbe13c24dd63d8d7f1fb489d350e5bfe930dd3'
observedGeneration: 1
reason: Succeeded
status: "True"
type: ArtifactInStorage
observedGeneration: 1
url: http://source-controller.flux-system.svc.cluster.local./ocirepository/default/podinfo-layer/latest.tar.gz That's the actual checksum of the extracted content of the artifact. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Improvements
<tag>/<digest-hex>
for a better UX.OCIRepository.spec.layerSelector
calledoperation
that accepts one of the following values:extract
orcopy
. When the operation is set tocopy
, instead of extracting the compressed layer, the controller copies the compressed blob as-is to storage, thus keeping the original content unaltered.WIP Proposal
If we chose to add OCIRepository as a source to HelmReleases, then we'll enable chart verification (cosgin + keyless), insecure registries which are blocked upstream in Helm, reuse of the same chart between multiple HelmReleases, and easier debugging experience (no more hidden HelmChart objects, nor HelmRepositories).
With
.spec.layerSelector
Flux is compatible with package managers which bundle in the same OCI artifact an app container image with a helm chart, Flux will pick only the chart layer based on the specified media type and will copy the chart tarball to storage for helm-controller to consume.Example of an OCIRepository which produces valid and verified Helm charts:
Example of how a HelmRelease using the OCIRepository could look like: