From da8f5304c10e30a05174d343eab907c2e520e55c Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Mon, 5 Feb 2024 12:34:01 -0600 Subject: [PATCH] Deprecate activeSystems* --- docs/administering-lagoon/create-project.gql | 2 - docs/administering-lagoon/graphql-queries.md | 2 - .../using-harbor/harbor-settings/README.md | 2 +- node-packages/commons/src/api.ts | 59 -- node-packages/commons/src/deploy-tasks.ts | 99 +-- node-packages/commons/src/tasks.ts | 787 ++++++++---------- .../20240119101016_remove_activesystems.js | 29 + services/api/src/mocks.js | 4 - .../api/src/resources/project/resolvers.ts | 15 - services/api/src/resources/project/sql.ts | 10 - services/api/src/typeDefs.js | 30 +- .../src/handlers/bitbucketBranchDeleted.ts | 2 - .../handlers/bitbucketPullRequestClosed.ts | 2 - .../handlers/bitbucketPullRequestUpdated.ts | 2 - .../src/handlers/bitbucketPush.ts | 2 - .../src/handlers/giteaBranchDeleted.ts | 2 - .../src/handlers/giteaPullRequestClosed.ts | 2 - .../src/handlers/giteaPullRequestOpened.ts | 2 - .../handlers/giteaPullRequestSynchronize.ts | 2 - .../webhooks2tasks/src/handlers/giteaPush.ts | 2 - .../src/handlers/githubBranchDeleted.ts | 2 - .../src/handlers/githubPullRequestClosed.ts | 2 - .../src/handlers/githubPullRequestOpened.ts | 2 - .../handlers/githubPullRequestSynchronize.ts | 2 - .../webhooks2tasks/src/handlers/githubPush.ts | 2 - .../src/handlers/gitlabBranchDeleted.ts | 2 - .../src/handlers/gitlabPullRequestClosed.ts | 2 - .../src/handlers/gitlabPullRequestOpened.ts | 2 - .../src/handlers/gitlabPullRequestUpdated.ts | 2 - .../webhooks2tasks/src/handlers/gitlabPush.ts | 2 - 30 files changed, 402 insertions(+), 675 deletions(-) create mode 100644 services/api/database/migrations/20240119101016_remove_activesystems.js diff --git a/docs/administering-lagoon/create-project.gql b/docs/administering-lagoon/create-project.gql index 53421c4522..503be86771 100644 --- a/docs/administering-lagoon/create-project.gql +++ b/docs/administering-lagoon/create-project.gql @@ -50,8 +50,6 @@ mutation { id } gitUrl - activeSystemsDeploy - activeSystemsRemove branches pullrequests } diff --git a/docs/administering-lagoon/graphql-queries.md b/docs/administering-lagoon/graphql-queries.md index 0aff02f00c..7638b91f38 100644 --- a/docs/administering-lagoon/graphql-queries.md +++ b/docs/administering-lagoon/graphql-queries.md @@ -298,8 +298,6 @@ mutation { id } gitUrl - activeSystemsDeploy - activeSystemsRemove branches pullrequests } diff --git a/docs/administering-lagoon/using-harbor/harbor-settings/README.md b/docs/administering-lagoon/using-harbor/harbor-settings/README.md index f95848cd2f..1321778aa4 100644 --- a/docs/administering-lagoon/using-harbor/harbor-settings/README.md +++ b/docs/administering-lagoon/using-harbor/harbor-settings/README.md @@ -1,6 +1,6 @@ # Running Harbor Locally -Lagoon supports running Harbor locally, and it is automatically used for hosting all Kubernetes-based builds (any time the project's `activeSystemsDeploy` value is set to `lagoon_kubernetesBuildDeploy`). When Harbor is ran locally, it makes use of MinIO as a storage backend, which is an AWS S3 compatible local storage solution. +Lagoon supports running Harbor locally, where it makes use of MinIO as a storage backend, which is an AWS S3 compatible local storage solution. ## Settings diff --git a/node-packages/commons/src/api.ts b/node-packages/commons/src/api.ts index f88ec4517e..bdbf85ffc1 100644 --- a/node-packages/commons/src/api.ts +++ b/node-packages/commons/src/api.ts @@ -15,8 +15,6 @@ export interface Project { envVariables?: any; gitUrl?: string; subfolder?: string; - activesystemsdeploy?: string; - activesystemsremove?: string; branches?: string; productionenvironment?: string; autoidle?: number; @@ -57,8 +55,6 @@ interface ProjectPatch { gitUrl?: string; subfolder?: string; routerPattern?: string; - activesystemsdeploy?: string; - activesystemsremove?: string; branches?: string; productionenvironment?: string; autoidle?: number; @@ -155,13 +151,6 @@ class EnvironmentNotFound extends Error { } } -class NoActiveSystemsDefined extends Error { - constructor(message) { - super(message); - this.name = 'NoActiveSystemsDefined'; - } -} - const sshKeyFragment = graphqlapi.createFragment(` fragment on SshKey { id @@ -834,54 +823,6 @@ export async function getEmailInfoForProject( return result.project.emails; } -interface GetActiveSystemForProjectResult { - id: number; - branches: string; - pullrequests: string; - organization: number; - activeSystemsDeploy: string; - activeSystemsPromote: string; - activeSystemsRemove: string; - activeSystemsTask: string; - activeSystemsMisc: string; -} - -export async function getActiveSystemForProject( - project: string, - task: 'Deploy' | 'Promote' | 'Remove' | 'Task' | 'Misc' -): Promise { - const field = `activeSystems${task}`; - const result = await graphqlapi.query(` - { - project:projectByName(name: "${project}"){ - id - activeSystemsDeploy - activeSystemsPromote - activeSystemsRemove - activeSystemsTask - activeSystemsMisc - branches - pullrequests - organization - } - } - `); - - if (!result || !result.project) { - throw new ProjectNotFound( - `Cannot find active-systems information for project ${project}` - ); - } - - if (!result.project[field]) { - throw new NoActiveSystemsDefined( - `Cannot find active system for task ${task} in project ${project}` - ); - } - - return result.project; -} - export async function getEnvironmentByName( name: string, projectId: number, diff --git a/node-packages/commons/src/deploy-tasks.ts b/node-packages/commons/src/deploy-tasks.ts index a9ed58a6e7..7a69309487 100644 --- a/node-packages/commons/src/deploy-tasks.ts +++ b/node-packages/commons/src/deploy-tasks.ts @@ -18,13 +18,6 @@ class NoNeedToDeployBranch extends Error { } } -class UnknownActiveSystem extends Error { - constructor(message) { - super(message); - this.name = 'UnknownActiveSystem'; - } -} - /* this function handles deploying a branch */ @@ -42,35 +35,14 @@ const deployBranch = async function(data: any) { switch (branchesRegex) { case undefined: case null: - logger.debug( - `projectName: ${projectName}, branchName: ${branchName}, no branches defined in active system, assuming we want all of them` - ); - switch (project.activeSystemsDeploy) { - case 'lagoon_controllerBuildDeploy': - deployData.deployTarget = deployTarget - const buildDeployData = await getControllerBuildData(deployData); - const sendTasks = await sendToLagoonTasks(buildDeployData.spec.project.deployTarget+':builddeploy', buildDeployData); - return true - default: - throw new UnknownActiveSystem( - `Unknown active system '${project.activeSystemsDeploy}' for task 'deploy' in for project ${projectName}` - ); - } case 'true': logger.debug( `projectName: ${projectName}, branchName: ${branchName}, all branches active, therefore deploying` ); - switch (project.activeSystemsDeploy) { - case 'lagoon_controllerBuildDeploy': - deployData.deployTarget = deployTarget - const buildDeployData = await getControllerBuildData(deployData); - const sendTasks = await sendToLagoonTasks(buildDeployData.spec.project.deployTarget+':builddeploy', buildDeployData); - return true - default: - throw new UnknownActiveSystem( - `Unknown active system '${project.activeSystemsDeploy}' for task 'deploy' in for project ${projectName}` - ); - } + deployData.deployTarget = deployTarget + const buildDeployData = await getControllerBuildData(deployData); + await sendToLagoonTasks(buildDeployData.spec.project.deployTarget+':builddeploy', buildDeployData); + return true case 'false': logger.debug( `projectName: ${projectName}, branchName: ${branchName}, branch deployments disabled` @@ -85,18 +57,11 @@ const deployBranch = async function(data: any) { logger.debug( `projectName: ${projectName}, branchName: ${branchName}, regex ${branchesRegex} matched branchname, starting deploy` ); - switch (project.activeSystemsDeploy) { - case 'lagoon_controllerBuildDeploy': - // controllers uses a different message than the other services, so we need to source it here - deployData.deployTarget = deployTarget - const buildDeployData = await getControllerBuildData(deployData); - const sendTasks = await sendToLagoonTasks(buildDeployData.spec.project.deployTarget+':builddeploy', buildDeployData); - return true - default: - throw new UnknownActiveSystem( - `Unknown active system '${project.activeSystemsDeploy}' for task 'deploy' in for project ${projectName}` - ); - } + // controllers uses a different message than the other services, so we need to source it here + deployData.deployTarget = deployTarget + const buildDeployData = await getControllerBuildData(deployData); + await sendToLagoonTasks(buildDeployData.spec.project.deployTarget+':builddeploy', buildDeployData); + return true } logger.debug( `projectName: ${projectName}, branchName: ${branchName}, regex ${branchesRegex} did not match branchname, not deploying` @@ -124,35 +89,14 @@ const deployPullrequest = async function(data: any) { switch (pullrequestRegex) { case undefined: case null: - logger.debug( - `projectName: ${projectName}, pullrequest: ${branchName}, no pullrequest defined in active system, assuming we want all of them` - ); - switch (project.activeSystemsDeploy) { - case 'lagoon_controllerBuildDeploy': - deployData.deployTarget = deployTarget - const buildDeployData = await getControllerBuildData(deployData); - const sendTasks = await sendToLagoonTasks(buildDeployData.spec.project.deployTarget+':builddeploy', buildDeployData); - return true - default: - throw new UnknownActiveSystem( - `Unknown active system '${project.activeSystemsDeploy}' for task 'deploy' in for project ${projectName}` - ); - } case 'true': logger.debug( `projectName: ${projectName}, pullrequest: ${branchName}, all pullrequest active, therefore deploying` ); - switch (project.activeSystemsDeploy) { - case 'lagoon_controllerBuildDeploy': - deployData.deployTarget = deployTarget - const buildDeployData = await getControllerBuildData(deployData); - const sendTasks = await sendToLagoonTasks(buildDeployData.spec.project.deployTarget+':builddeploy', buildDeployData); - return true - default: - throw new UnknownActiveSystem( - `Unknown active system '${project.activeSystemsDeploy}' for task 'deploy' in for project ${projectName}` - ); - } + deployData.deployTarget = deployTarget + const buildDeployData = await getControllerBuildData(deployData); + await sendToLagoonTasks(buildDeployData.spec.project.deployTarget+':builddeploy', buildDeployData); + return true case 'false': logger.debug( `projectName: ${projectName}, pullrequest: ${branchName}, pullrequest deployments disabled` @@ -167,18 +111,11 @@ const deployPullrequest = async function(data: any) { logger.debug( `projectName: ${projectName}, pullrequest: ${branchName}, regex ${pullrequestRegex} matched PR title '${pullrequestTitle}', starting deploy` ); - switch (project.activeSystemsDeploy) { - case 'lagoon_controllerBuildDeploy': - // controllers uses a different message than the other services, so we need to source it here - deployData.deployTarget = deployTarget - const buildDeployData = await getControllerBuildData(deployData); - const sendTasks = await sendToLagoonTasks(buildDeployData.spec.project.deployTarget+':builddeploy', buildDeployData); - return true - default: - throw new UnknownActiveSystem( - `Unknown active system '${project.activeSystemsDeploy}' for task 'deploy' in for project ${projectName}` - ); - } + // controllers uses a different message than the other services, so we need to source it here + deployData.deployTarget = deployTarget + const buildDeployData = await getControllerBuildData(deployData); + await sendToLagoonTasks(buildDeployData.spec.project.deployTarget+':builddeploy', buildDeployData); + return true } logger.debug( `projectName: ${projectName}, branchName: ${branchName}, regex ${pullrequestRegex} did not match PR title, not deploying` diff --git a/node-packages/commons/src/tasks.ts b/node-packages/commons/src/tasks.ts index 9af665f082..bdbfcd2d36 100644 --- a/node-packages/commons/src/tasks.ts +++ b/node-packages/commons/src/tasks.ts @@ -7,11 +7,9 @@ import { import { ConfirmChannel, ConsumeMessage } from 'amqplib'; import { logger } from './logs/local-logger'; import { - getActiveSystemForProject, getEnvironmentsForProject, getOpenShiftInfoForProject, getOpenShiftInfoForEnvironment, - getDeployTargetConfigsForProject, getEnvironmentByIdWithVariables, addOrUpdateEnvironment, getEnvironmentByName, @@ -127,20 +125,6 @@ const overwriteActiveStandbyTaskImage = process.env.OVERWRITE_ACTIVESTANDBY_TASK const jwtSecretString = process.env.JWTSECRET || "super-secret-string" const projectSeedString = process.env.PROJECTSEED || "super-secret-string" -class UnknownActiveSystem extends Error { - constructor(message) { - super(message); - this.name = 'UnknownActiveSystem'; - } -} - -class CannotDeployWithDeployTargetConfigs extends Error { - constructor(message) { - super(message); - this.name = 'CannotDeployWithDeployTargetConfigs'; - } -} - class NoNeedToRemoveBranch extends Error { constructor(message) { super(message); @@ -776,7 +760,7 @@ export const createDeployTask = async function(deployData: any) { pullrequestTitle } = deployData; - const project = await getActiveSystemForProject(projectName, 'Deploy'); + const project = await getOpenShiftInfoForProject(projectName); const environments = await getEnvironmentsForProject(projectName); if (project.organization) { @@ -798,104 +782,90 @@ export const createDeployTask = async function(deployData: any) { // production_environment: 'master', // environments: [ { name: 'develop', environment_type: 'development' }, [Object] ] } } - if (typeof project.activeSystemsDeploy === 'undefined') { - throw new UnknownActiveSystem( - `No active system for tasks 'deploy' in for project ${projectName}` + // we want to limit production environments, without making it configurable currently + var productionEnvironmentsLimit = 2; + + // we want to make sure we can deploy the `production` env, and also the env defined as standby + if ( + environments.project.productionEnvironment === branchName || + environments.project.standbyProductionEnvironment === branchName + ) { + // get a list of production environments + const prod_environments = environments.project.environments + .filter(e => e.environmentType === 'production') + .map(e => e.name); + logger.debug( + `projectName: ${projectName}, branchName: ${branchName}, existing environments are ${prod_environments}` ); - } - switch (project.activeSystemsDeploy) { - case 'lagoon_controllerBuildDeploy': - // we want to limit production environments, without making it configurable currently - var productionEnvironmentsLimit = 2; - - // we want to make sure we can deploy the `production` env, and also the env defined as standby - if ( - environments.project.productionEnvironment === branchName || - environments.project.standbyProductionEnvironment === branchName - ) { - // get a list of production environments - const prod_environments = environments.project.environments - .filter(e => e.environmentType === 'production') - .map(e => e.name); + if (prod_environments.length >= productionEnvironmentsLimit) { + if (prod_environments.find(i => i === branchName)) { logger.debug( - `projectName: ${projectName}, branchName: ${branchName}, existing environments are ${prod_environments}` + `projectName: ${projectName}, branchName: ${branchName}, environment already exists, no environment limits considered` ); - - if (prod_environments.length >= productionEnvironmentsLimit) { - if (prod_environments.find(i => i === branchName)) { - logger.debug( - `projectName: ${projectName}, branchName: ${branchName}, environment already exists, no environment limits considered` - ); - } else { - throw new EnvironmentLimit( - `'${branchName}' would exceed the configured limit of ${productionEnvironmentsLimit} production environments for project ${projectName}` - ); - } - } } else { - // get a list of non-production environments - const dev_environments = environments.project.environments - .filter(e => e.environmentType === 'development') - .map(e => e.name); - logger.debug( - `projectName: ${projectName}, branchName: ${branchName}, existing environments are ${dev_environments}` + throw new EnvironmentLimit( + `'${branchName}' would exceed the configured limit of ${productionEnvironmentsLimit} production environments for project ${projectName}` ); - - if ( - environments.project.developmentEnvironmentsLimit !== null && - dev_environments.length >= - environments.project.developmentEnvironmentsLimit - ) { - if (dev_environments.find(i => i === branchName)) { - logger.debug( - `projectName: ${projectName}, branchName: ${branchName}, environment already exists, no environment limits considered` - ); - } else { - throw new EnvironmentLimit( - `'${branchName}' would exceed the configured limit of ${environments.project.developmentEnvironmentsLimit} development environments for project ${projectName}` - ); - } - } } + } + } else { + // get a list of non-production environments + const dev_environments = environments.project.environments + .filter(e => e.environmentType === 'development') + .map(e => e.name); + logger.debug( + `projectName: ${projectName}, branchName: ${branchName}, existing environments are ${dev_environments}` + ); - if (type === 'branch') { - // use deployTargetBranches function to handle - let lagoonData = { - projectId: environments.project.id, - projectName, - branchName, - project, - deployData - } - try { - let result = deployTargetBranches(lagoonData) - return result - } catch (error) { - throw error - } - } else if (type === 'pullrequest') { - // use deployTargetPullrequest function to handle - let lagoonData = { - projectId: environments.project.id, - projectName, - branchName, - project, - pullrequestTitle, - deployData - } - try { - let result = deployTargetPullrequest(lagoonData) - return result - } catch (error) { - throw error - } + if ( + environments.project.developmentEnvironmentsLimit !== null && + dev_environments.length >= + environments.project.developmentEnvironmentsLimit + ) { + if (dev_environments.find(i => i === branchName)) { + logger.debug( + `projectName: ${projectName}, branchName: ${branchName}, environment already exists, no environment limits considered` + ); + } else { + throw new EnvironmentLimit( + `'${branchName}' would exceed the configured limit of ${environments.project.developmentEnvironmentsLimit} development environments for project ${projectName}` + ); } - break; - default: - throw new UnknownActiveSystem( - `Unknown active system '${project.activeSystemsDeploy}' for task 'deploy' in for project ${projectName}` - ); + } + } + + if (type === 'branch') { + // use deployTargetBranches function to handle + let lagoonData = { + projectId: environments.project.id, + projectName, + branchName, + project, + deployData + } + try { + let result = deployTargetBranches(lagoonData) + return result + } catch (error) { + throw error + } + } else if (type === 'pullrequest') { + // use deployTargetPullrequest function to handle + let lagoonData = { + projectId: environments.project.id, + projectName, + branchName, + project, + pullrequestTitle, + deployData + } + try { + let result = deployTargetPullrequest(lagoonData) + return result + } catch (error) { + throw error + } } } @@ -907,27 +877,14 @@ export const createPromoteTask = async function(promoteData: any) { // type, } = promoteData; - const project = await getActiveSystemForProject(projectName, 'Promote'); + const project = await getOpenShiftInfoForProject(projectName); - if (typeof project.activeSystemsPromote === 'undefined') { - throw new UnknownActiveSystem( - `No active system for tasks 'deploy' in for project ${projectName}` - ); - } - - switch (project.activeSystemsPromote) { - case 'lagoon_controllerBuildDeploy': - // use deployTargetPromote function to handle - let lagoonData = { - projectId: project.id, - promoteData - } - return deployTargetPromote(lagoonData) - default: - throw new UnknownActiveSystem( - `Unknown active system '${project.activeSystemsPromote}' for task 'deploy' in for project ${projectName}` - ); + // use deployTargetPromote function to handle + let lagoonData = { + projectId: project.id, + promoteData } + return deployTargetPromote(lagoonData) } export const createRemoveTask = async function(removeData: any) { @@ -958,114 +915,95 @@ export const createRemoveTask = async function(removeData: any) { } } - const project = await getActiveSystemForProject(projectName, 'Remove'); + if (type === 'branch') { + let environmentId = 0; + // Check to ensure the environment actually exists. + let foundEnvironment = false; + allEnvironments.project.environments.forEach(function( + environment, + index + ) { + if (environment.name === branch) { + foundEnvironment = true; + environmentId = environment.id; + } + }); - if (typeof project.activeSystemsRemove === 'undefined') { - throw new UnknownActiveSystem( - `No active system for tasks 'remove' in for project ${projectName}` + if (!foundEnvironment) { + logger.debug( + `projectName: ${projectName}, branchName: ${branch}, no environment found.` + ); + throw new NoNeedToRemoveBranch( + 'Branch environment does not exist, no need to remove anything.' + ); + } + // consume the deploytarget from the environment now + const result = await getOpenShiftInfoForEnvironment(environmentId); + const deployTarget = result.environment.openshift.name + logger.debug( + `projectName: ${projectName}, branchName: ${branchName}. Removing branch environment.` ); - } + // use the targetname as the routing key with the action + return sendToLagoonTasks(deployTarget+":remove", removeData); + } else if (type === 'pullrequest') { + // Work out the branch name from the PR number. + let branchName = 'pr-' + pullrequestNumber; + removeData.branchName = 'pr-' + pullrequestNumber; + + let environmentId = 0; + // Check to ensure the environment actually exists. + let foundEnvironment = false; + allEnvironments.project.environments.forEach(function( + environment, + index + ) { + if (environment.name === branchName) { + foundEnvironment = true; + environmentId = environment.id; + } + }); - switch (project.activeSystemsRemove) { - // removed `openshift` and `kubernetes` remove functionality, these services no longer exist in Lagoon - // handle removals using the controllers, send the message to our specific target cluster queue - case 'lagoon_controllerRemove': - if (type === 'branch') { - let environmentId = 0; - // Check to ensure the environment actually exists. - let foundEnvironment = false; - allEnvironments.project.environments.forEach(function( - environment, - index - ) { - if (environment.name === branch) { - foundEnvironment = true; - environmentId = environment.id; - } - }); - - if (!foundEnvironment) { - logger.debug( - `projectName: ${projectName}, branchName: ${branch}, no environment found.` - ); - throw new NoNeedToRemoveBranch( - 'Branch environment does not exist, no need to remove anything.' - ); - } - // consume the deploytarget from the environment now - const result = await getOpenShiftInfoForEnvironment(environmentId); - const deployTarget = result.environment.openshift.name - logger.debug( - `projectName: ${projectName}, branchName: ${branchName}. Removing branch environment.` - ); - // use the targetname as the routing key with the action - return sendToLagoonTasks(deployTarget+":remove", removeData); - } else if (type === 'pullrequest') { - // Work out the branch name from the PR number. - let branchName = 'pr-' + pullrequestNumber; - removeData.branchName = 'pr-' + pullrequestNumber; - - let environmentId = 0; - // Check to ensure the environment actually exists. - let foundEnvironment = false; - allEnvironments.project.environments.forEach(function( - environment, - index - ) { - if (environment.name === branchName) { - foundEnvironment = true; - environmentId = environment.id; - } - }); - - if (!foundEnvironment) { - logger.debug( - `projectName: ${projectName}, pullrequest: ${branchName}, no pullrequest found.` - ); - throw new NoNeedToRemoveBranch( - 'Pull Request environment does not exist, no need to remove anything.' - ); - } - // consume the deploytarget from the environment now - const result = await getOpenShiftInfoForEnvironment(environmentId); - const deployTarget = result.environment.openshift.name - logger.debug( - `projectName: ${projectName}, pullrequest: ${branchName}. Removing pullrequest environment.` - ); - return sendToLagoonTasks(deployTarget+":remove", removeData); - } else if (type === 'promote') { - let environmentId = 0; - // Check to ensure the environment actually exists. - let foundEnvironment = false; - allEnvironments.project.environments.forEach(function( - environment, - index - ) { - if (environment.name === branch) { - foundEnvironment = true; - environmentId = environment.id; - } - }); - - if (!foundEnvironment) { - logger.debug( - `projectName: ${projectName}, branchName: ${branch}, no environment found.` - ); - throw new NoNeedToRemoveBranch( - 'Branch environment does not exist, no need to remove anything.' - ); - } - // consume the deploytarget from the environment now - const result = await getOpenShiftInfoForEnvironment(environmentId); - const deployTarget = result.environment.openshift.name - return sendToLagoonTasks(deployTarget+":remove", removeData); + if (!foundEnvironment) { + logger.debug( + `projectName: ${projectName}, pullrequest: ${branchName}, no pullrequest found.` + ); + throw new NoNeedToRemoveBranch( + 'Pull Request environment does not exist, no need to remove anything.' + ); + } + // consume the deploytarget from the environment now + const result = await getOpenShiftInfoForEnvironment(environmentId); + const deployTarget = result.environment.openshift.name + logger.debug( + `projectName: ${projectName}, pullrequest: ${branchName}. Removing pullrequest environment.` + ); + return sendToLagoonTasks(deployTarget+":remove", removeData); + } else if (type === 'promote') { + let environmentId = 0; + // Check to ensure the environment actually exists. + let foundEnvironment = false; + allEnvironments.project.environments.forEach(function( + environment, + index + ) { + if (environment.name === branch) { + foundEnvironment = true; + environmentId = environment.id; } - break; + }); - default: - throw new UnknownActiveSystem( - `Unknown active system '${project.activeSystemsRemove}' for task 'remove' in for project ${projectName}` + if (!foundEnvironment) { + logger.debug( + `projectName: ${projectName}, branchName: ${branch}, no environment found.` + ); + throw new NoNeedToRemoveBranch( + 'Branch environment does not exist, no need to remove anything.' ); + } + // consume the deploytarget from the environment now + const result = await getOpenShiftInfoForEnvironment(environmentId); + const deployTarget = result.environment.openshift.name + return sendToLagoonTasks(deployTarget+":remove", removeData); } } @@ -1139,8 +1077,6 @@ export const getBaasBucketName = async (project: Project, deploytarget: DeployTa export const createTaskTask = async function(taskData: any) { const { project } = taskData; - const projectSystem = await getActiveSystemForProject(project.name, 'Task'); - // inject variables into tasks the same way it is in builds const [_, envVars, projectVars] = await getTaskProjectEnvironmentVariables( project.name, @@ -1160,25 +1096,11 @@ export const createTaskTask = async function(taskData: any) { taskData.project.organization = organization } - if (typeof projectSystem.activeSystemsTask === 'undefined') { - throw new UnknownActiveSystem( - `No active system for 'task' for project ${project.name}` - ); - } - - switch (projectSystem.activeSystemsTask) { - case 'lagoon_controllerJob': - // since controllers queues are named, we have to send it to the right tasks queue - // do that here by querying which deploytarget the environment uses - const result = await getOpenShiftInfoForEnvironment(taskData.environment.id); - const deployTarget = result.environment.openshift.name - return sendToLagoonTasks(deployTarget+":jobs", taskData); - - default: - throw new UnknownActiveSystem( - `Unknown active system '${projectSystem.activeSystemsTask}' for 'task' for project ${project.name}` - ); - } + // since controllers queues are named, we have to send it to the right tasks queue + // do that here by querying which deploytarget the environment uses + const result = await getOpenShiftInfoForEnvironment(taskData.environment.id); + const deployTarget = result.environment.openshift.name + return sendToLagoonTasks(deployTarget+":jobs", taskData); } export const createMiscTask = async function(taskData: any) { @@ -1187,208 +1109,197 @@ export const createMiscTask = async function(taskData: any) { data: { project } } = taskData; - const data = await getActiveSystemForProject(project.name, 'Misc'); - - let updatedKey = key; - let taskId = ''; - switch (data.activeSystemsMisc) { - case 'lagoon_controllerMisc': - // handle any controller based misc tasks - updatedKey = `deploytarget:${key}`; - taskId = 'misc-kubernetes'; - // determine the deploy target (openshift/kubernetes) for the task to go to - // we get this from the environment - const result = await getOpenShiftInfoForEnvironment(taskData.data.environment.id); - const deployTarget = result.environment.openshift.name - // this is the json structure for sending a misc task to the controller - // there are some additional bits that can be adjusted, and these are done in the switch below on `updatedKey` - var miscTaskData: any = { - misc: {}, - key: updatedKey, - environment: { - name: taskData.data.environment.name, - openshiftProjectName: taskData.data.environment.openshiftProjectName - }, - project: { - name: taskData.data.project.name - }, - task: taskData.data.task, - advancedTask: {} + // handle any controller based misc tasks + let updatedKey = `deploytarget:${key}`; + let taskId = 'misc-kubernetes'; + // determine the deploy target (openshift/kubernetes) for the task to go to + // we get this from the environment + const result = await getOpenShiftInfoForEnvironment(taskData.data.environment.id); + const deployTarget = result.environment.openshift.name + // this is the json structure for sending a misc task to the controller + // there are some additional bits that can be adjusted, and these are done in the switch below on `updatedKey` + var miscTaskData: any = { + misc: {}, + key: updatedKey, + environment: { + name: taskData.data.environment.name, + openshiftProjectName: taskData.data.environment.openshiftProjectName + }, + project: { + name: taskData.data.project.name + }, + task: taskData.data.task, + advancedTask: {} + } + switch (updatedKey) { + case 'deploytarget:restic:backup:restore': + // Handle setting up the configuration for a restic restoration task + const randRestoreId = Math.random().toString(36).substring(7); + const restoreName = `restore-${R.slice(0, 7, taskData.data.backup.backupId)}-${randRestoreId}`; + // Parse out the baasBucketName for any migrated projects + // check if the project is configured for a shared baas bucket + let [baasBucketName, shared] = await getBaasBucketName(result.environment.project, result.environment.openshift) + if (shared) { + // if it is a shared bucket, add the repo key to it too for restores + baasBucketName = `${baasBucketName}/baas-${makeSafe(taskData.data.project.name)}` + } + // Handle custom backup configurations + let lagoonBaasCustomBackupEndpoint = result.environment.project.envVariables.find(obj => { + return obj.name === "LAGOON_BAAS_CUSTOM_BACKUP_ENDPOINT" + }) + if (lagoonBaasCustomBackupEndpoint) { + lagoonBaasCustomBackupEndpoint = lagoonBaasCustomBackupEndpoint.value + } + let lagoonBaasCustomBackupBucket = result.environment.project.envVariables.find(obj => { + return obj.name === "LAGOON_BAAS_CUSTOM_BACKUP_BUCKET" + }) + if (lagoonBaasCustomBackupBucket) { + lagoonBaasCustomBackupBucket = lagoonBaasCustomBackupBucket.value + } + let lagoonBaasCustomBackupAccessKey = result.environment.project.envVariables.find(obj => { + return obj.name === "LAGOON_BAAS_CUSTOM_BACKUP_ACCESS_KEY" + }) + if (lagoonBaasCustomBackupAccessKey) { + lagoonBaasCustomBackupAccessKey = lagoonBaasCustomBackupAccessKey.value + } + let lagoonBaasCustomBackupSecretKey = result.environment.project.envVariables.find(obj => { + return obj.name === "LAGOON_BAAS_CUSTOM_BACKUP_SECRET_KEY" + }) + if (lagoonBaasCustomBackupSecretKey) { + lagoonBaasCustomBackupSecretKey = lagoonBaasCustomBackupSecretKey.value } - switch (updatedKey) { - case 'deploytarget:restic:backup:restore': - // Handle setting up the configuration for a restic restoration task - const randRestoreId = Math.random().toString(36).substring(7); - const restoreName = `restore-${R.slice(0, 7, taskData.data.backup.backupId)}-${randRestoreId}`; - // Parse out the baasBucketName for any migrated projects - // check if the project is configured for a shared baas bucket - let [baasBucketName, shared] = await getBaasBucketName(result.environment.project, result.environment.openshift) - if (shared) { - // if it is a shared bucket, add the repo key to it too for restores - baasBucketName = `${baasBucketName}/baas-${makeSafe(taskData.data.project.name)}` - } - // Handle custom backup configurations - let lagoonBaasCustomBackupEndpoint = result.environment.project.envVariables.find(obj => { - return obj.name === "LAGOON_BAAS_CUSTOM_BACKUP_ENDPOINT" - }) - if (lagoonBaasCustomBackupEndpoint) { - lagoonBaasCustomBackupEndpoint = lagoonBaasCustomBackupEndpoint.value - } - let lagoonBaasCustomBackupBucket = result.environment.project.envVariables.find(obj => { - return obj.name === "LAGOON_BAAS_CUSTOM_BACKUP_BUCKET" - }) - if (lagoonBaasCustomBackupBucket) { - lagoonBaasCustomBackupBucket = lagoonBaasCustomBackupBucket.value - } - let lagoonBaasCustomBackupAccessKey = result.environment.project.envVariables.find(obj => { - return obj.name === "LAGOON_BAAS_CUSTOM_BACKUP_ACCESS_KEY" - }) - if (lagoonBaasCustomBackupAccessKey) { - lagoonBaasCustomBackupAccessKey = lagoonBaasCustomBackupAccessKey.value - } - let lagoonBaasCustomBackupSecretKey = result.environment.project.envVariables.find(obj => { - return obj.name === "LAGOON_BAAS_CUSTOM_BACKUP_SECRET_KEY" - }) - if (lagoonBaasCustomBackupSecretKey) { - lagoonBaasCustomBackupSecretKey = lagoonBaasCustomBackupSecretKey.value - } - let backupS3Config = {} - if (lagoonBaasCustomBackupEndpoint && lagoonBaasCustomBackupBucket && lagoonBaasCustomBackupAccessKey && lagoonBaasCustomBackupSecretKey) { - backupS3Config = { - endpoint: lagoonBaasCustomBackupEndpoint, - bucket: lagoonBaasCustomBackupBucket, - accessKeyIDSecretRef: { - name: "lagoon-baas-custom-backup-credentials", - key: "access-key" - }, - secretAccessKeySecretRef: { - name: "lagoon-baas-custom-backup-credentials", - key: "secret-key" - } - } - } else { - backupS3Config = { - bucket: baasBucketName ? baasBucketName : `baas-${makeSafe(taskData.data.project.name)}` - } + let backupS3Config = {} + if (lagoonBaasCustomBackupEndpoint && lagoonBaasCustomBackupBucket && lagoonBaasCustomBackupAccessKey && lagoonBaasCustomBackupSecretKey) { + backupS3Config = { + endpoint: lagoonBaasCustomBackupEndpoint, + bucket: lagoonBaasCustomBackupBucket, + accessKeyIDSecretRef: { + name: "lagoon-baas-custom-backup-credentials", + key: "access-key" + }, + secretAccessKeySecretRef: { + name: "lagoon-baas-custom-backup-credentials", + key: "secret-key" } + } + } else { + backupS3Config = { + bucket: baasBucketName ? baasBucketName : `baas-${makeSafe(taskData.data.project.name)}` + } + } - // Handle custom restore configurations - let lagoonBaasCustomRestoreEndpoint = result.environment.project.envVariables.find(obj => { - return obj.name === "LAGOON_BAAS_CUSTOM_RESTORE_ENDPOINT" - }) - if (lagoonBaasCustomRestoreEndpoint) { - lagoonBaasCustomRestoreEndpoint = lagoonBaasCustomRestoreEndpoint.value - } - let lagoonBaasCustomRestoreBucket = result.environment.project.envVariables.find(obj => { - return obj.name === "LAGOON_BAAS_CUSTOM_RESTORE_BUCKET" - }) - if (lagoonBaasCustomRestoreBucket) { - lagoonBaasCustomRestoreBucket = lagoonBaasCustomRestoreBucket.value - } - let lagoonBaasCustomRestoreAccessKey = result.environment.project.envVariables.find(obj => { - return obj.name === "LAGOON_BAAS_CUSTOM_RESTORE_ACCESS_KEY" - }) - if (lagoonBaasCustomRestoreAccessKey) { - lagoonBaasCustomRestoreAccessKey = lagoonBaasCustomRestoreAccessKey.value - } - let lagoonBaasCustomRestoreSecretKey = result.environment.project.envVariables.find(obj => { - return obj.name === "LAGOON_BAAS_CUSTOM_RESTORE_SECRET_KEY" - }) - if (lagoonBaasCustomRestoreSecretKey) { - lagoonBaasCustomRestoreSecretKey = lagoonBaasCustomRestoreSecretKey.value - } + // Handle custom restore configurations + let lagoonBaasCustomRestoreEndpoint = result.environment.project.envVariables.find(obj => { + return obj.name === "LAGOON_BAAS_CUSTOM_RESTORE_ENDPOINT" + }) + if (lagoonBaasCustomRestoreEndpoint) { + lagoonBaasCustomRestoreEndpoint = lagoonBaasCustomRestoreEndpoint.value + } + let lagoonBaasCustomRestoreBucket = result.environment.project.envVariables.find(obj => { + return obj.name === "LAGOON_BAAS_CUSTOM_RESTORE_BUCKET" + }) + if (lagoonBaasCustomRestoreBucket) { + lagoonBaasCustomRestoreBucket = lagoonBaasCustomRestoreBucket.value + } + let lagoonBaasCustomRestoreAccessKey = result.environment.project.envVariables.find(obj => { + return obj.name === "LAGOON_BAAS_CUSTOM_RESTORE_ACCESS_KEY" + }) + if (lagoonBaasCustomRestoreAccessKey) { + lagoonBaasCustomRestoreAccessKey = lagoonBaasCustomRestoreAccessKey.value + } + let lagoonBaasCustomRestoreSecretKey = result.environment.project.envVariables.find(obj => { + return obj.name === "LAGOON_BAAS_CUSTOM_RESTORE_SECRET_KEY" + }) + if (lagoonBaasCustomRestoreSecretKey) { + lagoonBaasCustomRestoreSecretKey = lagoonBaasCustomRestoreSecretKey.value + } - let restoreS3Config = {} - if (lagoonBaasCustomRestoreEndpoint && lagoonBaasCustomRestoreBucket && lagoonBaasCustomRestoreAccessKey && lagoonBaasCustomRestoreSecretKey) { - restoreS3Config = { - endpoint: lagoonBaasCustomRestoreEndpoint, - bucket: lagoonBaasCustomRestoreBucket, - accessKeyIDSecretRef: { - name: "lagoon-baas-custom-restore-credentials", - key: "access-key" - }, - secretAccessKeySecretRef: { - name: "lagoon-baas-custom-restore-credentials", - key: "secret-key" - } - } + let restoreS3Config = {} + if (lagoonBaasCustomRestoreEndpoint && lagoonBaasCustomRestoreBucket && lagoonBaasCustomRestoreAccessKey && lagoonBaasCustomRestoreSecretKey) { + restoreS3Config = { + endpoint: lagoonBaasCustomRestoreEndpoint, + bucket: lagoonBaasCustomRestoreBucket, + accessKeyIDSecretRef: { + name: "lagoon-baas-custom-restore-credentials", + key: "access-key" + }, + secretAccessKeySecretRef: { + name: "lagoon-baas-custom-restore-credentials", + key: "secret-key" } + } + } - // generate the restore CRD - const restoreConf = restoreConfig(restoreName, taskData.data.backup.backupId, backupS3Config, restoreS3Config) - //logger.info(restoreConf) - // base64 encode it - const restoreBytes = new Buffer(JSON.stringify(restoreConf).replace(/\\n/g, "\n")).toString('base64') - miscTaskData.misc.miscResource = restoreBytes - break; - case 'deploytarget:task:activestandby': - // handle setting up the task configuration for running the active/standby switch - // this uses the `advanced task` system in the controllers - // generate out custom json payload to send to the advanced task - var jsonPayload: any = { - productionEnvironment: taskData.data.productionEnvironment.name, - standbyEnvironment: taskData.data.environment.name, - sourceNamespace: makeSafe(taskData.data.environment.openshiftProjectName), - destinationNamespace: makeSafe(taskData.data.productionEnvironment.openshiftProjectName) - } - // encode it - const jsonPayloadBytes = new Buffer(JSON.stringify(jsonPayload).replace(/\\n/g, "\n")).toString('base64') - // set the task data up - miscTaskData.advancedTask.JSONPayload = jsonPayloadBytes - // use this image to run the task - let taskImage = "" - // choose which task image to use - if (CI == "true") { - taskImage = "172.17.0.1:5000/lagoon/task-activestandby:latest" - } else if (overwriteActiveStandbyTaskImage) { - // allow to overwrite the image we use via OVERWRITE_ACTIVESTANDBY_TASK_IMAGE env variable - taskImage = overwriteActiveStandbyTaskImage - } else { - taskImage = `uselagoon/task-activestandby:${lagoonVersion}` - } - miscTaskData.advancedTask.runnerImage = taskImage - // miscTaskData.advancedTask.runnerImage = "shreddedbacon/runner:latest" - break; - case 'deploytarget:task:advanced': - // inject variables into advanced tasks the same way it is in builds and standard tasks - const [_, envVars, projectVars] = await getTaskProjectEnvironmentVariables( - taskData.data.project.name, - taskData.data.environment.id - ) - miscTaskData.project.variables = { - project: projectVars, - environment: envVars, - } - miscTaskData.advancedTask = taskData.data.advancedTask - break; - case 'deploytarget:task:cancel': - // task cancellation is just a standard unmodified message - miscTaskData.misc = taskData.data.task - break; - case 'deploytarget:build:cancel': - // build cancellation is just a standard unmodified message - miscTaskData.misc = taskData.data.build - break; - default: - miscTaskData.misc = taskData.data.build - break; + // generate the restore CRD + const restoreConf = restoreConfig(restoreName, taskData.data.backup.backupId, backupS3Config, restoreS3Config) + //logger.info(restoreConf) + // base64 encode it + const restoreBytes = new Buffer(JSON.stringify(restoreConf).replace(/\\n/g, "\n")).toString('base64') + miscTaskData.misc.miscResource = restoreBytes + break; + case 'deploytarget:task:activestandby': + // handle setting up the task configuration for running the active/standby switch + // this uses the `advanced task` system in the controllers + // generate out custom json payload to send to the advanced task + var jsonPayload: any = { + productionEnvironment: taskData.data.productionEnvironment.name, + standbyEnvironment: taskData.data.environment.name, + sourceNamespace: makeSafe(taskData.data.environment.openshiftProjectName), + destinationNamespace: makeSafe(taskData.data.productionEnvironment.openshiftProjectName) } - // send the task to the queue - if (project.organization != null) { - const curOrg = await getOrganizationById(project.organization); - const organization = { - name: curOrg.name, - id: curOrg.id, - } - miscTaskData.project.organization = organization + // encode it + const jsonPayloadBytes = new Buffer(JSON.stringify(jsonPayload).replace(/\\n/g, "\n")).toString('base64') + // set the task data up + miscTaskData.advancedTask.JSONPayload = jsonPayloadBytes + // use this image to run the task + let taskImage = "" + // choose which task image to use + if (CI == "true") { + taskImage = "172.17.0.1:5000/lagoon/task-activestandby:latest" + } else if (overwriteActiveStandbyTaskImage) { + // allow to overwrite the image we use via OVERWRITE_ACTIVESTANDBY_TASK_IMAGE env variable + taskImage = overwriteActiveStandbyTaskImage + } else { + taskImage = `uselagoon/task-activestandby:${lagoonVersion}` + } + miscTaskData.advancedTask.runnerImage = taskImage + // miscTaskData.advancedTask.runnerImage = "shreddedbacon/runner:latest" + break; + case 'deploytarget:task:advanced': + // inject variables into advanced tasks the same way it is in builds and standard tasks + const [_, envVars, projectVars] = await getTaskProjectEnvironmentVariables( + taskData.data.project.name, + taskData.data.environment.id + ) + miscTaskData.project.variables = { + project: projectVars, + environment: envVars, } - return sendToLagoonTasks(deployTarget+':misc', miscTaskData); + miscTaskData.advancedTask = taskData.data.advancedTask + break; + case 'deploytarget:task:cancel': + // task cancellation is just a standard unmodified message + miscTaskData.misc = taskData.data.task + break; + case 'deploytarget:build:cancel': + // build cancellation is just a standard unmodified message + miscTaskData.misc = taskData.data.build + break; default: + miscTaskData.misc = taskData.data.build break; } - - return sendToLagoonTasks(taskId, { ...taskData, key: updatedKey }); + // send the task to the queue + if (project.organization != null) { + const curOrg = await getOrganizationById(project.organization); + const organization = { + name: curOrg.name, + id: curOrg.id, + } + miscTaskData.project.organization = organization + } + return sendToLagoonTasks(deployTarget+':misc', miscTaskData); } export const consumeTasks = async function( diff --git a/services/api/database/migrations/20240119101016_remove_activesystems.js b/services/api/database/migrations/20240119101016_remove_activesystems.js new file mode 100644 index 0000000000..cda56cee89 --- /dev/null +++ b/services/api/database/migrations/20240119101016_remove_activesystems.js @@ -0,0 +1,29 @@ +/** + * @param { import("knex").Knex } knex + * @returns { Promise } + */ +exports.up = function(knex) { + return knex.schema + .alterTable('project', (table) => { + table.dropColumn('active_systems_deploy'); + table.dropColumn('active_systems_promote'); + table.dropColumn('active_systems_remove'); + table.dropColumn('active_systems_task'); + table.dropColumn('active_systems_misc'); + }); +}; + +/** + * @param { import("knex").Knex } knex + * @returns { Promise } + */ +exports.down = function(knex) { + return knex.schema + .alterTable('environment', (table) => { + table.string('active_systems_deploy', 300); + table.string('active_systems_promote', 300); + table.string('active_systems_remove', 300); + table.string('active_systems_task', 300); + table.string('active_systems_misc', 300); + }); +}; diff --git a/services/api/src/mocks.js b/services/api/src/mocks.js index 1c157567ce..14d7d56eca 100644 --- a/services/api/src/mocks.js +++ b/services/api/src/mocks.js @@ -239,10 +239,6 @@ MIIJKQIBAAKCAgEA+o[...]P0yoL8BoQQG2jCvYfWh6vyglQdrDYx/o6/8ecTwXokKKh6fg1q -----END RSA PRIVATE KEY-----`, subfolder: '', notifications: [mocks.Notification()], - activeSystemsDeploy: 'lagoon_controllerBuildDeploy', - activeSystemsPromote: 'lagoon_controllerBuildDeploy', - activeSystemsRemove: 'lagoon_controllerRemove', - activeSystemsTask: 'lagoon_controllerJob', branches: faker.random.arrayElement(['true', 'false', '^(master|staging)$']), pullrequests: faker.random.arrayElement(['true', 'false', '[BUILD]']), productionEnvironment: 'master', diff --git a/services/api/src/resources/project/resolvers.ts b/services/api/src/resources/project/resolvers.ts index d2af5630e7..90c5ab4da0 100644 --- a/services/api/src/resources/project/resolvers.ts +++ b/services/api/src/resources/project/resolvers.ts @@ -627,11 +627,6 @@ export const updateProject: ResolverFn = async ( privateKey, subfolder, routerPattern, - activeSystemsDeploy, - activeSystemsRemove, - activeSystemsTask, - activeSystemsMisc, - activeSystemsPromote, branches, productionEnvironment, productionRoutes, @@ -813,11 +808,6 @@ export const updateProject: ResolverFn = async ( privateKey, subfolder, routerPattern, - activeSystemsDeploy, - activeSystemsRemove, - activeSystemsTask, - activeSystemsMisc, - activeSystemsPromote, branches, productionEnvironment, productionRoutes, @@ -919,11 +909,6 @@ export const updateProject: ResolverFn = async ( privateKey, subfolder, routerPattern, - activeSystemsDeploy, - activeSystemsRemove, - activeSystemsTask, - activeSystemsMisc, - activeSystemsPromote, branches, productionEnvironment, productionRoutes, diff --git a/services/api/src/resources/project/sql.ts b/services/api/src/resources/project/sql.ts index 0ef7035cf8..5f247989dd 100644 --- a/services/api/src/resources/project/sql.ts +++ b/services/api/src/resources/project/sql.ts @@ -125,11 +125,6 @@ export const Sql = { routerPattern, openshift, openshiftProjectPattern, - activeSystemsDeploy = "lagoon_controllerBuildDeploy", - activeSystemsPromote = "lagoon_controllerBuildDeploy", - activeSystemsRemove = "lagoon_controllerRemove", - activeSystemsTask = "lagoon_controllerJob", - activeSystemsMisc = "lagoon_controllerMisc", branches = "true", pullrequests = "true", productionEnvironment, @@ -159,11 +154,6 @@ export const Sql = { privateKey, subfolder, routerPattern, - activeSystemsDeploy, - activeSystemsPromote, - activeSystemsRemove, - activeSystemsTask, - activeSystemsMisc, branches, productionEnvironment, productionRoutes, diff --git a/services/api/src/typeDefs.js b/services/api/src/typeDefs.js index 8a0ba7ed91..4ede443219 100644 --- a/services/api/src/typeDefs.js +++ b/services/api/src/typeDefs.js @@ -669,31 +669,11 @@ const typeDefs = gql` Notifications that should be sent for this project """ notifications(type: NotificationType, contentType: NotificationContentType, notificationSeverityThreshold: ProblemSeverityRating): [Notification] - """ - Which internal Lagoon System is responsible for deploying - Currently only 'lagoon_controllerBuildDeploy' exists - """ - activeSystemsDeploy: String - """ - Which internal Lagoon System is responsible for promoting - Currently only 'lagoon_controllerBuildDeploy' exists - """ - activeSystemsPromote: String - """ - Which internal Lagoon System is responsible for promoting - Currently only 'lagoon_controllerRemove' exists - """ - activeSystemsRemove: String - """ - Which internal Lagoon System is responsible for tasks - Currently only 'lagoon_controllerJob' exists - """ - activeSystemsTask: String - """ - Which internal Lagoon System is responsible for miscellaneous tasks - Currently only 'lagoon_controllerMisc' exists - """ - activeSystemsMisc: String + activeSystemsDeploy: String @deprecated(reason: "No longer in use") + activeSystemsPromote: String @deprecated(reason: "No longer in use") + activeSystemsRemove: String @deprecated(reason: "No longer in use") + activeSystemsTask: String @deprecated(reason: "No longer in use") + activeSystemsMisc: String @deprecated(reason: "No longer in use") """ Which branches should be deployed, can be one of: - \`true\` - all branches are deployed diff --git a/services/webhooks2tasks/src/handlers/bitbucketBranchDeleted.ts b/services/webhooks2tasks/src/handlers/bitbucketBranchDeleted.ts index 0bbeec9203..35b4004ad6 100644 --- a/services/webhooks2tasks/src/handlers/bitbucketBranchDeleted.ts +++ b/services/webhooks2tasks/src/handlers/bitbucketBranchDeleted.ts @@ -59,8 +59,6 @@ export async function bitbucketBranchDeleted(webhook: WebhookRequestData, projec meta.error switch (error.name) { case "ProjectNotFound": - case "NoActiveSystemsDefined": - case "UnknownActiveSystem": // These are not real errors and also they will happen many times. We just log them locally but not throw an error sendToLagoonLogs('info', project.name, uuid, `${webhooktype}:${event}:handledButNoTask`, meta, `*[${project.name}]* \`${meta.branch}\` deleted. No remove task created, reason: ${error}` diff --git a/services/webhooks2tasks/src/handlers/bitbucketPullRequestClosed.ts b/services/webhooks2tasks/src/handlers/bitbucketPullRequestClosed.ts index 94089e2eb8..2a7d9d2cbc 100644 --- a/services/webhooks2tasks/src/handlers/bitbucketPullRequestClosed.ts +++ b/services/webhooks2tasks/src/handlers/bitbucketPullRequestClosed.ts @@ -61,8 +61,6 @@ export async function bitbucketPullRequestClosed(webhook: WebhookRequestData, pr } catch (error) { switch (error.name) { case "ProjectNotFound": - case "NoActiveSystemsDefined": - case "UnknownActiveSystem": // These are not real errors and also they will happen many times. We just log them locally but not throw an error sendToLagoonLogs('info', project.name, uuid, `${webhooktype}:${event}:handledButNoTask`, meta, `*[${project.name}]* \`${body.pullrequest.id}\` deleted. No remove task created, reason: ${error}` diff --git a/services/webhooks2tasks/src/handlers/bitbucketPullRequestUpdated.ts b/services/webhooks2tasks/src/handlers/bitbucketPullRequestUpdated.ts index 26e935d1be..c1b6c626eb 100644 --- a/services/webhooks2tasks/src/handlers/bitbucketPullRequestUpdated.ts +++ b/services/webhooks2tasks/src/handlers/bitbucketPullRequestUpdated.ts @@ -73,8 +73,6 @@ export async function bitbucketPullRequestUpdated(webhook: WebhookRequestData, p } catch (error) { switch (error.name) { case "ProjectNotFound": - case "NoActiveSystemsDefined": - case "UnknownActiveSystem": // These are not real errors and also they will happen many times. We just log them locally but not throw an error sendToLagoonLogs('info', project.name, uuid, `${webhooktype}:${event}:handledButNoTask`, meta, `*[${project.name}]* PR ${body.object_attributes.id} updated. No deploy task created, reason: ${error}` diff --git a/services/webhooks2tasks/src/handlers/bitbucketPush.ts b/services/webhooks2tasks/src/handlers/bitbucketPush.ts index 0b4898e747..2d12a3a35f 100644 --- a/services/webhooks2tasks/src/handlers/bitbucketPush.ts +++ b/services/webhooks2tasks/src/handlers/bitbucketPush.ts @@ -72,8 +72,6 @@ export async function bitbucketPush(webhook: WebhookRequestData, project: Projec } catch (error) { switch (error.name) { case "ProjectNotFound": - case "NoActiveSystemsDefined": - case "UnknownActiveSystem": case "NoNeedToDeployBranch": // These are not real errors and also they will happen many times. We just log them locally but not throw an error sendToLagoonLogs('info', project.name, uuid, `${webhooktype}:${event}:handledButNoTask`, meta, diff --git a/services/webhooks2tasks/src/handlers/giteaBranchDeleted.ts b/services/webhooks2tasks/src/handlers/giteaBranchDeleted.ts index beaebdae13..84f9d3fdef 100644 --- a/services/webhooks2tasks/src/handlers/giteaBranchDeleted.ts +++ b/services/webhooks2tasks/src/handlers/giteaBranchDeleted.ts @@ -57,8 +57,6 @@ export async function giteaBranchDeleted(webhook: WebhookRequestData, project: P meta.error = error switch (error.name) { case "ProjectNotFound": - case "NoActiveSystemsDefined": - case "UnknownActiveSystem": // These are not real errors and also they will happen many times. We just log them locally but not throw an error sendToLagoonLogs('info', project.name, uuid, `${webhooktype}:${event}:handledButNoTask`, meta, `*[${project.name}]* \`${meta.branch}\` deleted. No remove task created, reason: ${error}` diff --git a/services/webhooks2tasks/src/handlers/giteaPullRequestClosed.ts b/services/webhooks2tasks/src/handlers/giteaPullRequestClosed.ts index 6894919760..e665259283 100644 --- a/services/webhooks2tasks/src/handlers/giteaPullRequestClosed.ts +++ b/services/webhooks2tasks/src/handlers/giteaPullRequestClosed.ts @@ -64,8 +64,6 @@ export async function giteaPullRequestClosed(webhook: WebhookRequestData, projec meta.error = error switch (error.name) { case "ProjectNotFound": - case "NoActiveSystemsDefined": - case "UnknownActiveSystem": // These are not real errors and also they will happen many times. We just log them locally but not throw an error sendToLagoonLogs('info', project.name, uuid, `${webhooktype}:${event}:handledButNoTask`, meta, `*[${project.name}]* PR ${body.number} closed. No remove task created, reason: ${error}` diff --git a/services/webhooks2tasks/src/handlers/giteaPullRequestOpened.ts b/services/webhooks2tasks/src/handlers/giteaPullRequestOpened.ts index 238dc054a6..050496f2fd 100644 --- a/services/webhooks2tasks/src/handlers/giteaPullRequestOpened.ts +++ b/services/webhooks2tasks/src/handlers/giteaPullRequestOpened.ts @@ -73,8 +73,6 @@ export async function giteaPullRequestOpened(webhook: WebhookRequestData, projec } catch (error) { switch (error.name) { case "ProjectNotFound": - case "NoActiveSystemsDefined": - case "UnknownActiveSystem": // These are not real errors and also they will happen many times. We just log them locally but not throw an error sendToLagoonLogs('info', project.name, uuid, `${webhooktype}:${event}:handledButNoTask`, meta, `*[${project.name}]* PR ${body.number} opened. No deploy task created, reason: ${error}` diff --git a/services/webhooks2tasks/src/handlers/giteaPullRequestSynchronize.ts b/services/webhooks2tasks/src/handlers/giteaPullRequestSynchronize.ts index 280dd7982c..251fd5943d 100644 --- a/services/webhooks2tasks/src/handlers/giteaPullRequestSynchronize.ts +++ b/services/webhooks2tasks/src/handlers/giteaPullRequestSynchronize.ts @@ -91,8 +91,6 @@ export async function giteaPullRequestSynchronize(webhook: WebhookRequestData, p } catch (error) { switch (error.name) { case "ProjectNotFound": - case "NoActiveSystemsDefined": - case "UnknownActiveSystem": // These are not real errors and also they will happen many times. We just log them locally but not throw an error sendToLagoonLogs('info', project.name, uuid, `${webhooktype}:${event}:handledButNoTask`, meta, `*[${project.name}]* PR ${body.number} opened. No deploy task created, reason: ${error}` diff --git a/services/webhooks2tasks/src/handlers/giteaPush.ts b/services/webhooks2tasks/src/handlers/giteaPush.ts index c513c840b6..98cd89ac3a 100644 --- a/services/webhooks2tasks/src/handlers/giteaPush.ts +++ b/services/webhooks2tasks/src/handlers/giteaPush.ts @@ -73,8 +73,6 @@ export async function giteaPush(webhook: WebhookRequestData, project: Project) { } catch (error) { switch (error.name) { case "ProjectNotFound": - case "NoActiveSystemsDefined": - case "UnknownActiveSystem": case "NoNeedToDeployBranch": // These are not real errors and also they will happen many times. We just log them locally but not throw an error sendToLagoonLogs('info', project.name, uuid, `${webhooktype}:${event}:handledButNoTask`, meta, diff --git a/services/webhooks2tasks/src/handlers/githubBranchDeleted.ts b/services/webhooks2tasks/src/handlers/githubBranchDeleted.ts index b9f42c6f39..b7a7b72710 100644 --- a/services/webhooks2tasks/src/handlers/githubBranchDeleted.ts +++ b/services/webhooks2tasks/src/handlers/githubBranchDeleted.ts @@ -57,8 +57,6 @@ export async function githubBranchDeleted(webhook: WebhookRequestData, project: meta.error = error switch (error.name) { case "ProjectNotFound": - case "NoActiveSystemsDefined": - case "UnknownActiveSystem": // These are not real errors and also they will happen many times. We just log them locally but not throw an error sendToLagoonLogs('info', project.name, uuid, `${webhooktype}:${event}:handledButNoTask`, meta, `*[${project.name}]* \`${meta.branch}\` deleted. No remove task created, reason: ${error}` diff --git a/services/webhooks2tasks/src/handlers/githubPullRequestClosed.ts b/services/webhooks2tasks/src/handlers/githubPullRequestClosed.ts index 445825f20d..813dd147b3 100644 --- a/services/webhooks2tasks/src/handlers/githubPullRequestClosed.ts +++ b/services/webhooks2tasks/src/handlers/githubPullRequestClosed.ts @@ -64,8 +64,6 @@ export async function githubPullRequestClosed(webhook: WebhookRequestData, proje meta.error = error switch (error.name) { case "ProjectNotFound": - case "NoActiveSystemsDefined": - case "UnknownActiveSystem": // These are not real errors and also they will happen many times. We just log them locally but not throw an error sendToLagoonLogs('info', project.name, uuid, `${webhooktype}:${event}:handledButNoTask`, meta, `*[${project.name}]* PR ${body.number} closed. No remove task created, reason: ${error}` diff --git a/services/webhooks2tasks/src/handlers/githubPullRequestOpened.ts b/services/webhooks2tasks/src/handlers/githubPullRequestOpened.ts index 134e7942f6..52dbb66023 100644 --- a/services/webhooks2tasks/src/handlers/githubPullRequestOpened.ts +++ b/services/webhooks2tasks/src/handlers/githubPullRequestOpened.ts @@ -73,8 +73,6 @@ export async function githubPullRequestOpened(webhook: WebhookRequestData, proje } catch (error) { switch (error.name) { case "ProjectNotFound": - case "NoActiveSystemsDefined": - case "UnknownActiveSystem": // These are not real errors and also they will happen many times. We just log them locally but not throw an error sendToLagoonLogs('info', project.name, uuid, `${webhooktype}:${event}:handledButNoTask`, meta, `*[${project.name}]* PR ${body.number} opened. No deploy task created, reason: ${error}` diff --git a/services/webhooks2tasks/src/handlers/githubPullRequestSynchronize.ts b/services/webhooks2tasks/src/handlers/githubPullRequestSynchronize.ts index da5e8705e4..aeaccf2091 100644 --- a/services/webhooks2tasks/src/handlers/githubPullRequestSynchronize.ts +++ b/services/webhooks2tasks/src/handlers/githubPullRequestSynchronize.ts @@ -91,8 +91,6 @@ export async function githubPullRequestSynchronize(webhook: WebhookRequestData, } catch (error) { switch (error.name) { case "ProjectNotFound": - case "NoActiveSystemsDefined": - case "UnknownActiveSystem": // These are not real errors and also they will happen many times. We just log them locally but not throw an error sendToLagoonLogs('info', project.name, uuid, `${webhooktype}:${event}:handledButNoTask`, meta, `*[${project.name}]* PR ${body.number} opened. No deploy task created, reason: ${error}` diff --git a/services/webhooks2tasks/src/handlers/githubPush.ts b/services/webhooks2tasks/src/handlers/githubPush.ts index 9641582dbf..fbe95e0afe 100644 --- a/services/webhooks2tasks/src/handlers/githubPush.ts +++ b/services/webhooks2tasks/src/handlers/githubPush.ts @@ -72,8 +72,6 @@ export async function githubPush(webhook: WebhookRequestData, project: Project) } catch (error) { switch (error.name) { case "ProjectNotFound": - case "NoActiveSystemsDefined": - case "UnknownActiveSystem": case "NoNeedToDeployBranch": // These are not real errors and also they will happen many times. We just log them locally but not throw an error sendToLagoonLogs('info', project.name, uuid, `${webhooktype}:${event}:handledButNoTask`, meta, diff --git a/services/webhooks2tasks/src/handlers/gitlabBranchDeleted.ts b/services/webhooks2tasks/src/handlers/gitlabBranchDeleted.ts index e153414320..96c31477c8 100644 --- a/services/webhooks2tasks/src/handlers/gitlabBranchDeleted.ts +++ b/services/webhooks2tasks/src/handlers/gitlabBranchDeleted.ts @@ -60,8 +60,6 @@ export async function gitlabBranchDeleted(webhook: WebhookRequestData, project: meta.error = error switch (error.name) { case "ProjectNotFound": - case "NoActiveSystemsDefined": - case "UnknownActiveSystem": // These are not real errors and also they will happen many times. We just log them locally but not throw an error sendToLagoonLogs('info', project.name, uuid, `${webhooktype}:remove:handledButNoTask`, meta, `*[${project.name}]* \`${meta.branch}\` deleted. No remove task created, reason: ${error}` diff --git a/services/webhooks2tasks/src/handlers/gitlabPullRequestClosed.ts b/services/webhooks2tasks/src/handlers/gitlabPullRequestClosed.ts index 53b9f6f615..1f3fa0fff5 100644 --- a/services/webhooks2tasks/src/handlers/gitlabPullRequestClosed.ts +++ b/services/webhooks2tasks/src/handlers/gitlabPullRequestClosed.ts @@ -61,8 +61,6 @@ export async function gitlabPullRequestClosed(webhook: WebhookRequestData, proje } catch (error) { switch (error.name) { case "ProjectNotFound": - case "NoActiveSystemsDefined": - case "UnknownActiveSystem": // These are not real errors and also they will happen many times. We just log them locally but not throw an error sendToLagoonLogs('info', project.name, uuid, `${webhooktype}:${event}:handledButNoTask`, meta, `*[${project.name}]* PR ${body.object_attributes.iid} closed. No remove task created, reason: ${error}` diff --git a/services/webhooks2tasks/src/handlers/gitlabPullRequestOpened.ts b/services/webhooks2tasks/src/handlers/gitlabPullRequestOpened.ts index 8df6178ac3..a0be3e7998 100644 --- a/services/webhooks2tasks/src/handlers/gitlabPullRequestOpened.ts +++ b/services/webhooks2tasks/src/handlers/gitlabPullRequestOpened.ts @@ -73,8 +73,6 @@ export async function gitlabPullRequestOpened(webhook: WebhookRequestData, proje } catch (error) { switch (error.name) { case "ProjectNotFound": - case "NoActiveSystemsDefined": - case "UnknownActiveSystem": // These are not real errors and also they will happen many times. We just log them locally but not throw an error sendToLagoonLogs('info', project.name, uuid, `${webhooktype}:${event}:handledButNoTask`, meta, `*[${project.name}]* PR ${body.object_attributes.iid} opened. No deploy task created, reason: ${error}` diff --git a/services/webhooks2tasks/src/handlers/gitlabPullRequestUpdated.ts b/services/webhooks2tasks/src/handlers/gitlabPullRequestUpdated.ts index ffa93d6898..e6d8c84b14 100644 --- a/services/webhooks2tasks/src/handlers/gitlabPullRequestUpdated.ts +++ b/services/webhooks2tasks/src/handlers/gitlabPullRequestUpdated.ts @@ -74,8 +74,6 @@ export async function gitlabPullRequestUpdated(webhook: WebhookRequestData, proj } catch (error) { switch (error.name) { case "ProjectNotFound": - case "NoActiveSystemsDefined": - case "UnknownActiveSystem": // These are not real errors and also they will happen many times. We just log them locally but not throw an error sendToLagoonLogs('info', project.name, uuid, `${webhooktype}:${event}:handledButNoTask`, meta, `*[${project.name}]* PR ${body.object_attributes.iid} updated. No deploy task created, reason: ${error}` diff --git a/services/webhooks2tasks/src/handlers/gitlabPush.ts b/services/webhooks2tasks/src/handlers/gitlabPush.ts index af249a3e42..8a6d452b10 100644 --- a/services/webhooks2tasks/src/handlers/gitlabPush.ts +++ b/services/webhooks2tasks/src/handlers/gitlabPush.ts @@ -73,8 +73,6 @@ export async function gitlabPush(webhook: WebhookRequestData, project: Project) } catch (error) { switch (error.name) { case "ProjectNotFound": - case "NoActiveSystemsDefined": - case "UnknownActiveSystem": case "NoNeedToDeployBranch": // These are not real errors and also they will happen many times. We just log them locally but not throw an error sendToLagoonLogs('info', project.name, uuid, `${webhooktype}:${event}:handledButNoTask`, meta,