-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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(repo/config-migration): error fetching config file when repo cache is enabled #16664
fix(repo/config-migration): error fetching config file when repo cache is enabled #16664
Conversation
These functions sound confusingly similar. Should we be looking deeper at why we have both and why they don't behave the same? |
on top of that, im not sure why |
this workaround is getting the file from github instead of getting it locally. |
So the problem was that whenever repo cache is enabled, the repo content isnt being saved under the regular file based cache but rather in the |
We shouldn't trigger a clone just for the purpose the checking migration though. This would be really wasteful. |
We don't want to be cloning or using an extra API call every run if it's only for the purpose of this migration PR and such a PR already exists and doesn't need updating. Ie I prefer to make our cache smarter instead of consuming extra GitHub calls |
current repo cache already have the config name, is saving its content an option? |
Sure, if that can avoid unnecessary cloning or API calls |
instead of saving the config to the cache, we should simply check if current branch sha is the same as before and skip the whole migration check, as the branch is already up to date. |
As long as it works in both cache and non cache scenarios |
Isnt the branch sha is changed on new commits to it? if so, we shouldnt expect too many sha changes to the migration branch. |
It's only the default branch sha which should matter, because it holds the config. And if it has changed then we would have cloned in most cases. Could you summarise again what exactly causes this problem? Eg is it that we haven't fully synced got on some runs, or something else? |
The current main logic is as follows: In
This null indicates that the config does not need migration renovate/lib/workers/repository/config-migration/branch/index.ts Lines 11 to 19 in 4d55ada
These two function calls are invoked here - renovate/lib/workers/repository/finalise/index.ts Lines 19 to 24 in 4d55ada
So the main problem is that it is assumed that the repository config file always exists, which it doesnt when repo cache is enable, so in turn The suggested solution, as per this discussion would be to cache this branch, and check the parent sha to determine whether to try migration and fetch the raw config or not. Above is the PR closing cause. |
Also, the migration flow happens after the cache is set, therefore the branch data isnt saved. cache is set here - renovate/lib/workers/repository/index.ts Lines 49 to 53 in 4f82df4
migration done in the repo finalize stage - renovate/lib/workers/repository/finalise/index.ts Lines 19 to 31 in 4f82df4
|
In the current state, we cant use repository cache in the migration flow. As i see it, we have three options:
1,2 are doable, 2 requires cache manipulation. 3 i assume would break quite a few things. To sum it up, can we move the migration flow into the repo worker's main flow? Note that we call WDYT? once cache is available, we can compare parent Sha in order to determine if new migration is required. renovate/lib/workers/repository/index.ts Lines 40 to 60 in 4f82df4
|
Is (1) a small change? I'm not sure I can fully visualize the impact but if it's simple to show in a PR then let's just take a look |
This is all there is to it. now we cache the branch and can utilize the repository cache within the migration flow. |
That looks like an elegant solution to me. Do you have any concerns or doubts about it? |
Currently the only thing i can think of is that this flow might be run more than once in a current run due to the recursive call to that said, thats not much different than running self hosted with cache disable, what i mean is that we detect that the branch is not modified and we basically skip it. same goes for cache, if we utilize it correctly this shouldnt be a problem. other than that the logic stays the same, we just change execution point |
Recursive call within Renovate OSS or within the app's wrapper? |
OSS - declaration - renovate/lib/workers/repository/index.ts Lines 21 to 25 in 4f82df4
recursive call - renovate/lib/workers/repository/index.ts Lines 54 to 60 in 4f82df4
rubber ducking here, seems that the recursive depth is 2 at most due to the |
and it's only done on automerge |
The base-branch SHA comparison won't help us as much. I've tested it and I think it won't work as easily, as the A possible solution might be in the form of as the migration flow is already dependent on This is done regardless of repo cache. |
Changes
Use
platform.readLocalFile
to fetch repo config file.currently we are using
fs.getLocalFile
which fails whenrepoCache=enabled
. which in turn causes migration PR to not be created/autoclosed.Context
Documentation (please check one with an [x])
How I've tested my work (please tick one)
I have verified these changes via: