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(util/git): Skip PR update on "force-with-lease" errors #14228

Merged
merged 5 commits into from
Feb 15, 2022

Conversation

zharinov
Copy link
Collaborator

Changes:

  • Wrap to ExternalHostError and re-throw, which will lead processBranch() to skip the branch updating for this run.

Context:

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please tick one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

@@ -124,7 +124,7 @@ export function handleCommitError(
logger.info(
'Branch update was rejected because local copy is not up-to-date.'
);
return null;
throw new ExternalHostError(err, 'git');
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

'[rejected] (stale info)' can be added to externalHostFailureStrings instead, but log message would be too verbose IMO.

Anyway, please suggest better alternative if the solution is okay in general.

Copy link
Collaborator

Choose a reason for hiding this comment

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

How does it look in the logs with your current suggestion?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

How does it look in the logs with your current suggestion?

Please, take a look here: #14228 (comment)

@zharinov zharinov changed the title fix(util/git): Skip PR update on --force-with-lease errors fix(util/git): Skip PR update on "force-with-lease" errors Feb 15, 2022
@zharinov
Copy link
Collaborator Author

zharinov commented Feb 15, 2022

Log messages from reproduction repo (no PRs were updated):

DEBUG: Pushing branch renovate/yarn-1.x (repository=renovate-testing/test-12124-pr-title-and-body-failure, branch=renovate/yarn-1.x)
 INFO: Branch update was rejected because local copy is not up-to-date. (repository=renovate-testing/test-12124-pr-title-and-body-failure, branch=renovate/yarn-1.x)
DEBUG: Closing Dependency Dashboard (repository=renovate-testing/test-12124-pr-title-and-body-failure)
DEBUG: Retrieving issueList (repository=renovate-testing/test-12124-pr-title-and-body-failure)
DEBUG: Retrieved 0 issues (repository=renovate-testing/test-12124-pr-title-and-body-failure)
DEBUG: Removing any stale branches (repository=renovate-testing/test-12124-pr-title-and-body-failure)
DEBUG: config.repoIsOnboarded=true (repository=renovate-testing/test-12124-pr-title-and-body-failure)
DEBUG: Branch lists (repository=renovate-testing/test-12124-pr-title-and-body-failure)
       "branchList": ["renovate/yarn-1.x"],
       "renovateBranches": ["renovate/yarn-1.x"]
DEBUG: remainingBranches= (repository=renovate-testing/test-12124-pr-title-and-body-failure)
DEBUG: No branches to clean up (repository=renovate-testing/test-12124-pr-title-and-body-failure)
DEBUG: Repository timing splits (milliseconds) (repository=renovate-testing/test-12124-pr-title-and-body-failure)
       "splits": {"init": 2194, "extract": 1561, "lookup": 187, "update": 16636},
       "total": 20941
DEBUG: http statistics (repository=renovate-testing/test-12124-pr-title-and-body-failure)
       "urls": {
         "https://api.github.com/graphql (POST)": 4,
         "https://api.github.com/repos/renovate-testing/test-12124-pr-title-and-body-failure/contents/renovate.json (GET)": 1,
         "https://api.github.com/repos/renovate-testing/test-12124-pr-title-and-body-failure/pulls (GET)": 1
       },
       "hostStats": {"api.github.com": {"requestCount": 6, "requestAvgMs": 331, "queueAvgMs": 0}},
       "totalRequests": 6
 INFO: Repository finished (repository=renovate-testing/test-12124-pr-title-and-body-failure)
       "durationMs": 20941
DEBUG: Renovate exiting

@rarkins
Copy link
Collaborator

rarkins commented Feb 15, 2022

I was expecting to see an err logged somehow. Do we swallow it all now? It's ok if so

@zharinov
Copy link
Collaborator Author

DEBUG: Pushing branch renovate/yarn-1.x (repository=renovate-testing/test-12124-pr-title-and-body-failure, branch=renovate/yarn-1.x)
DEBUG: Converting git error to ExternalHostError (repository=renovate-testing/test-12124-pr-title-and-body-failure, branch=renovate/yarn-1.x)
       "err": {
         "task": {
           "commands": [
             "push",
             "origin",
             "renovate/yarn-1.x:renovate/yarn-1.x",
             "--force-with-lease",
             "-u",
             "--no-verify",
             "--verbose",
             "--porcelain"
           ],
           "format": "utf-8",
           "parser": "[function]"
         },
         "message": "To https://github.com/renovate-testing/test-12124-pr-title-and-body-failure.git\n!\trefs/heads/renovate/yarn-1.x:refs/heads/renovate/yarn-1.x\t[rejected] (stale info)\nDone\nPushing to https://github.com/renovate-testing/test-12124-pr-title-and-body-failure.git\nerror: failed to push some refs to 'https://github.com/renovate-testing/test-12124-pr-title-and-body-failure.git'\n",
         "stack": "Error: To https://github.com/renovate-testing/test-12124-pr-title-and-body-failure.git\n!\trefs/heads/renovate/yarn-1.x:refs/heads/renovate/yarn-1.x\t[rejected] (stale info)\nDone\nPushing to https://github.com/renovate-testing/test-12124-pr-title-and-body-failure.git\nerror: failed to push some refs to 'https://github.com/renovate-testing/test-12124-pr-title-and-body-failure.git'\n\n    at Object.action (/Users/sergio/Work/renovate/node_modules/src/lib/plugins/error-detection.plugin.ts:38:28)\n    at PluginStore.exec (/Users/sergio/Work/renovate/node_modules/src/lib/plugins/plugin-store.ts:24:29)\n    at /Users/sergio/Work/renovate/node_modules/src/lib/runners/git-executor-chain.ts:114:40\n    at new Promise (<anonymous>)\n    at GitExecutorChain.handleTaskData (/Users/sergio/Work/renovate/node_modules/src/lib/runners/git-executor-chain.ts:111:14)\n    at GitExecutorChain.<anonymous> (/Users/sergio/Work/renovate/node_modules/src/lib/runners/git-executor-chain.ts:88:40)\n    at Generator.next (<anonymous>)\n    at fulfilled (/Users/sergio/Work/renovate/node_modules/simple-git/cjs/index.js:55:24)"
       }
DEBUG: Closing Dependency Dashboard (repository=renovate-testing/test-12124-pr-title-and-body-failure)
DEBUG: Retrieving issueList (repository=renovate-testing/test-12124-pr-title-and-body-failure)
DEBUG: Retrieved 0 issues (repository=renovate-testing/test-12124-pr-title-and-body-failure)
DEBUG: Removing any stale branches (repository=renovate-testing/test-12124-pr-title-and-body-failure)
DEBUG: config.repoIsOnboarded=true (repository=renovate-testing/test-12124-pr-title-and-body-failure)
DEBUG: Branch lists (repository=renovate-testing/test-12124-pr-title-and-body-failure)
       "branchList": ["renovate/yarn-1.x"],
       "renovateBranches": ["renovate/yarn-1.x"]
DEBUG: remainingBranches= (repository=renovate-testing/test-12124-pr-title-and-body-failure)
DEBUG: No branches to clean up (repository=renovate-testing/test-12124-pr-title-and-body-failure)
DEBUG: Repository timing splits (milliseconds) (repository=renovate-testing/test-12124-pr-title-and-body-failure)
       "splits": {"init": 2242, "extract": 1583, "lookup": 121, "update": 13675},
       "total": 17962
DEBUG: http statistics (repository=renovate-testing/test-12124-pr-title-and-body-failure)
       "urls": {
         "https://api.github.com/graphql (POST)": 4,
         "https://api.github.com/repos/renovate-testing/test-12124-pr-title-and-body-failure/contents/renovate.json (GET)": 1,
         "https://api.github.com/repos/renovate-testing/test-12124-pr-title-and-body-failure/pulls (GET)": 1
       },
       "hostStats": {"api.github.com": {"requestCount": 6, "requestAvgMs": 313, "queueAvgMs": 0}},
       "totalRequests": 6
 INFO: Repository finished (repository=renovate-testing/test-12124-pr-title-and-body-failure)
       "durationMs": 17962
DEBUG: Renovate exiting

@zharinov
Copy link
Collaborator Author

zharinov commented Feb 15, 2022

Ah, haven't noticed you're okay with swallowing. So yes, at first I decided we don't need to log error as we handle it now explicitly.
Which approach would you like to be released?

@viceice viceice enabled auto-merge (squash) February 15, 2022 07:01
@rarkins rarkins enabled auto-merge (squash) February 15, 2022 07:16
@rarkins rarkins merged commit 1f79f22 into renovatebot:main Feb 15, 2022
@renovate-release
Copy link
Collaborator

🎉 This PR is included in version 31.82.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PR gets auto-merged with changed version in title, but not changed contents
4 participants