Skip to content

Restorable apps#120

Merged
mike-sul merged 16 commits intomasterfrom
feat/restorable-apps
Sep 27, 2021
Merged

Restorable apps#120
mike-sul merged 16 commits intomasterfrom
feat/restorable-apps

Conversation

@mike-sul
Copy link
Copy Markdown
Contributor

  • Use skopeo to pull images from Registry(ies);
  • Store apps&images' data (manifests, blobs, etc) in dedicated folder/volume in addition to /var/lib/docker and /var/sota/compose-apps;
  • Use skopeo to copy images from the restorable app store to the docker store (`/var/lib/docker');
  • If /var/lib/docker and /var/sota/compose-apps are removed then Apps&images are restored from the local store.

@mike-sul
Copy link
Copy Markdown
Contributor Author

Corresponding changes to meta-lmp foundriesio/meta-lmp#429

Copy link
Copy Markdown
Member

@doanac doanac left a comment

Choose a reason for hiding this comment

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

I think most of the comments were fixed as I kept reading on in the PR. The biggest thing I found missing was a little more info in a couple of the commit messages about what was happening on the filesystem.

I'm pull this onto a test device and kick the tires today.

Comment thread src/docker/restorableappengine.cc Outdated
Comment thread src/docker/restorableappengine.cc Outdated
LOG_ERROR << image_uri;

const Uri uri{Uri::parseUri(image_uri)};
const std::string tag{uri.registryHostname + '/' + uri.repo + ':' + uri.digest.shortHash()};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

shortHash scares me cause it its just a fixed slice of the first $x character. It could have collisions. I guess its pretty safe in this context. Just want to double check it makes sense here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is just an image tag. It doesn't play any functional role, it could be an empty as it is now or any other random value.
Unfortunately, skopeo doesn't allow to specify "destination" by using the full sha256 (@sha256:<>), what actually leads to unnecessary fetch of a newly exported/loaded image manifest by the docker daemon regardless of the image presence in the docker store. It's not critical since just a manifest is fetched, but I'll try to fix/improve on the next iteration, it will require patching of the skopeo or even dockers source code.

var/rootdirs/home/fio# cat /var/lib/docker/image/overlay2/repositories.json | jq
{
  "Repositories": {
    "hub.foundries.io/msul-dev01/app-05": {
      "hub.foundries.io/msul-dev01/app-05:5f80d09": "sha256:36264a214873ebd01966c95be4c53ae879f67361a5ae5c2b89dc14faf3b0b760",
      "hub.foundries.io/msul-dev01/app-05@sha256:5f80d09611ee4f0ba07e7318f9c2970a2d8d0ca84e187e99eae971189a207a71": "sha256:36264a214873ebd01966c95be4c53ae879f67361a5ae5c2b89dc14faf3b0b760"
    }
  }
}

The first record "hub.foundries.io/msul-dev01/app-05:5f80d09" is added by aklite/skopeo, the second is added by dockerd. Once we teach skopeo/dockerd to accept the full sha256 hash (not just a tag) then we will eliminate the unnecessary image manifest pull.

Comment thread src/docker/restorableappengine.cc Outdated
Comment thread src/docker/restorableappengine.cc
Comment thread src/docker/restorableappengine.cc
Comment thread src/composeappmanager.h
Comment thread src/docker/restorableappengine.cc Outdated
@mike-sul
Copy link
Copy Markdown
Contributor Author

root@raspberrypi4-64:/var/sota# tree reset-apps/
reset-apps/
|-- apps
|   |-- app-05
|   |   `-- 32a0309bbc1ab28a81fcd012a53f7e2075633b711e75b38c8e2aecaa361aaab6
|   |       |-- 4a7c02f3267e2b92c0d1d78432acf611906b70964df8e27ab7d4c6f835efdcad.tgz
|   |       |-- docker-compose.yml
|   |       |-- images
|   |       |   `-- hub.foundries.io
|   |       |       `-- msul-dev01
|   |       |           `-- app-05
|   |       |               `-- 5f80d09611ee4f0ba07e7318f9c2970a2d8d0ca84e187e99eae971189a207a71
|   |       |                   |-- blobs
|   |       |                   |-- index.json
|   |       |                   `-- oci-layout
|   |       `-- manifest.json
|   `-- app-07
|       `-- 3ce3d04d72aa25d31a8ddb6489818861c1082094ffc358fb38d74eccaf637b7c
|           |-- ae4d7690e4e2c189d550db57144abdd7a53477b9d89d7cba4d390371978e53a4.tgz
|           |-- docker-compose.yml
|           |-- images
|           |   |-- docker.io
|           |   |   `-- library
|           |   |       `-- nginx
|           |   |           `-- a97eb9ecc708c8aa715ccfb5e9338f5456e4b65575daf304f108301f3b497314
|           |   |               |-- blobs
|           |   |               |-- index.json
|           |   |               `-- oci-layout
|           |   `-- hub.foundries.io
|           |       `-- msul-dev01
|           |           |-- app-07
|           |           |   `-- 3ee70a119a620086afbfa8705bf222edd09b9ae9d41653749752c04089cad21d
|           |           |       |-- blobs
|           |           |       |-- index.json
|           |           |       `-- oci-layout
|           |           `-- nginx
|           |               `-- c83ec3a0e87e2f3039c8234b157381af41081d42109bb35f418b851356e5e846
|           |                   |-- blobs
|           |                   |-- index.json
|           |                   `-- oci-layout
|           `-- manifest.json
`-- blobs
    `-- sha256
        |-- 03513b8933dacfb95cb1d00fc4846b0c28686aba484b00ef5409ae368e83c922
        |-- 068614b905e936c8385dfe78226faa7329858b327edb0236eadd1f1c7d0903f8
        |-- 06ade89b14b08b385b7add0a1c420a11d7840018ef39e96da50912076a94b580
        |-- 0fef6ea0df27793b9f4c29c5532d42d82a22db9b46d5420712c33ad3279850c3
        |-- 1934397b2d60a56a8d1f00f010ea90482a0d07bacb0fb11faaa157b0173a09e5
        |-- 36264a214873ebd01966c95be4c53ae879f67361a5ae5c2b89dc14faf3b0b760
        |-- 38b063c012a18ae561a278be4b06d811ac853cb162e974e4294ee49ded650450
        |-- 3a9dae124c1e06f7b5b3206f48a716c76b3761fd119f3aeba564ac5c0febb293
        |-- 552370ba0ff87e7bd1875774b62e68b97966b7c81716de7bf84962c5133df24f
        |-- 60f1a9e09753825c7f40ef8fc8b171aac00fe637b14f753fec607e24d26635b5
        |-- 66942047c7b3b1e4cfa170855e791fffb10e70e4061f5d20cdf3d712b1d9ba79
        |-- 677498ef6ce0d06a2bcf9a637bad274e0c6ce7360dfc0531db4bf0d0d9840636
        |-- 6c96e371c1ec89645799581c2326662ff1fa432b1ad012359d2dfde4e5685c61
        |-- 836a8c2b8815affbbd8c0c1e8bde3d6a77b336e2171db263b929771dee2ee23d
        |-- 86ade662cda571f878ef3c7f9a69bb8649b60974fa25680948cad5ab16cac36b
        |-- 8bfe4843495e56e3546d4d49cf476ee7bc1650156062151aa38cf3e2fb397a70
        |-- 8d99a3e08d0f07ca0fdf1db5c56b1f30d9cc97af5458ecfac604b8887cba289a
        |-- b02ff6364805794937c1e44c3729d10340e274142740dd693963deb6c35a6116
        |-- b538f80385f9b48122e3da068c932a96ea5018afa3c7be79da00437414bd18cd
        |-- c223065212e836d8e54e480f4c8e0a978393f15db88bc4413fd921ba6e9b325e
        |-- d81823b5c9b536108c620f3c7b371517e997a25caa8495ef8cb040a17a1eb8be
        |-- ecf68cc49fc15307388a7e4c968ba76e9c05de65e238c595cb9a8fff318ea6b2
        `-- f0599ed267cb750a3c0ebeb55004b5a818b7e9a7e8071b49e687d11349556868

@mike-sul
Copy link
Copy Markdown
Contributor Author

root@raspberrypi4-64:/var/sota# tree compose-apps/
compose-apps/
`-- app-05
    |-- Dockerfile
    `-- docker-compose.yml

root@raspberrypi4-64:/var/sota# docker images -a
REPOSITORY                           TAG       IMAGE ID       CREATED         SIZE
hub.foundries.io/msul-dev01/app-05   5f80d09   36264a214873   11 months ago   89.2MB

root@raspberrypi4-64:/var/sota# docker ps -a
CONTAINER ID   IMAGE                                COMMAND                  CREATED        STATUS       PORTS                                   NAMES
694d0d216896   hub.foundries.io/msul-dev01/app-05   "/bin/sh -c 'python …"   23 hours ago   Up 2 hours   0.0.0.0:9986->80/tcp, :::9986->80/tcp   app-05_python-www_1

config

compose_apps = "app-05"
reset_apps = "app-05,app-07"

Comment thread src/docker/restorableappengine.cc Outdated
@mike-sul mike-sul force-pushed the feat/restorable-apps branch 2 times, most recently from 01cdf9c to 4648e38 Compare September 24, 2021 13:03
Copy link
Copy Markdown
Member

@doanac doanac left a comment

Choose a reason for hiding this comment

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

looks good.

Use the the same test suite for testing aklite configured with
ComposeAppEngine and RestorableAppEngine.

Signed-off-by: Mike Sul <[email protected]>
Make use of the restorable app engine if `reset_apps` are set in
configuration. Make sure aklite checks and pulls an union of reset and
compose apps.

Signed-off-by: Mike Sul <[email protected]>
Properly remove Apps&images for both use-cases, composeapp and
restorableapp engines.

Signed-off-by: Mike Sul <[email protected]>
@mike-sul mike-sul force-pushed the feat/restorable-apps branch from 4648e38 to dcd5f81 Compare September 24, 2021 15:08
@mike-sul
Copy link
Copy Markdown
Contributor Author

looks good.

@doanac So, I think, it's ready to be merged. This is corresponding changes to meta-lmp foundriesio/meta-lmp#429.

@mike-sul mike-sul merged commit 2dcfde0 into master Sep 27, 2021
@mike-sul mike-sul deleted the feat/restorable-apps branch July 14, 2023 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants