Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(docker): Parse date into Instant when using sortTagsByDate #6137

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

wwalters12
Copy link

Potential fix for spinnaker/spinnaker#6921

I know this feature isn't recommend (spinnaker/spinnaker#5538), but we have a small repository we are caching and sorting the tags for it would be nice.

We are using Redis and the date value is cached as a string:

bash-4.4# redis-cli --scan --pattern dockerRegistry:taggedImage:attributes:dockerRegistry:taggedImage:**** | xargs redis-cli mget
1) "{\"account\":\"***\",\"date\":\"2024-01-08T15:23:15.280797435Z\",\"name\":\"***\"}"

With this change, the date value will be parsed to an Instant if the date is cached as a String.

@dbyron-sf
Copy link
Contributor

Looks like there are some build failures to resolve. Could you look into adding an automated test for this please, and ideally explaining how info shows up as instants vs. strings?

@wwalters12
Copy link
Author

Looks like there are some build failures to resolve. Could you look into adding an automated test for this please, and ideally explaining how info shows up as instants vs. strings?

@dbyron-sf Added a missing import, that should fix the build. And yes, I'll look into adding a test to verify the tags can be sorted if the date is stored as a String or Instant.

I think the previous change to this fixed the functionality for using a SQL cache (#5098) where the image date is stored as a map with the key epochSecond, but when using a Redis cache the date is stored as a string.

I'm also realizing this means using the epochSecond key is incorrect as this will still break if the date is stored as a string instead of a map. I'll fix that and get a test added in the next commit.

@jasonmcintosh
Copy link
Member

@wwalters12 did you get a chance to work on any of this? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants