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

Feature/147 global cache #460

Merged
merged 11 commits into from
Feb 25, 2022
Merged

Feature/147 global cache #460

merged 11 commits into from
Feb 25, 2022

Conversation

henrjk
Copy link
Member

@henrjk henrjk commented Feb 21, 2022

This provides support for caching dependencies by changing ods-start to no longer clean any content in the working directory and instead spare files under .ods-cache.

In addition ods-start cleans the cache by removing files except at locations .ods-cache/deps/*/**.

The PR also introduces parameter cache-dependencies defaulting to true in ods-build-go. The default places the go module cache at .ods-cache/deps/gomod by setting environment variable GOMODCACHE to that area.

In addition ods-build-go now reports the free disk space.

If disk space on the PVC runs out one should replace or resize the PVC to accommodate the storage demands. This is a manual operation.

Compared to the PR #412 this does not implement an additional mechanism to skip dependency caching for a particular (re)build other than changing the parameter cache-dependencies. As a consequence the mechanism to implement dynamic disablement of caching via file .ods/cache-deps-parent-dir has not been implemented.

Closes #147

Tasks:

  • Updated design documents in docs/design directory or not applicable
  • Updated user-facing documentation in docs directory or not applicable
  • Ran tests (e.g. make test) or not applicable
  • Updated changelog or not applicable

@henrjk
Copy link
Member Author

henrjk commented Feb 21, 2022

I made it a draft PR knowing that there is outstanding work on docs.
I @michaelsauter: Any additional feedback about the changes is most welcome as I would say the code might be done!

Copy link
Member

@michaelsauter michaelsauter left a comment

Choose a reason for hiding this comment

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

Unfortunately I won't get to this for the next couple of days and I need more time to look at the code in detail. So for now just some high-level comments on the general approach ...

@henrjk henrjk marked this pull request as ready for review February 22, 2022 11:10
@henrjk henrjk requested review from gerardcl and stitakis February 22, 2022 11:12
@henrjk henrjk self-assigned this Feb 22, 2022
@gerardcl gerardcl self-requested a review February 23, 2022 13:37
Copy link
Member

@gerardcl gerardcl left a comment

Choose a reason for hiding this comment

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

LGTM so far! 🚀

definitely we might have a solution for compiled languages but not for python or javascript which might be the complicated ones...let's see! in any case this is out of scope for this PR IMHO as you stated -> good job!!!!!

Copy link
Member

@michaelsauter michaelsauter left a comment

Choose a reason for hiding this comment

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

Love it! Especially the surgical changes in the Go build tasks and the use of io.fs.FS 😉

return leaveAlone
}
return remove // delete everything else
}, withBaseFileRemover(filepath.Join(fsb.base, odsCacheDirName), fnRemove))
Copy link
Member

Choose a reason for hiding this comment

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

I was wondering if this would be easier to read if the "decider func" would be defined upfront, and only referenced here?

if err != nil {
return err
}
}
Copy link
Member

Choose a reason for hiding this comment

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

I was wondering whether we really need two different ways to deal with directories and files. It seems like fnSkip either returns stuff for directories (walkChildren or leaveAlone), or for files (remove) ... of course fnRemove is called with true/false, but that seems to be for logging purposes only so not sure whether this is worth it.

Anyway, I haven't thought this through and I might be off here ...

Copy link
Member Author

Choose a reason for hiding this comment

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

For directories there are three cases:

  1. Remove directory and (thus skip further walking)
  2. Skip directory to leave it in place.
  3. Enter but not delete directory to allow deleting files inside a directory.
    For files it only needs to be decided whether they should be removed or not.
    Anyways perhaps with improved naming this will be clearer.

func TestCacheCleaning(t *testing.T) {

tests := map[string]struct {
fileSystem fstest.MapFS
Copy link
Member

Choose a reason for hiding this comment

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

Nice!

@henrjk
Copy link
Member Author

henrjk commented Feb 24, 2022

The latest pushes did not trigger the workflows. https://www.githubstatus.com/ looks green.
@michaelsauter Is there a possibility to trigger this manually?

@henninggross
Copy link
Member

@henrjk I think workflows are not executed when there is a merge conflict. Check if resolving this triggers a execution of the workflows.

@henrjk
Copy link
Member Author

henrjk commented Feb 24, 2022

@henrjk I think workflows are not executed when there is a merge conflict. Check if resolving this triggers a execution of the workflows.

You rock! I didn't know about this and also did not notice the conflict.

- Do not delete files outside of deps cache.
- Remove parameter `cache-dependencies` and always enable it instead.
  This removes the need for the additional test which was removed.
- Some minor stylistic changes
- Updated docs
Copy link
Member

@michaelsauter michaelsauter left a comment

Choose a reason for hiding this comment

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

Awesome 🚀

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.

Allow to cache dependencies
4 participants