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

Renovate exit with code 0 when a Azure repository is disabled #13013

Closed
marcmognol opened this issue Dec 8, 2021 · 8 comments · Fixed by #13225
Closed

Renovate exit with code 0 when a Azure repository is disabled #13013

marcmognol opened this issue Dec 8, 2021 · 8 comments · Fixed by #13225
Assignees
Labels
platform:azure Azure DevOps platform priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others type:feature Feature (new functionality)

Comments

@marcmognol
Copy link
Contributor

marcmognol commented Dec 8, 2021

What would you like Renovate to be able to do?

I would like Renovate doesn't exit with 0 when Azure Repository is disabled.

Right now, I use renovate running on Kubernetes as a CronJob.
If I disable a repos in Azure, renovate will fail, and Job will restart continuously.

If you have any ideas on how this should be implemented, please tell us here.

Maybe by setting WARNING instear ERROR level when renovate fails to access to the repository ?

Thanks for your support

Is this a feature you are interested in implementing yourself?

No

Click me to see logs


DEBUG: Using RE2 as regex engine
DEBUG: Parsing configs
DEBUG: Converting GITHUB_COM_TOKEN into a global host rule
DEBUG: File config
       "config": {
         "platform": "azure",
         "endpoint": "https://dev.azure.com/my-company",
         "autodiscover": true,
         "autodiscoverFilter": "IFS/*",
         "schedule": [
           "after 6pm every weekday",
           "before 5am every weekday",
           "every weekend"
         ],
         "prConcurrentLimit": 2,
         "gitAuthor": "Renovate Bot <[email protected]>",
         "dryRun": false
       }
DEBUG: CLI config
       "config": {}
DEBUG: Env config
       "config": {
         "hostRules": [
           {"hostType": "github", "matchHost": "github.com", "token": "***********"}
         ],
         "token": "***********"
       }
DEBUG: Combined config
       "config": {
         "platform": "azure",
         "endpoint": "https://dev.azure.com/my-company",
         "autodiscover": true,
         "autodiscoverFilter": "IFS/*",
         "schedule": [
           "after 6pm every weekday",
           "before 5am every weekday",
           "every weekend"
         ],
         "prConcurrentLimit": 2,
         "gitAuthor": "Renovate Bot <[email protected]>",
         "dryRun": false,
         "hostRules": [
           {"hostType": "github", "matchHost": "github.com", "token": "***********"}
         ],
         "token": "***********"
       }
DEBUG: Adding trailing slash to endpoint
DEBUG: Found valid git version: 2.34.1
DEBUG: Using configured gitAuthor (Renovate Bot <[email protected]>)
DEBUG: Adding token authentication for dev.azure.com to hostRules
DEBUG: Using baseDir: /tmp/renovate
DEBUG: Using cacheDir: /tmp/renovate/cache
DEBUG: Initializing Renovate internal cache into /tmp/renovate/cache/renovate/renovate-cache-v1
DEBUG: Commits limit = null
DEBUG: Autodiscovering Azure DevOps repositories
 INFO: Autodiscovered repositories
       "length": 1,
       "repositories": ["IFS/MyCompany.MyProject"]
DEBUG: Clearing hostRules
DEBUG: Adding token authentication for github.com to hostRules
DEBUG: Adding token authentication for dev.azure.com to hostRules
 INFO: Repository started (repository=IFS/MyCompany.MyProject)
       "renovateVersion": "29.36.2"
DEBUG: Using localDir: /tmp/renovate/repos/azure/IFS/MyCompany.MyProject (repository=IFS/MyCompany.MyProject)
DEBUG: initRepo("IFS/MyCompany.MyProject") (repository=IFS/MyCompany.MyProject)
DEBUG: Repository details (repository=IFS/MyCompany.MyProject)
       "repositoryDetails": {
         "id": "ReposId",
         "name": "MyCompany.MyProject",
         "url": "https://dev.azure.com/my-company/ProjectId/_apis/git/repositories/ReposId",
         "project": {
           "id": "ProjectId",
           "name": "IFS",
           "url": "https://dev.azure.com/my-company/_apis/projects/ProjectId",
           "state": "wellFormed",
           "revision": 662,
           "visibility": 0,
           "lastUpdateTime": "2021-07-21T08:31:15.143Z"
         },
         "defaultBranch": "refs/heads/main",
         "size": 642328,
         "remoteUrl": "https://[email protected]/my-company/IFS/_git/MyCompany.MyProject",
         "sshUrl": "[email protected]:v3/my-company/IFS/MyCompany.MyProject",
         "webUrl": "https://dev.azure.com/my-company/IFS/_git/MyCompany.MyProject",
         "isDisabled": true
       }
DEBUG: IFS/MyCompany.MyProject owner = ?owner? (repository=IFS/MyCompany.MyProject)
DEBUG: IFS/MyCompany.MyProject default branch = main (repository=IFS/MyCompany.MyProject)
DEBUG: git error (repository=IFS/MyCompany.MyProject)
       "err": {
         "task": {
           "commands": [
             "-c",
             "http.extraheader=AUTHORIZATION: basic **redacted**",
             "ls-remote",
             "--heads",
             "https://[email protected]/my-company/IFS/_git/MyCompany.MyProject"
           ],
           "format": "utf-8",
           "parser": "[function]"
         },
         "message": "remote: TF401019: The Git repository with name or identifier MyCompany.MyProject does not exist or you do not have permissions for the operation you are attempting.\nfatal: repository 'https://dev.azure.com/my-company/IFS/_git/MyCompany.MyProject/' not found\n",
         "stack": "Error: remote: TF401019: The Git repository with name or identifier MyCompany.MyProject does not exist or you do not have permissions for the operation you are attempting.\nfatal: repository 'https://dev.azure.com/my-company/IFS/_git/MyCompany.MyProject/' not found\n\n    at Object.action (/usr/src/app/node_modules/simple-git/src/lib/plugins/error-detection.plugin.ts:38:28)\n    at PluginStore.exec (/usr/src/app/node_modules/simple-git/src/lib/plugins/plugin-store.ts:24:29)\n    at /usr/src/app/node_modules/simple-git/src/lib/runners/git-executor-chain.ts:114:40\n    at new Promise (<anonymous>)\n    at GitExecutorChain.handleTaskData (/usr/src/app/node_modules/simple-git/src/lib/runners/git-executor-chain.ts:111:14)\n    at GitExecutorChain.<anonymous> (/usr/src/app/node_modules/simple-git/src/lib/runners/git-executor-chain.ts:88:40)\n    at Generator.next (<anonymous>)\n    at fulfilled (/usr/src/app/node_modules/simple-git/src/lib/runners/git-executor-chain.js:5:58)\n    at processTicksAndRejections (internal/process/task_queues.js:95:5)"
       }
ERROR: Repository has unknown error (repository=IFS/MyCompany.MyProject)
       "err": {
         "task": {
           "commands": [
             "-c",
             "http.extraheader=AUTHORIZATION: basic **redacted**",
             "ls-remote",
             "--heads",
             "https://[email protected]/my-company/IFS/_git/MyCompany.MyProject"
           ],
           "format": "utf-8",
           "parser": "[function]"
         },
         "message": "remote: TF401019: The Git repository with name or identifier MyCompany.MyProject does not exist or you do not have permissions for the operation you are attempting.\nfatal: repository 'https://dev.azure.com/my-company/IFS/_git/MyCompany.MyProject/' not found\n",
         "stack": "Error: remote: TF401019: The Git repository with name or identifier MyCompany.MyProject does not exist or you do not have permissions for the operation you are attempting.\nfatal: repository 'https://dev.azure.com/my-company/IFS/_git/MyCompany.MyProject/' not found\n\n    at Object.action (/usr/src/app/node_modules/simple-git/src/lib/plugins/error-detection.plugin.ts:38:28)\n    at PluginStore.exec (/usr/src/app/node_modules/simple-git/src/lib/plugins/plugin-store.ts:24:29)\n    at /usr/src/app/node_modules/simple-git/src/lib/runners/git-executor-chain.ts:114:40\n    at new Promise (<anonymous>)\n    at GitExecutorChain.handleTaskData (/usr/src/app/node_modules/simple-git/src/lib/runners/git-executor-chain.ts:111:14)\n    at GitExecutorChain.<anonymous> (/usr/src/app/node_modules/simple-git/src/lib/runners/git-executor-chain.ts:88:40)\n    at Generator.next (<anonymous>)\n    at fulfilled (/usr/src/app/node_modules/simple-git/src/lib/runners/git-executor-chain.js:5:58)\n    at processTicksAndRejections (internal/process/task_queues.js:95:5)"
       }
DEBUG: Unknown res (repository=IFS/MyCompany.MyProject)
       "res": "unknown-error"
DEBUG: Repository timing splits (milliseconds) (repository=IFS/MyCompany.MyProject)
       "splits": {},
       "total": 1013
 INFO: Repository finished (repository=IFS/MyCompany.MyProject)
       "durationMs": 1013
DEBUG: Renovate exiting
 INFO: Renovate is exiting with a non-zero code due to the following logged errors
       "loggerErrors": [
         {
           "name": "renovate",
           "level": 50,
           "logContext": "",
           "repository": "IFS/MyCompany.MyProject",
           "err": {
             "task": {
               "commands": [
                 "-c",
                 "http.extraheader=AUTHORIZATION: basic **redacted**",
                 "ls-remote",
                 "--heads",
                 "https://[email protected]/my-company/IFS/_git/MyCompany.MyProject"
               ],
               "format": "utf-8",
               "parser": "[function]"
             },
             "message": "remote: TF401019: The Git repository with name or identifier MyCompany.MyProject does not exist or you do not have permissions for the operation you are attempting.\nfatal: repository 'https://dev.azure.com/my-company/IFS/_git/MyCompany.MyProject/' not found\n",
             "stack": "Error: remote: TF401019: The Git repository with name or identifier MyCompany.MyProject does not exist or you do not have permissions for the operation you are attempting.\nfatal: repository 'https://dev.azure.com/my-company/IFS/_git/MyCompany.MyProject/' not found\n\n    at Object.action (/usr/src/app/node_modules/simple-git/src/lib/plugins/error-detection.plugin.ts:38:28)\n    at PluginStore.exec (/usr/src/app/node_modules/simple-git/src/lib/plugins/plugin-store.ts:24:29)\n    at /usr/src/app/node_modules/simple-git/src/lib/runners/git-executor-chain.ts:114:40\n    at new Promise (<anonymous>)\n    at GitExecutorChain.handleTaskData (/usr/src/app/node_modules/simple-git/src/lib/runners/git-executor-chain.ts:111:14)\n    at GitExecutorChain.<anonymous> (/usr/src/app/node_modules/simple-git/src/lib/runners/git-executor-chain.ts:88:40)\n    at Generator.next (<anonymous>)\n    at fulfilled (/usr/src/app/node_modules/simple-git/src/lib/runners/git-executor-chain.js:5:58)\n    at processTicksAndRejections (internal/process/task_queues.js:95:5)"
           },
           "msg": "Repository has unknown error"
         }
       ]
Copy/paste any log here, between the starting and ending backticks
@marcmognol marcmognol added priority-5-triage status:requirements Full requirements are not yet known, so implementation should not be started type:feature Feature (new functionality) labels Dec 8, 2021
@rarkins rarkins added the auto:logs Issue or Discussion is needs logs/more logs label Dec 8, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Dec 8, 2021

Hi there,

We have found that there's a problem with the logs. Depending on which situation applies follow one, some or all of these instructions.

No logs at all

If there's no log posted yet, we need you to find and copy/paste the log into the issue template.

Finding logs on hosted app

Click me to read instructions

If you use the Renovate app (GitHub):

  1. Go to the affected PR, and search for "View repository job log here"
  2. Click on the link to go to the "WhiteSource Renovate Dashboard" and log in
  3. You are now in the correct repository log overview screen
  4. Copy/paste the correct log
  5. Follow the steps in the formatting your logs section

Finding logs when self-hosting

Click me to read instructions

If you're running self-hosted, run with LOG_LEVEL=debug in your environment variables and search for whatever dependency/branch/PR that is causing the problem.

Insufficient logs

Click me to read instructions

If you already provided logs, and the Renovate team said they are not enough, follow the instructions from the No logs at all section.

Formatting your logs

Click me to read instructions

Please put your logs in a <details> and <summary> element like this:

<details><summary>Click me to see logs</summary>

```
Copy/paste any log here, between the starting and ending backticks
```

</details>

@marcmognol
Copy link
Contributor Author

Sorry, I forgot to put my logs. It should be ok now. Thanks

@rarkins
Copy link
Collaborator

rarkins commented Dec 9, 2021

I think the first thing we need to do is detect this git error as "not found":

DEBUG: git error (repository=IFS/MyCompany.MyProject)
       "err": {
         "task": {
           "commands": [
             "-c",
             "http.extraheader=AUTHORIZATION: basic **redacted**",
             "ls-remote",
             "--heads",
             "https://[email protected]/my-company/IFS/_git/MyCompany.MyProject"
           ],
           "format": "utf-8",
           "parser": "[function]"
         },
         "message": "remote: TF401019: The Git repository with name or identifier MyCompany.MyProject does not exist or you do not have permissions for the operation you are attempting.\nfatal: repository 'https://dev.azure.com/my-company/IFS/_git/MyCompany.MyProject/' not found\n",
         "stack": "Error: remote: TF401019: The Git repository with name or identifier MyCompany.MyProject does not exist or you do not have permissions for the operation you are attempting.\nfatal: repository 'https://dev.azure.com/my-company/IFS/_git/MyCompany.MyProject/' not found\n\n    at Object.action (/usr/src/app/node_modules/simple-git/src/lib/plugins/error-detection.plugin.ts:38:28)\n    at PluginStore.exec (/usr/src/app/node_modules/simple-git/src/lib/plugins/plugin-store.ts:24:29)\n    at /usr/src/app/node_modules/simple-git/src/lib/runners/git-executor-chain.ts:114:40\n    at new Promise (<anonymous>)\n    at GitExecutorChain.handleTaskData (/usr/src/app/node_modules/simple-git/src/lib/runners/git-executor-chain.ts:111:14)\n    at GitExecutorChain.<anonymous> (/usr/src/app/node_modules/simple-git/src/lib/runners/git-executor-chain.ts:88:40)\n    at Generator.next (<anonymous>)\n    at fulfilled (/usr/src/app/node_modules/simple-git/src/lib/runners/git-executor-chain.js:5:58)\n    at processTicksAndRejections (internal/process/task_queues.js:95:5)"
       }

That might be enough, but I'm not sure.

@rarkins rarkins added platform:azure Azure DevOps platform priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others status:ready and removed priority-5-triage auto:logs Issue or Discussion is needs logs/more logs status:requirements Full requirements are not yet known, so implementation should not be started labels Dec 9, 2021
@viceice
Copy link
Member

viceice commented Dec 9, 2021

TF401019 would be enough.

@olegkrivtsov
Copy link
Contributor

I'd like to help with this one.

@olegkrivtsov
Copy link
Contributor

My plan for fixing this issue:

  1. Modify lib/workers/repository/error.ts around this place:
    if (err.message === REPOSITORY_NOT_FOUND) {
    delete config.branchList;
    logger.error('Repository is not found');
    return err.message;
    }

Check if the platform is Azure and err.message contains TF401019, then return REPOSITORY_NOT_FOUND instead of unknown error.

@viceice
Copy link
Member

viceice commented Dec 21, 2021

I think you need to modify here:

if (!repo.defaultBranch) {
logger.debug('Repo is empty');
throw new Error(REPOSITORY_EMPTY);
}

and add

    if (repo.isDisabled) {
      logger.debug(
        'Repository is disabled- throwing error to abort renovation'
      );
      throw new Error(REPOSITORY_ARCHIVED);
    }

@renovate-release
Copy link
Collaborator

🎉 This issue has been resolved in version 31.11.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
platform:azure Azure DevOps platform priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others type:feature Feature (new functionality)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants