Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Be more explicit and concise during automation run #1249

Merged
merged 2 commits into from
Jul 24, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions daemon/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package daemon

import (
"context"
"fmt"

"github.com/go-kit/kit/log"
"github.com/pkg/errors"
Expand Down Expand Up @@ -41,28 +42,35 @@ func (d *Daemon) pollForNewImages(logger log.Logger) {
changes := &update.Automated{}
for _, service := range services {
for _, container := range service.ContainersOrNil() {
logger := log.With(logger, "service", service.ID, "container", container.Name, "currentimage", container.Image)

currentImageID := container.Image
if err != nil {
logger.Log("error", err)
continue
}

This comment was marked as abuse.

This comment was marked as abuse.


pattern := policy.GetTagPattern(candidateServicesPolicyMap, service.ID, container.Name)
repo := currentImageID.Name
logger.Log("repo", repo, "pattern", pattern)
logger := log.With(logger, "service", service.ID, "container", container.Name, "repo", repo, "pattern", pattern, "current", currentImageID)

filteredImages := imageRepos.GetRepoImages(repo).Filter(pattern)

if latest, ok := filteredImages.Latest(); ok && latest.ID != currentImageID {
if latest.ID.Tag == "" {
logger.Log("msg", "untagged image in available images", "action", "skip", "available", repo)
logger.Log("warning", "untagged image in available images", "action", "skip")
continue
}
if latest.CreatedAt.IsZero() {

This comment was marked as abuse.

This comment was marked as abuse.

logger.Log("warning", "image with zero created timestamp", "action", "skip")
continue
}
newImage := currentImageID.WithNewTag(latest.ID.Tag)
changes.Add(service.ID, container, newImage)
logger.Log("msg", "added image to changes", "newimage", newImage)
currentCreatedAt := ""
for _, info := range filteredImages {
if info.ID == currentImageID {
currentCreatedAt = info.CreatedAt.String()
}
}
if currentCreatedAt == "" {
currentCreatedAt = "filtered out or missing"
logger.Log("warning", "current image not in filtered images", "action", "add")
}
logger.Log("info", "added update to automation run", "new", newImage, "reason", fmt.Sprintf("latest %s (%s) > current %s (%s)", latest.ID.Tag, latest.CreatedAt, currentImageID.Tag, currentCreatedAt))
}
}
}
Expand Down