Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.

Relocation the right way #765

Merged
merged 5 commits into from
Nov 28, 2019

Conversation

eunomie
Copy link
Member

@eunomie eunomie commented Nov 25, 2019

- What I did

Copy the relocation map in a dedicated file and apply it at runtime in the invocation image instead of modifying the service definition in the Installation object.

See https://github.com/cnabio/cnab-spec/blob/master/103-bundle-runtime.md#image-relocation

- How I did it

The relocation map is now stored under /cnab/app/relocation-mapping.json when we run commands.
Then the cnab-run binary will read it, apply it on top of the service image definition.

Note: the /cnab/app/image-map.json is not read anymore, all data already exist in /cnab/bundle.json

- How to verify it

Without this version

When you run a pulled App, read the installation file (under ~/.docker/app/installation/.../appname.json). The image definition should contains relocated images (everything like registry/repo:tag@sha256...)

With this version

When you run a pulled App (must be build using this version to have the right cnab-run binary) and look at the installation file, the service images must not be the relocated ones but the one in the bundle.json.
But if you inspect the App Image, you should see the relocated images.

- Description for the changelog

@codecov
Copy link

codecov bot commented Nov 25, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@e890e66). Click here to learn what that means.
The diff coverage is 58.33%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #765   +/-   ##
=========================================
  Coverage          ?   69.68%           
=========================================
  Files             ?       64           
  Lines             ?     3612           
  Branches          ?        0           
=========================================
  Hits              ?     2517           
  Misses            ?      766           
  Partials          ?      329
Impacted Files Coverage Δ
internal/store/installation.go 78.12% <ø> (ø)
internal/commands/image/inspect.go 65.3% <0%> (ø)
internal/commands/image/render.go 69.49% <0%> (ø)
internal/commands/inspect.go 21.66% <0%> (ø)
internal/commands/remove.go 52.94% <0%> (ø)
internal/commands/run.go 63.73% <100%> (ø)
internal/commands/update.go 58.92% <100%> (ø)
internal/relocated/bundle.go 54.54% <36.36%> (ø)
internal/cnab/driver.go 77.5% <78.94%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e890e66...39c87cb. Read the comment docs.

@eunomie eunomie force-pushed the relocation-the-right-way branch 2 times, most recently from cc10716 to e80d4cb Compare November 26, 2019 14:48
Copy link
Contributor

@silvin-lubecki silvin-lubecki left a comment

Choose a reason for hiding this comment

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

LGTM with function renamed

Signed-off-by: Yves Brissaud <yves.brissaud@docker.com>
`cnab-go` adds two files to the invocation image:
- `/cnab/bundle.json`: containing the whole `bundle.json`
- `/cnab/app/image-map.json`: containing `Images` section of the bundle

As this second file is only an extract of the Bundle it can safely be removed.

The full removal needs to be done in `cnab-go`, here we only ignore it.

Signed-off-by: Yves Brissaud <yves.brissaud@docker.com>
Bundle definition -with service image definitions- is mounted under
`/cnab/bundle.json` in the invocation image.
If a `/cnab/app/relocation-mapping.json` exists read it and apply it
on top of image definitions.

See https://github.com/cnabio/cnab-spec/blob/master/103-bundle-runtime.md#image-relocation

Signed-off-by: Yves Brissaud <yves.brissaud@docker.com>
Embed the relocation map inside `/cnab/app/relocation-mapping.json`
and do not touch the bundle definition.

Signed-off-by: Yves Brissaud <yves.brissaud@docker.com>
Invocation image can be relocated. The relocation map about services is now applied
at runtime by `cnab-run`, when running inside the invocation image.

This change updates the invocation image definition in the `driver.Operation`
using the relocation map if exists. So that the image can be pulled and run.

Signed-off-by: Yves Brissaud <yves.brissaud@docker.com>
@silvin-lubecki silvin-lubecki merged commit dc6d86d into docker:master Nov 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants