Skip to content

fix: fetch each import source only once per command - #3367

Open
shawkitajima wants to merge 2 commits into
devspace-sh:mainfrom
shawkitajima:inf/fetch-imports-once-per-run
Open

shawkitajima wants to merge 2 commits into
devspace-sh:mainfrom
shawkitajima:inf/fetch-imports-once-per-run

Conversation

@shawkitajima

@shawkitajima shawkitajima commented Dec 3, 2026 •

Copy link
Copy Markdown

What issue type does this pull request address?
/kind bugfix

What does this pull request do? Which issues does it resolve?
A single DevSpace command reads the config more than once (a preload at startup, the command's own read, and one more read per dependency). Each read resolves every import, nested import and dependency again. For each cached git import that means a git pull every time, and for URL path: imports a fresh download every time, even though the same source was just fetched earlier in the same command. With chained imports a command runs the same pull many times.

This change records, in the existing downloadMutex-guarded dependency downloader, the source ids already cloned, pulled or downloaded in the current process. Later reads of the same source skip the remote while the cached copy exists. A missing cache still clones or downloads fresh, and disablePull, revision, branch and tag behave as before. Each new command still pulls once, so updates are picked up on the next run. The same downloader also serves helm git and URL chart sources, so they get the same behavior.

Two details: a failed git pull is logged once and not retried within the same command, and a URL source is marked fetched only after a successful download. The URL download now completes and checks the HTTP status before it replaces the cached file, so a failed download no longer empties a good cached import.

Measured against local git repos chained by imports, on repeat runs: pulls fell from 9 to 3 with one dependency, from 10 to 3 with shared nested imports, and from 9 to 3 with tag imports. A commit pushed to the deepest import between runs still appeared on the next run.

Please provide a short message that should be published in the DevSpace release notes
Fixed an issue where DevSpace pulled the same git import (and re-downloaded URL imports) repeatedly within a single command, instead of once per command.

What else do we need to know?

  • Added tests in pkg/devspace/dependency/util for git, disablePull, a failed pull, URL sources, and URL download errors with and without a cached copy. They fail without the change and pass with it.
  • Ran go test ./pkg/devspace/dependency/... ./pkg/devspace/config/loader/..., gofmt and go vet on the package: all clean.
  • Not run: ./hack/coverage.bash, golangci-lint and the e2e suite (needs a kind cluster).
  • Long-running commands such as devspace dev keep the version fetched at start; before this change they also read imports only when the config was read.

@netlify

netlify Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for devspace-docs canceled.

Built without sensitive environment variables

Name Link
🔨 Latest commit d2f169b
🔍 Latest deploy log https://app.netlify.com/projects/devspace-docs/deploys/6b11f05421a274193167bf1c

A single command reads the config several times and resolves every import,
nested import and dependency again, so each cached git import ran git pull
(and URL imports re-downloaded) on every read. Record the sources already
fetched in this process and skip the remote for later reads while the cached
copy exists. A missing cache still clones or downloads fresh.

Signed-off-by: Shaw Kitajima <41173553+shawkitajima@users.noreply.github.com>
Download and check the HTTP status before writing the cached file, and mark
the source fetched only after the download succeeded, so a failed download
neither empties a good cached import nor stops retries in the same command.
Cover URL sources, disablePull and a failed pull in tests, and build file
URLs that are valid on Windows.

Signed-off-by: Shaw Kitajima <41173553+shawkitajima@users.noreply.github.com>
@shawkitajima
shawkitajima force-pushed the inf/fetch-imports-once-per-run branch from 6ba11b1 to d2f169b Compare December 3, 2026 22:42
@shawkitajima
shawkitajima marked this pull request as ready for review December 3, 2026 22:49

This branch has not been deployed

No deployments
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.

1 participant