-
Notifications
You must be signed in to change notification settings - Fork 2
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: add annotations to ensure new docker image is downloaded #117
Conversation
e104bc2
to
7ae3c54
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this again I think this can be simplified.
The GetManifestDigest
func uses RemoteTag
internally and looking at the code I believe there is no need to persist the digest in the DockerImage
at all.
So imho you could just rename GetManifestDigest
to GetImageDigest
and return the whole RemoteTags()[digest]
and use it directly.
Of course doing this will make the test part harder but I would be ok not to have a test for now and write an integration test that only run on CI next.
@LucaLanziani I'm not really sure about this. In my understanding WDYT? |
@zaremba-tomasz digest is not part of The This to me is a clear indication of separation of concern, the |
7ae3c54
to
08117da
Compare
@LucaLanziani please take a look whether this is something you were thinking about. If so I'll test this locally and extend knative test as described during standup. |
08117da
to
2ce4cce
Compare
src/services/docker/docker.go
Outdated
|
||
func (ds DockerService) GetImageDigest() (string, error) { | ||
logger.PrintInfo("Getting manifest digest for " + ds.dockerImage.RemoteTag()) | ||
logger.PrintInfo("User: " + ds.AuthConfig.Username) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to check if the user is set here, since this is needed when pulling from a private registry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also just realised that this will fail if we pull from a private registry since we dont have any registry-user
registry-password
parameter in the deploy command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is getting to complicated, are you sure that a new revision will not pull the new image?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking at kn service update
behaviour it looks like they always create a new revision, should probably do the same here or even use the kn client library itself if we find an easy way to integrate it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks like they are using an annotation to do this knative/client#1364
I'm sorry @zaremba-tomasz but I'm thinking of dropping this and use the annotation approach :(
Here how to setup the annotation, we should probably use the same annotation to be compatible and eventually try to use their library for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually @zaremba-tomasz I was thinking that having a SHA of the commit that generated the change would be way more useful, the issue is when you run the CLI from your local machine and maybe you have uncommitted changes, at the point the value could be lastCommitSha-dirty
? https://mirrors.edge.kernel.org/pub/software/scm/git/docs/gitglossary.html#def_dirty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is getting to complicated, are you sure that a new revision will not pull the new image?
The initial issue was that, the subsequent push to the repository did not create new revision at all (most probably because manifest did not change).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually @zaremba-tomasz I was thinking that having a SHA of the commit that generated the change would be way more useful, the issue is when you run the CLI from your local machine and maybe you have uncommitted changes, at the point the value could be
lastCommitSha-dirty
? https://mirrors.edge.kernel.org/pub/software/scm/git/docs/gitglossary.html#def_dirty
The issue was not related to the local environment only; I can easily reproduce this in GHA as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The initial issue was that, the subsequent push to the repository did not create new revision at all (most probably because manifest did not change).
Yes, it looks like that changing the annotation value will also trigger a new revision that will pull the image again,
2ce4cce
to
c0787f0
Compare
To ensure new Docker image being downloaded after a push to a branch we need to make changes to the knative service manifest. The following annotations are added on each deployment (
initium.nearform.com/updateSha
andinitium.nearform.com/updateTimestamp
forspec.template.metadata.annotations
) to make sure repository changes are reflected in the cluster.Closes #103