--- a/operator.go Thu Jun 18 03:02:03 2020 -0500
+++ b/operator.go Thu Jun 18 06:24:52 2020 -0500
@@ -198,21 +198,46 @@
-func (o *Operator) checkContainer(container corev1.Container, imageID string, images map[string]string) (bool, error) {
+func (o *Operator) checkContainer(container corev1.Container, imageID string, digests map[string]string) (bool, error) { // now that we know that the container has a ImagePullPolicy of
- // Always, we can check it's image.
- regImageID, found := images[container.Image]
+ // Always, we can check it's digest against the tags digest. + // look up the digest for the local version in k8s + if strings.HasPrefix(imageID, "docker-pullable://") { + parts := strings.SplitN(imageID, "@", 2) + localDigest, found := digests[imageID] - id, err := registryGetImageID(container.Image)
+ digest, err := registryGetDigest(container.Image, imageID) - images[container.Image] = id
+ digests[imageID] = digest - if !strings.HasSuffix(imageID, regImageID) {
- log.Infof("image id's differ, cycling pod: %s, %s", imageID, regImageID)
+ // now figure out the digest for what's on the registry + remoteDigest, found := digests[container.Image] + repo, tag := parseRepositoryAndTag(container.Image) + digest, err := registryGetDigest(repo, tag) + digests[container.Image] = digest + if localDigest != remoteDigest { + log.Infof("image digests differ, cycling pod: %s, %s", localDigest, remoteDigest) --- a/registry.go Thu Jun 18 03:02:03 2020 -0500
+++ b/registry.go Thu Jun 18 06:24:52 2020 -0500
@@ -1,21 +1,16 @@
"github.com/heroku/docker-registry-client/registry"
-func registryGetImageID(repository string) (string, error) {
+func registryGetDigest(repository, tag string) (string, error) { reg, err := registry.New("https://index.docker.io", "", "")
- repo, tag := parseRepositoryAndTag(repository)
- manifest, err := reg.ManifestV2(repo, tag)
- fmt.Printf("%#v\n", manifest)
+ manifest, err := reg.ManifestV2(repository, tag) return manifest.Config.Digest.String(), err