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 caching by resetting cache only when mono changes #38972

Merged
merged 1 commit into from
Oct 2, 2019

Conversation

chsienki
Copy link
Contributor

@chsienki chsienki commented Oct 1, 2019

We currently have a 'cache bust' mechanism, that prevents our docker image from caching the mono nightly install steps: We cache the initial install, then update the container every time we run the tests to get up to latest.

In general this is fine, but as the base image gets further away from the 'latest' update, the apt-upgrade takes longer and longer, leading to machine restore time being up to 50% of overall test time.

We have a couple of options, including not updating everything on the box, but this can lead to potentially weird issues where a 'fresh' container build would give different results to a cached one due to dependency differences, which we definitely want to avoid.

This change breaks the container build into two stages: an info stage and a build stage. The info stage simply gets the release info for Mono nightly. The main build then copies this file into the main container before updating. Docker is clever enough to use the hash of the file to determine if it should maintain the cache or not, meaning we'll only update the machine and its dependencies if a new nightly mono has actually been published since the last run.

There are still some issues with this approach, mainly that running on different physical machines can end up with different dependency sets cached, but they should only ever be slightly out of date, so I'm hopeful we shouldn't see any actual issues.

I have some ideas how to fix this in a much more robust way, but it needs some thinking / infra investment, so this should be considered a medium term fix to try and get the Linux Mono legs to a better, but not perfect, state.

@chsienki chsienki force-pushed the fix_dockerfile_caching branch 2 times, most recently from 77d86ac to 46fa171 Compare October 1, 2019 00:42
@chsienki
Copy link
Contributor Author

chsienki commented Oct 1, 2019

Note also: because we have machine fan out, this change will take a little while to have any effect. As the new docker file is used on each machine it will start from scratch (as the file changed), and then subsequent runs on the same machines should improve in speed as the cache is used.

@chsienki chsienki marked this pull request as ready for review October 1, 2019 18:14
@chsienki chsienki requested a review from a team as a code owner October 1, 2019 18:14
@chsienki
Copy link
Contributor Author

chsienki commented Oct 1, 2019

@dotnet/roslyn-infrastructure for review please.

Copy link
Member

@agocke agocke left a comment

Choose a reason for hiding this comment

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

LGTM

@chsienki chsienki merged commit 0ce4f54 into dotnet:master Oct 2, 2019
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.

2 participants