Skip to content

worker: remove automatic migration of legacy v1 cache#6509

Open
thaJeztah wants to merge 1 commit intomoby:masterfrom
thaJeztah:rm_cache_migration
Open

worker: remove automatic migration of legacy v1 cache#6509
thaJeztah wants to merge 1 commit intomoby:masterfrom
thaJeztah:rm_cache_migration

Conversation

@thaJeztah
Copy link
Member

@thaJeztah thaJeztah commented Feb 3, 2026

worker: remove automatic migration of legacy v1 cache

This removes the MigrateV2 function, which was added in BuildKit v0.7.0 (Docker v20.10.0) in 31a9aee. That was in 2019, which is now over 6 Years ago, so it's very unlikely for old files to be still present.

Removing this code would impact users migrating from Docker 19.03 or older, which are versions that reached EOL many years ago, so very unlikely.

Copy link
Member

@crazy-max crazy-max left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@tonistiigi tonistiigi left a comment

Choose a reason for hiding this comment

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

We can remove this migration code, but we should still leave in error if the old state dir is used.

@thaJeztah
Copy link
Member Author

@tonistiigi you mean if filepath.Join(root, "metadata.db"), exists, but filepath.Join(root, "metadata_v2.db") does not exist (i.e., old data found that's not migrated)?

That would be in a situation where a user upgrades from either Docker 19.03 -> latest, or BuildKit v0.6.0 -> latest; is that supported?

@tonistiigi
Copy link
Member

@thaJeztah Yes, I think in that case we can just give an error. So if this ever happens, users can clear the state manually or run a version with the migrate before updating to the latest version.

@thaJeztah thaJeztah force-pushed the rm_cache_migration branch 2 times, most recently from 97bf000 to 13bc686 Compare February 12, 2026 11:09
Comment on lines 32 to 43
// Check for legacy (v1) cache state.
//
// Automatic migration was removed in https://github.com/moby/buildkit/pull/6509
if _, err := os.Stat(filepath.Join(dbPath)); os.IsNotExist(err) {
legacyMetadata := filepath.Join(filepath.Dir(dbPath), "metadata.db")
if _, err := os.Stat(legacyMetadata); err == nil {
return nil, errors.Errorf(
"legacy (v1) cache metadata found at %q and needs to be removed or migrated; downgrade BuildKit to v0.27.1 to perform automatic migration or remove the existing cache",
legacyMetadata,
)
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Updated; https://github.com/moby/buildkit/compare/97bf000f37af60ea3628889cff6c7f37c81adb71..13bc686bd6adfdcaec59d03bfe26b36ad14a29f8

Decided to roll the check into the constructor here, so that BuildKit can remove it when we're comfortable; could use some input on the error-message though (not sure if it's just the metadata.db to look for, or if the user has to remove (or migrate) state elsewhere.

// Check for legacy (v1) cache state.
//
// Automatic migration was removed in https://github.com/moby/buildkit/pull/6509
if _, err := os.Stat(filepath.Join(dbPath)); os.IsNotExist(err) {
Copy link
Member

Choose a reason for hiding this comment

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

cache/metadata/metadata.go:35:23: badCall: suspicious Join on 1 argument (gocritic)

Copy link
Member Author

Choose a reason for hiding this comment

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

Doh! I initially had it in a separate function; the filepath.Join is no longer needed here.

Updated; should be good now!

(I also tweaked the PR and commit title to be a bit more descriptive for the change-log)

This removes the MigrateV2 function, which was added in BuildKit v0.7.0
(Docker v20.10.0) in 31a9aee. That was
in 2019, which is now over 6 Years ago, so it's very unlikely for old
files to be still present.

Removing this code would impact users migrating from Docker 19.03 or
older, which are versions that reached EOL many years ago, so very
unlikely.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah thaJeztah changed the title cache: remove MigrateV2 worker: remove automatic migration of legacy v1 cache Feb 14, 2026
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.

3 participants