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

Enable caching imgpkg #178

Merged
merged 10 commits into from
Sep 13, 2022
Merged

Enable caching imgpkg #178

merged 10 commits into from
Sep 13, 2022

Conversation

joaopapereira
Copy link
Member

This PR includes the following changes:

  • Uses richgo, when present, to run tests to have an easier-to-read UX
  • Start using imgpkg as a library
  • Allow the users to specify caching folder and the maximum size of caching they want to enable using the environment variables VENDIR_CACHE_DIR and VENDIR_MAX_CACHE_SIZE respectively.

Fixes #160

richgo provides a better UX while running tests in the command line

Signed-off-by: Joao Pereira <[email protected]>
Copy link
Contributor

@joe-kimmel-vmw joe-kimmel-vmw left a comment

Choose a reason for hiding this comment

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

i have left you a sort of incomplete code review but i think that's all i can give you at the moment. thanks for letting me take a look.

// Enabled implements dockerConfigProvider
func (d *defaultDockerConfigProvider) Enabled() bool {
- return true
+ return false
Copy link
Contributor

Choose a reason for hiding this comment

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

this is like forking an open source project but sneakier. is this a long-term plan?

Copy link
Member Author

Choose a reason for hiding this comment

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

we tried to give provide a fix to the upstream repository but they told us that they wanted to keep the repository as a copy-paste from Kubernetes authentication libraries.
This is a temporary solution until we fix the issue carvel-dev/imgpkg#397


// Hit checks if a particular entry in the cache is present
// Returns the path to the entry and a flag information if the entry was found or not
func (c FolderCache) Hit(id string) (string, bool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: but to my mind "Hit" sounds more like a command than a query. of course "Present" has the same issues and is a longer word. idk, for 3 letter words, ... "Has" ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was trying to use the caching more common terms like hit/miss to provide describe the behavior, but I think this can be an easy change

@@ -0,0 +1,302 @@
// Copyright 2022 VMware, Inc.
Copy link
Contributor

Choose a reason for hiding this comment

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

what does it mean to stick our copyright above something that has a different copyright?

Copy link
Member Author

Choose a reason for hiding this comment

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

we do add our copyright to all the files with cod in the project and we have been told that this is what we should be doing

@@ -135,3 +238,29 @@ func (t *Imgpkg) addDangerousArgs(args []string) []string {
}
return args
}

// Logger provided to the imgpkg API calls
type Logger struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

ok i'll admit, i'm confused why, in a PR about caching, there's a logger that looks like it has levels but actually they're hardcoded and you'll never know which level something was logged at, especially if it was a debug log bc those don't even log at all?

My guess is you needed an interface to pass to something else, but maybe some more elaborate hint in the comments would be helpful

Copy link
Contributor

Choose a reason for hiding this comment

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

i guess in general -- i like log messages. like being able to get debug output. i have some dreams w.r.t . being able to trigger all the tools in kapp-controller into debug at the same time, for the sake of figuring out what's going on.

Copy link
Member Author

Choose a reason for hiding this comment

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

The logger created in this particular instance is a bit peculiar because it needs to conform to the requirements from the imgpkg API.
Because of that, it is only present in the image package. In the future when we are using our tools and can provide directives to activate different logging levels we should definitely revisit all these instances to ensure that we are doing the correct thing.
In the meanwhile, I will update the logger struct comment to inform the user that not all the logs will be present

Starts using imgpkg as a library do pull images and bundles

Signed-off-by: Joao Pereira <[email protected]>
Due to the inclusion of imgpkg as a library we need to ensure that the
change made in carvel-dev/imgpkg#255
stays in effect.
This will behavior can be removed when we complete the issue
carvel-dev/imgpkg#397

Signed-off-by: Joao Pereira <[email protected]>
@joaopapereira joaopapereira force-pushed the enable-caching-imgpkg branch 2 times, most recently from 89c3df8 to 3714f5b Compare August 23, 2022 22:06
@cppforlife
Copy link
Contributor

i just realized that by merging this, it would make vendir block in environments where ambient creds endpoints are present but blocked (same problem that imgpkg has). this is especially nasty if user is not even using imgpkg fetcher (previously this was not a problem because imgpkg's dependencies are not executed when vendir itself starts). id like us to see ambient cred blocking problem fixed before we release vendir to avoid this backwards compat breaking behaviour.

@joaopapereira
Copy link
Member Author

@cppforlife what do you mean by ambient credentials blocking problem?

@joaopapereira joaopapereira force-pushed the enable-caching-imgpkg branch from 3714f5b to 1c049fb Compare August 24, 2022 16:00
@joaopapereira
Copy link
Member Author

Are you talking about selectively choose the auth keychains?
From this issue carvel-dev/imgpkg#326
Also the fix that is coming on this PR carvel-dev/imgpkg#409 ?

@cppforlife
Copy link
Contributor

Are you talking about selectively choose the auth keychains?

yup, im getting a little lost with one of the PRs closed and the other merged. looks like it the feature that we needed got merged. it seems that those changes were introduced in imgpkg v0.32.0. im ok merging this PR as is assuming we make another PR with bump to imgpkg v0.32.0 before we cut a next vendir release. (or feel free to revise this PR to do the bump).

Signed-off-by: Joao Pereira <[email protected]>
With imgpkg 0.32.0 there is not need for this hack script anymore

This reverts commit 0b6d143.
Signed-off-by: Joao Pereira <[email protected]>
Copy link
Contributor

@cppforlife cppforlife left a comment

Choose a reason for hiding this comment

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

left one comment before merge

}

func (c FolderCache) idToFolder(artifactType string, id string) string {
normalizedID := strings.ReplaceAll(id, ":", "-")
Copy link
Contributor

Choose a reason for hiding this comment

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

should we turn id into a base64 or sha to avoid having to "try to sanitize" it?

@cppforlife cppforlife merged commit d3f61c7 into develop Sep 13, 2022
@joaopapereira joaopapereira deleted the enable-caching-imgpkg branch September 28, 2022 20:26
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.

Cache image and bundle contents
4 participants