Fix regression with local mode push

PR #1749 introduced a bug when pushing local target state. An update to
the [image name normalization](f1bd4b8d9b/src/lib/docker-utils.ts (L81))
failed to consider the local image name format. This results in mangling
of image names in the database, i.e. the image `ubuntu:latest` is stored
as `/ubuntu:latest`. This causes an exception to be returned by the
dockerode `getImage('/ubuntu:latest').inspect()` call.

This sends the supervisor into a crash loop and is shown on the supervisor
journal logs as

```
getaddrinfo ENOTFOUND images
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:64:26)
```

Unfortunately if this happens on a user device, since the mangled image
name is already on the database, the easiest way to fix is to remove the
supervisor database and let the supervisor recreate it. Deleting the
database should be side effect free.

Change-type: patch
This commit is contained in:
Felipe Lalanne 2021-08-01 23:02:44 -04:00
parent 0df979be55
commit 6f5f3bc2f3
2 changed files with 4 additions and 2 deletions

View File

@ -674,7 +674,9 @@ function saveAndRemoveImages(
(svc) =>
_.find(availableImages, {
dockerImageId: svc.config.image,
name: svc.imageName,
// There is no 1-1 mapping between services and images
// on disk, so the only way to compare is by imageId
imageId: svc.imageId,
}) ?? _.find(availableImages, { dockerImageId: svc.config.image }),
),
) as imageManager.Image[];

View File

@ -80,7 +80,7 @@ export function getRegistryAndName(uri: string): ImageNameParts {
// Normalise an image name to always have a tag, with :latest being the default
export function normaliseImageName(image: string) {
const { registry, imageName, tagName, digest } = getRegistryAndName(image);
const repository = [registry, imageName].join('/');
const repository = [registry, imageName].filter((s) => !!s).join('/');
if (!digest) {
return [repository, tagName || 'latest'].join(':');