Avoid silent failures during a GitHub sync script run
In order to avoid silent failures, it would be good to ensure that the sync script process exits in a way that marks the k8s job as "failed" instead of "succeeded".
Example was today's issue with the ditto org forbidding access via classic personal access token, that lead to the sync script run failing without anyone noticing until looking into the pod logs.
2023-05-15T09:41:26 [GitWrapper] DEBUG prefetchTeams(org = eclipse-ditto)
2023-05-15T09:41:26 [GitWrapper] INFO Starting prefetch for teams in org=eclipse-ditto
2023-05-15T09:41:26 [GitWrapper] ERROR API encountered errors processing current request (team:list). More information is available in log file
2023-05-15T09:41:26 [GitWrapper] ERROR HttpError: `eclipse-ditto` forbids access via a personal access token (classic). Please use a GitHub App, OAuth App, or a personal access token with fine-grained permissions.
2023-05-15T09:41:26 [GitWrapper] ERROR An error occured while prefetching teams for org 'eclipse-ditto', returning
2023-05-15T09:41:26 [GitWrapper] DEBUG prefetchRepos(org = eclipse-ditto)
2023-05-15T09:41:26 [GitWrapper] VERBOSE Starting prefetch for repos in org=eclipse-ditto
2023-05-15T09:41:26 [GitWrapper] ERROR API encountered errors processing current request (team:listMembers). More information is available in log file
2023-05-15T09:41:26 [GitWrapper] ERROR HttpError: `eclipse-ditto` forbids access via a personal access token (classic). Please use a GitHub App, OAuth App, or a personal access token with fine-grained permissions.
2023-05-15T09:41:26 [GitWrapper] ERROR An error occured while prefetching repos for org 'eclipse-ditto', returning
2023-05-15T09:41:26 [main] DEBUG Sync:updateTeam(org = eclipse-ditto, teamName = eclipsefdn-security, designatedMembers = [{"name":"mbarbero","url":"https://api.eclipse.org/account/profile/mbarbero","expiration":""},{"name":"fgurr","url":"https://api.eclipse.org/account/profile/fgurr","expiration":""},{"name":"netomi","url":"https://api.eclipse.org/account/profile/netomi","expiration":""},{"name":"fcojperez","url":"https://api.eclipse.org/account/profile/fcojperez","expiration":""},{"name":"mrybczyn","url":"https://api.eclipse.org/account/profile/mrybczyn","expiration":""}])
2023-05-15T09:41:26 [main] INFO Syncing team 'eclipsefdn-security' for organization eclipse-ditto
2023-05-15T09:41:26 [GitWrapper] DEBUG addTeam(org = eclipse-ditto, teamName = eclipsefdn-security)
2023-05-15T09:41:27 [GitWrapper] ERROR API encountered errors processing current request (team:create). More information is available in log file
2023-05-15T09:41:27 [GitWrapper] ERROR HttpError: `eclipse-ditto` forbids access via a personal access token (classic). Please use a GitHub App, OAuth App, or a personal access token with fine-grained permissions.
2023-05-15T09:41:27 [GitWrapper] DEBUG editTeam(org = eclipse-ditto, team = "eclipsefdn-security", options = {"privacy":"secret"})
2023-05-15T09:41:27 [GitWrapper] VERBOSE Updating team eclipsefdn-security settings: {"privacy":"secret"}
2023-05-15T09:41:27 [GitWrapper] ERROR API encountered errors processing current request (team:getByName). More information is available in log file
2023-05-15T09:41:27 [GitWrapper] ERROR HttpError: Not Found
2023-05-15T09:41:27 [GitWrapper] WARN Could not find team with name eclipsefdn-security to update
(node:22) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'name' of undefined
at getTeamMembers (/app/src/GitWrapper.js:905:51)
at module.exports.getTeamMembers (/app/src/GitWrapper.js:404:12)
at updateTeam (/app/src/Sync.js:458:28)
at async processOrg (/app/src/Sync.js:432:5)
at async processStaticTeam (/app/src/Sync.js:320:7)
at async runSync (/app/src/Sync.js:197:5)
at async _init (/app/src/Sync.js:149:3)
(node:22) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 544)
(node:22) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
┌──────────────────────────────────────────────┐
│ npm update check failed │
│ Try running with sudo or get access │
│ to the local update config store via │
│ sudo chown -R $USER:$(id -gn $USER) /.config │
└──────────────────────────────────────────────┘