Skip to content

Add a LastTagTime for images#31497

Merged
thaJeztah merged 1 commit intomoby:masterfrom
dnephin:engine-local-image-data
Jun 27, 2017
Merged

Add a LastTagTime for images#31497
thaJeztah merged 1 commit intomoby:masterfrom
dnephin:engine-local-image-data

Conversation

@dnephin
Copy link
Copy Markdown
Member

@dnephin dnephin commented Mar 2, 2017

Implements proposal #25728

Comment thread api/swagger.yaml Outdated
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.

format: "dateTime"?

@thaJeztah
Copy link
Copy Markdown
Member

I'm not sure about this; my worry is that there's no relation whatsoever with the actual image. This keeps track of when the build command is last executed, but not when the image is last updated, which seems completely separate.

Take the following example;

$ docker build -t foo -<<EOF
FROM busybox
RUN date > /lastupdated
EOF

Sending build context to Docker daemon  2.048kB
Step 1/2 : FROM busybox
 ---> 7968321274dc
Step 2/2 : RUN date > /lastupdated
 ---> Running in 256bcc697e92
 ---> a678cb68731c
Removing intermediate container 256bcc697e92
Successfully built a678cb68731c

Inspecting the image;

$ docker inspect -f '{{.LastUpdated}}' foo
2017-03-06T12:59:26.91289454Z

Building the image again will use the cache, so no image is built;

$ docker build -t foo -<<EOF
FROM busybox
RUN date > /lastupdated
EOF

Sending build context to Docker daemon  2.048kB
Step 1/2 : FROM busybox
 ---> 7968321274dc
Step 2/2 : RUN date > /lastupdated
 ---> Using cache
 ---> a678cb68731c
Successfully built a678cb68731c

But LastUpdated gives the impression that the image has been updated;

$ docker inspect -f '{{.LastUpdated}}' foo
2017-03-06T13:01:55.397159895Z

If we go this direction, I would also prefer that the "metadata" that's separate from the actual image would be in a separate "struct" in the inspect output. Perhaps we want to add more metadata that's independent from the image (the lengthy discussions about labels that can be set without altering the actual image)

@dnephin
Copy link
Copy Markdown
Member Author

dnephin commented Mar 6, 2017

This keeps track of when the build command is last executed, but not when the image is last updated, which seems completely separate.

True, so I guess I need to either:

  • change the field name to lastBuildTime
  • also set lastUpdated when an image is pulled (and maybe also change the field name to something else)

I prefer the second. What do you think?

I would also prefer that the "metadata" that's separate from the actual image would be in a separate "struct" in the inspect output.

That seems reasonable, Parent is already mixed in, so I copied that, but it is probably a good idea to fix that now instead of continue with the pattern.

@dnephin dnephin force-pushed the engine-local-image-data branch from 12c5c90 to 1cfa5a9 Compare March 8, 2017 16:45
@tiborvass
Copy link
Copy Markdown
Contributor

If this is about the last time it was tagged, maybe we shouldn't call it last build time :)

@dnephin dnephin changed the title Add a LastUpdated time for images Add a LastTagTime for images Mar 14, 2017
@dnephin dnephin force-pushed the engine-local-image-data branch from 1cfa5a9 to bd6f431 Compare March 14, 2017 22:18
@dnephin
Copy link
Copy Markdown
Member Author

dnephin commented Mar 14, 2017

Changed it to LastTagTime

@thaJeztah
Copy link
Copy Markdown
Member

I would also prefer that the "metadata" that's separate from the actual image would be in a separate "struct" in the inspect output.

@dnephin did you have a look at making that change? I think others agreed on this when we were discussing

@dnephin
Copy link
Copy Markdown
Member Author

dnephin commented Mar 24, 2017

I've made that change

@dnephin dnephin force-pushed the engine-local-image-data branch from 8dc6e2d to c6ee84f Compare March 24, 2017 16:28
Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

design LGTM, but left a question

Comment thread api/types/types.go Outdated
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.

should this have omitempty? Also wondering why it's not using time.Time (as we use in other places), e.g.;

UpdatedAt time.Time `json:",omitempty"`

Copy link
Copy Markdown
Member Author

@dnephin dnephin Mar 31, 2017

Choose a reason for hiding this comment

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

Added omitempty and changed to time.Time.

Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

@thaJeztah
Copy link
Copy Markdown
Member

ping @tiborvass PTAL

@cpuguy83
Copy link
Copy Markdown
Member

Needs a rebase, but LGTM.

@thaJeztah thaJeztah force-pushed the engine-local-image-data branch from 8d61245 to 0496029 Compare June 26, 2017 18:47
@thaJeztah
Copy link
Copy Markdown
Member

I rebased (because it was only the api-chances), but looks like it needed more changes due to 3aa4a00#diff-1ed32f2ce4c90e536bbbb9ede729120c (#33241) being merged; these are the changes I added;

diff --git a/daemon/image_inspect.go b/daemon/image_inspect.go
index a2b1d59..3baf265 100644
--- a/daemon/image_inspect.go
+++ b/daemon/image_inspect.go
@@ -61,7 +61,7 @@ func (daemon *Daemon) LookupImage(name string) (*types.ImageInspect, error) {
 		comment = img.History[len(img.History)-1].Comment
 	}

-	lastUpdated, err := daemon.imageStore.GetLastUpdated(img.ID())
+	lastUpdated, err := daemon.stores[platform].imageStore.GetLastUpdated(img.ID())
 	if err != nil {
 		return nil, err
 	}
diff --git a/daemon/image_tag.go b/daemon/image_tag.go
index 4516c5e..5f28dae 100644
--- a/daemon/image_tag.go
+++ b/daemon/image_tag.go
@@ -32,7 +32,7 @@ func (daemon *Daemon) TagImageWithReference(imageID image.ID, platform string, n
 		return err
 	}

-	if err := daemon.imageStore.SetLastUpdated(imageID); err != nil {
+	if err := daemon.stores[platform].imageStore.SetLastUpdated(imageID); err != nil {
 		return err
 	}
 	daemon.LogImageEvent(imageID.String(), reference.FamiliarString(newTag), "tag")

ping @cpuguy83 @johnstep PTAL

@thaJeztah
Copy link
Copy Markdown
Member

ugh; more work to do 😅

@thaJeztah thaJeztah added the status/failing-ci Indicates that the PR in its current state fails the test suite label Jun 26, 2017
@thaJeztah
Copy link
Copy Markdown
Member

thaJeztah commented Jun 26, 2017

Culprit was due to 6052f2b (#32614). I'll push an update

diff --git a/image/store_test.go b/image/store_test.go
index 87101cb..fc6d461 100644
--- a/image/store_test.go
+++ b/image/store_test.go
@@ -154,16 +154,16 @@ func TestGetAndSetLastUpdated(t *testing.T) {
        defer cleanup()

        id, err := store.Create([]byte(`{"comment": "abc1", "rootfs": {"type": "layers"}}`))
-       assert.NilError(t, err)
+       assert.NoError(t, err)

        updated, err := store.GetLastUpdated(id)
-       assert.NilError(t, err)
+       assert.NoError(t, err)
        assert.Equal(t, updated.IsZero(), true)

-       assert.NilError(t, store.SetLastUpdated(id))
+       assert.NoError(t, store.SetLastUpdated(id))

        updated, err = store.GetLastUpdated(id)
-       assert.NilError(t, err)
+       assert.NoError(t, err)
        assert.Equal(t, updated.IsZero(), false)
 }

@thaJeztah thaJeztah force-pushed the engine-local-image-data branch from 0496029 to 016eea0 Compare June 26, 2017 19:16
@thaJeztah thaJeztah removed the status/failing-ci Indicates that the PR in its current state fails the test suite label Jun 26, 2017
Copy link
Copy Markdown
Member

@johnstep johnstep left a comment

Choose a reason for hiding this comment

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

LGTM

@thaJeztah thaJeztah merged commit 8f3c526 into moby:master Jun 27, 2017
@dnephin dnephin deleted the engine-local-image-data branch June 29, 2017 17:19
thaJeztah added a commit to thaJeztah/cli that referenced this pull request Jul 2, 2017
Includes changes from;

- Add a LastTagTime for images (moby/moby#31497)
- Fix handling of remote "git@" notation (moby/moby#33696)
- Move some `api` package functions away (moby/moby#33798) (related to docker#236)
- Set ping version even on error (moby/moby#33827)
- Do not add duplicate platform information to service spec (moby/moby#33867)
- Refactor MountPoint Setup function in volume.go (moby/moby#33890)

Signed-off-by: Sebastiaan van Stijn <[email protected]>
thaJeztah added a commit to thaJeztah/cli that referenced this pull request Jul 3, 2017
Includes changes from;

- Add a LastTagTime for images (moby/moby#31497)
- Fix handling of remote "git@" notation (moby/moby#33696)
- Move some `api` package functions away (moby/moby#33798) (related to docker#236)
- Set ping version even on error (moby/moby#33827)
- Do not add duplicate platform information to service spec (moby/moby#33867)
- Refactor MountPoint Setup function in volume.go (moby/moby#33890)

Signed-off-by: Sebastiaan van Stijn <[email protected]>
thaJeztah added a commit to thaJeztah/cli that referenced this pull request Jul 5, 2017
Includes changes from;

- Add a LastTagTime for images (moby/moby#31497)
- Fix handling of remote "git@" notation (moby/moby#33696)
- Move some `api` package functions away (moby/moby#33798) (related to docker#236)
- Set ping version even on error (moby/moby#33827)
- Do not add duplicate platform information to service spec (moby/moby#33867)
- Refactor MountPoint Setup function in volume.go (moby/moby#33890)

Signed-off-by: Sebastiaan van Stijn <[email protected]>
andrewhsu pushed a commit to docker-archive/docker-ce that referenced this pull request Jul 14, 2017
Includes changes from;

- Add a LastTagTime for images (moby/moby#31497)
- Fix handling of remote "git@" notation (moby/moby#33696)
- Move some `api` package functions away (moby/moby#33798) (related to docker/cli#236)
- Set ping version even on error (moby/moby#33827)
- Do not add duplicate platform information to service spec (moby/moby#33867)
- Refactor MountPoint Setup function in volume.go (moby/moby#33890)

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Upstream-commit: 366d3ec971d8007c667e8d7dc8e35a346fb19539
Component: cli
alshabib pushed a commit to alshabib/cli that referenced this pull request Aug 1, 2017
Includes changes from;

- Add a LastTagTime for images (moby/moby#31497)
- Fix handling of remote "git@" notation (moby/moby#33696)
- Move some `api` package functions away (moby/moby#33798) (related to docker#236)
- Set ping version even on error (moby/moby#33827)
- Do not add duplicate platform information to service spec (moby/moby#33867)
- Refactor MountPoint Setup function in volume.go (moby/moby#33890)

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants