More explicit massage if manifest not found (#94)

This commit is contained in:
CrazyMax
2020-06-20 02:50:18 +02:00
parent db2bce3bb3
commit 9146b78111
5 changed files with 35 additions and 37 deletions

View File

@@ -18,21 +18,23 @@ $ docker-compose exec diun --test-notif
If you have the error `failed to decode configuration from file: field docker uses unsupported type: invalid` that's because your `docker`, `swarm` or `kubernetes` provider is not initialized in your configuration: If you have the error `failed to decode configuration from file: field docker uses unsupported type: invalid` that's because your `docker`, `swarm` or `kubernetes` provider is not initialized in your configuration:
```yaml !!! failure
providers: ```yaml
docker: providers:
``` docker:
```
should be: should be:
```yaml !!! success
providers: ```yaml
docker: {} providers:
``` docker: {}
```
## No image found in manifest list for architecture, variant, OS ## No image found in manifest list for architecture, variant, OS
If you encounter this kind of error, you are probably using the [file provider](providers/file.md) containing an image with an erroneous or empty platform. If the platform is not filled in, it will be deduced automatically from the information of your operating system on which Diun is running. If you encounter this kind of warning, you are probably using the [file provider](providers/file.md) containing an image with an erroneous or empty platform. If the platform is not filled in, it will be deduced automatically from the information of your operating system on which Diun is running.
In the example below, Diun is running (`diun_x.x.x_windows_i386.zip`) on Windows 10 and tries to analyze the `crazymax/cloudflared` image with the detected platform (`windows/386)`: In the example below, Diun is running (`diun_x.x.x_windows_i386.zip`) on Windows 10 and tries to analyze the `crazymax/cloudflared` image with the detected platform (`windows/386)`:
@@ -43,12 +45,10 @@ In the example below, Diun is running (`diun_x.x.x_windows_i386.zip`) on Windows
But this platform is not supported by this image as you can see [on DockerHub](https://hub.docker.com/layers/crazymax/cloudflared/2020.2.1/images/sha256-137eea4e84ec4c6cb5ceb2017b9788dcd7b04f135d756e1f37e3e6673c0dd9d2?context=explore): But this platform is not supported by this image as you can see [on DockerHub](https://hub.docker.com/layers/crazymax/cloudflared/2020.2.1/images/sha256-137eea4e84ec4c6cb5ceb2017b9788dcd7b04f135d756e1f37e3e6673c0dd9d2?context=explore):
``` !!! warning
Fri, 27 Mar 2020 01:20:03 UTC ERR Cannot run job error="Error choosing image instance: no image found in manifest list for architecture 386, variant , OS windows" provider=file `Fri, 27 Mar 2020 01:20:03 UTC WRN Cannot get remote manifest error="Cannot create image closer: Error choosing image instance: no image found in manifest list for architecture 386, variant \"\", OS windows" image=docker.io/image=crazymax/cloudflared:2020.2.1 provider=file`
Fri, 27 Mar 2020 01:20:03 UTC ERR Cannot list tags from registry error="Error choosing image instance: no image found in manifest list for architecture 386, variant , OS windows" image=crazymax/cloudflared:2020.2.1 provider=file
```
You have to force the platform for this image if you are not on a supported platform. For example: You have to force the platform for this image if you are not on a supported platform:
```yaml ```yaml
- name: crazymax/cloudflared:2020.2.1 - name: crazymax/cloudflared:2020.2.1
@@ -58,6 +58,5 @@ You have to force the platform for this image if you are not on a supported plat
arch: amd64 arch: amd64
``` ```
``` !!! success
Fri, 27 Mar 2020 01:24:33 UTC INF New image found image=docker.io/crazymax/cloudflared:2020.2.1 provider=file `Fri, 27 Mar 2020 01:24:33 UTC INF New image found image=docker.io/crazymax/cloudflared:2020.2.1 provider=file`
```

View File

@@ -105,11 +105,7 @@ func (di *Diun) Run() {
di.wg = new(sync.WaitGroup) di.wg = new(sync.WaitGroup)
di.pool, _ = ants.NewPoolWithFunc(di.cfg.Watch.Workers, func(i interface{}) { di.pool, _ = ants.NewPoolWithFunc(di.cfg.Watch.Workers, func(i interface{}) {
job := i.(model.Job) job := i.(model.Job)
if err := di.runJob(job); err != nil { di.runJob(job)
log.Error().Err(err).
Str("provider", job.Provider).
Msg("Cannot run job")
}
di.wg.Done() di.wg.Done()
}, ants.WithLogger(new(logging.AntsLogger))) }, ants.WithLogger(new(logging.AntsLogger)))
defer di.pool.Release() defer di.pool.Release()

View File

@@ -137,7 +137,7 @@ func (di *Diun) createJob(job model.Job) {
} }
} }
func (di *Diun) runJob(job model.Job) error { func (di *Diun) runJob(job model.Job) {
sublog := log.With(). sublog := log.With().
Str("provider", job.Provider). Str("provider", job.Provider).
Str("image", job.RegImage.String()). Str("image", job.RegImage.String()).
@@ -145,20 +145,22 @@ func (di *Diun) runJob(job model.Job) error {
if !utl.IsIncluded(job.RegImage.Tag, job.Image.IncludeTags) { if !utl.IsIncluded(job.RegImage.Tag, job.Image.IncludeTags) {
sublog.Warn().Msg("Tag not included") sublog.Warn().Msg("Tag not included")
return nil return
} else if utl.IsExcluded(job.RegImage.Tag, job.Image.ExcludeTags) { } else if utl.IsExcluded(job.RegImage.Tag, job.Image.ExcludeTags) {
sublog.Warn().Msg("Tag excluded") sublog.Warn().Msg("Tag excluded")
return nil return
} }
liveManifest, err := job.Registry.Manifest(job.RegImage) liveManifest, err := job.Registry.Manifest(job.RegImage)
if err != nil { if err != nil {
return err sublog.Warn().Err(err).Msg("Cannot get remote manifest")
return
} }
dbManifest, err := di.db.GetManifest(job.RegImage) dbManifest, err := di.db.GetManifest(job.RegImage)
if err != nil { if err != nil {
return err sublog.Error().Err(err).Msg("Cannot get manifest from db")
return
} }
status := model.ImageStatusUnchange status := model.ImageStatusUnchange
@@ -170,17 +172,18 @@ func (di *Diun) runJob(job model.Job) error {
sublog.Info().Msg("Image update found") sublog.Info().Msg("Image update found")
} else { } else {
sublog.Debug().Msg("No changes") sublog.Debug().Msg("No changes")
return nil return
} }
if err := di.db.PutManifest(job.RegImage, liveManifest); err != nil { if err := di.db.PutManifest(job.RegImage, liveManifest); err != nil {
return err sublog.Error().Err(err).Msg("Cannot write manifest to db")
return
} }
sublog.Debug().Msg("Manifest saved to database") sublog.Debug().Msg("Manifest saved to database")
if job.FirstCheck && !*di.cfg.Watch.FirstCheckNotif { if job.FirstCheck && !*di.cfg.Watch.FirstCheckNotif {
sublog.Debug().Msg("Skipping notification (first check)") sublog.Debug().Msg("Skipping notification (first check)")
return nil return
} }
di.notif.Send(model.NotifEntry{ di.notif.Send(model.NotifEntry{
@@ -189,6 +192,4 @@ func (di *Diun) runJob(job model.Job) error {
Image: job.RegImage, Image: job.RegImage,
Manifest: liveManifest, Manifest: liveManifest,
}) })
return nil
} }

View File

@@ -6,6 +6,7 @@ import (
"github.com/containers/image/v5/manifest" "github.com/containers/image/v5/manifest"
"github.com/opencontainers/go-digest" "github.com/opencontainers/go-digest"
"github.com/pkg/errors"
) )
// Manifest is the Docker image manifest information // Manifest is the Docker image manifest information
@@ -28,23 +29,23 @@ func (c *Client) Manifest(image Image) (Manifest, error) {
imgCloser, err := c.newImage(ctx, image.String()) imgCloser, err := c.newImage(ctx, image.String())
if err != nil { if err != nil {
return Manifest{}, err return Manifest{}, errors.Wrap(err, "Cannot create image closer")
} }
defer imgCloser.Close() defer imgCloser.Close()
rawManifest, _, err := imgCloser.Manifest(ctx) rawManifest, _, err := imgCloser.Manifest(ctx)
if err != nil { if err != nil {
return Manifest{}, err return Manifest{}, errors.Wrap(err, "Cannot get raw manifest")
} }
imgInspect, err := imgCloser.Inspect(ctx) imgInspect, err := imgCloser.Inspect(ctx)
if err != nil { if err != nil {
return Manifest{}, err return Manifest{}, errors.Wrap(err, "Cannot inspect")
} }
imgDigest, err := manifest.Digest(rawManifest) imgDigest, err := manifest.Digest(rawManifest)
if err != nil { if err != nil {
return Manifest{}, err return Manifest{}, errors.Wrap(err, "Cannot get digest")
} }
imgTag := imgInspect.Tag imgTag := imgInspect.Tag

View File

@@ -8,6 +8,7 @@ import (
"github.com/containers/image/v5/docker" "github.com/containers/image/v5/docker"
"github.com/containers/image/v5/types" "github.com/containers/image/v5/types"
"github.com/pkg/errors"
) )
// Client represents an active docker registry object // Client represents an active docker registry object
@@ -71,7 +72,7 @@ func (c *Client) newImage(ctx context.Context, imageStr string) (types.ImageClos
ref, err := docker.ParseReference(imageStr) ref, err := docker.ParseReference(imageStr)
if err != nil { if err != nil {
return nil, fmt.Errorf("invalid image name %s: %v", imageStr, err) return nil, errors.Wrap(err, "Invalid image name")
} }
img, err := ref.NewImage(ctx, c.sysCtx) img, err := ref.NewImage(ctx, c.sysCtx)