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

Allow not persisting CACHE mount #3510

Merged
merged 6 commits into from
Nov 27, 2023
Merged

Conversation

ingwarsw
Copy link
Contributor

@ingwarsw ingwarsw commented Nov 20, 2023

Adds option to disable persist cache.
See #3509 for details.

Im not sure if by default should be persist or not-persist.
Persisting data seems bad idea in most "global" caches, cause they will grow and it takes ages to persist them.
And caches are well, caches and I assume in most cases are not needed in image..
And if someone wants to persist it it can enable it.

@ingwarsw ingwarsw requested a review from a team as a code owner November 20, 2023 12:37
@alexcb
Copy link
Collaborator

alexcb commented Nov 20, 2023

Thanks for the PR; it should be not-persist, as we try to avoid backwards-breaking changes. We could potentially flip the default behaviour when we bump VERSION 0.7 to 0.8.

@vladaionescu
Copy link
Member

it should be not-persist, as we try to avoid backwards-breaking changes

Hey @alexcb - note that currently, the behavior is to always persist. So then the default should remain persist, right?

@vladaionescu
Copy link
Member

Either way, the existence of this new option still requires a feature flag. Something like VERSION --cache-not-persist-option 0.7.

@alexcb
Copy link
Collaborator

alexcb commented Nov 20, 2023

it should be not-persist, as we try to avoid backwards-breaking changes

Hey @alexcb - note that currently, the behavior is to always persist. So then the default should remain persist, right?

That's what I tried to say, but words are hard.... thanks for clarifying this :)

I understood the question as which of the two boolean flag names do we want:

CACHE --persisted ... or CACHE --non-persisted ....

I think we'll want CACHE --non-persisted ..., so that users can continue to use CACHE ... which will give them a persisted cache by default.

Something like VERSION --cache-not-persist-option 0.7

I wonder if we really need that in this case, because old users of earthly will get an error such as CACHE --non-persisted contains an unsupported flag name, so we'll prevent cases where a feature is ignored by older earthly clients. Thoughts @vladaionescu ?

@vladaionescu
Copy link
Member

It's best to add a feature flag for new commands and new options, even if they're backwards compatible. The reasoning is that every 0.7 Earthly should be able to build any VERSION 0.7 Earthfile.

@vladaionescu
Copy link
Member

BTW should be call the flag --no-persist? It's a little more consistent

alexcb added a commit that referenced this pull request Nov 20, 2023
A friendly reminder, stemming from the discussion in #3510 (comment)

Signed-off-by: Alex Couture-Beil <[email protected]>
alexcb added a commit that referenced this pull request Nov 20, 2023
A friendly reminder, stemming from the discussion in #3510 (comment)

Signed-off-by: Alex Couture-Beil <[email protected]>
alexcb added a commit that referenced this pull request Nov 20, 2023
A friendly reminder, stemming from the discussion in
#3510 (comment)

Signed-off-by: Alex Couture-Beil <[email protected]>
@ingwarsw
Copy link
Contributor Author

Adding extra flag seems ok..
But since we will be adding flag maybe then default can be reverted (it will not be breaking change then)?
I dont see when --persist option is needed (but i assume there are few cases), but in all options that I can think about its harmful, and thats why default should be in my opinion to not persist.

So to summarise.

When build with:

VERSION 0.7

test:
    CACHE /some

Would persist cache as currently (so would not be a breaking change).

If build with:

VERSION --cache-not-persist-option 0.7

test:
    CACHE /some

Would not persist it (not a breaking change because guarded by option).

If build with:

VERSION --cache-not-persist-option 0.7

test:
    CACHE --persist /some

Would persist it.

@alexcb
Copy link
Collaborator

alexcb commented Nov 21, 2023

But since we will be adding flag maybe then default can be reverted (it will not be breaking change then)?
I dont see when --persist option is needed (but i assume there are few cases), but in all options that I can think about its harmful, and thats why default should be in my opinion to not persist.

This would mean when users upgrade to VERSION 0.8, it would break the behaviour, which would suprise users who simply update the number without reading the CHANGELOG -- I think I'm ok with that change, since persisting the cache leads to really large images; thoughts on this change @vladaionescu ?

@vladaionescu
Copy link
Member

Yeah, it feels like a good decision. It is sometimes surprising to users that this auto-persisting is taking place, and sometimes it affects performance due to the size of the cache.

@ingwarsw
Copy link
Contributor Author

ingwarsw commented Nov 22, 2023

This would mean when users upgrade to VERSION 0.8, it would break the behaviour, which would suprise users who simply update the number without reading the CHANGELOG -- I think I'm ok with that change, since persisting the cache leads to really large images; thoughts on this change @vladaionescu ?

Thats something I didn't take into account..
But that should still not break much..

ps. what are the use cases when saving cache is essential?

@ingwarsw ingwarsw closed this Nov 22, 2023
@ingwarsw ingwarsw reopened this Nov 22, 2023
@ingwarsw
Copy link
Contributor Author

Wrong button :)

@vladaionescu
Copy link
Member

what are the use cases when saving cache is essential?

Sometimes users will want to populate some cache in one target, and reuse most of it in another target. For example: download dependencies in one target, but then have those dependencies around when compiling in another target. The pattern is very common in some languages.

@ingwarsw
Copy link
Contributor Author

what are the use cases when saving cache is essential?

Sometimes users will want to populate some cache in one target, and reuse most of it in another target. For example: download dependencies in one target, but then have those dependencies around when compiling in another target. The pattern is very common in some languages.

But as far as its in earthly its way faster to just mount cache in that other target.
Only place I need it may be needed its maybe python or other languages like that where you would need cache folder in final image.. but then I would never use shared cache cause it may be waaaay bigger than I actually need.

@alexcb
Copy link
Collaborator

alexcb commented Nov 23, 2023

Thanks for the changes @ingwarsw ; I just opened #3527 (with a git commit --allow-empty) to trigger our tests, which unfortunately depend on some secrets that are only available to members of the earthy repo. If they pass we'll be able to merge this PR.

@alexcb alexcb merged commit 19b3ead into earthly:main Nov 27, 2023
78 of 82 checks passed
@alexcb alexcb mentioned this pull request Dec 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants