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

WIP: Use a single queue per remote instead of 4 queues. #3323

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 50 additions & 64 deletions node-packages/commons/src/deploy-tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from './api';
import {
getControllerBuildData,
sendToLagoonTasks
sendToLagoonControllers
} from './tasks';

class NoNeedToDeployBranch extends Error {
Expand Down Expand Up @@ -45,32 +45,26 @@ const deployBranch = async function(data: any) {
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}`
);
deployData.deployTarget = deployTarget
const branchBuildDeployData = await getControllerBuildData(deployData);
const branchPayload = {
eventType: "lagoon:build",
payload: branchBuildDeployData
}
const sendBranch = await sendToLagoonControllers(branchBuildDeployData.spec.project.deployTarget, branchPayload);
return true
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);
const payload = {
eventType: "lagoon:build",
payload: buildDeployData
}
const sendTasks = await sendToLagoonControllers(buildDeployData.spec.project.deployTarget, payload);
return true
case 'false':
logger.debug(
`projectName: ${projectName}, branchName: ${branchName}, branch deployments disabled`
Expand All @@ -85,18 +79,15 @@ 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);
const payload = {
eventType: "lagoon:build",
payload: buildDeployData
}
const sendTasks = await sendToLagoonControllers(buildDeployData.spec.project.deployTarget, payload);
return true
}
logger.debug(
`projectName: ${projectName}, branchName: ${branchName}, regex ${branchesRegex} did not match branchname, not deploying`
Expand Down Expand Up @@ -127,32 +118,26 @@ const deployPullrequest = async function(data: any) {
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}`
);
deployData.deployTarget = deployTarget
const prBuildDeployData = await getControllerBuildData(deployData);
const prPayload = {
eventType: "lagoon:build",
payload: prBuildDeployData
}
const prSendTasks = await sendToLagoonControllers(prBuildDeployData.spec.project.deployTarget, prPayload);
return true
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);
const payload = {
eventType: "lagoon:build",
payload: buildDeployData
}
const sendTasks = await sendToLagoonControllers(buildDeployData.spec.project.deployTarget, payload);
return true
case 'false':
logger.debug(
`projectName: ${projectName}, pullrequest: ${branchName}, pullrequest deployments disabled`
Expand All @@ -167,18 +152,15 @@ 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);
const payload = {
eventType: "lagoon:build",
payload: buildDeployData
}
const sendTasks = await sendToLagoonControllers(buildDeployData.spec.project.deployTarget, payload);
return true
}
logger.debug(
`projectName: ${projectName}, branchName: ${branchName}, regex ${pullrequestRegex} did not match PR title, not deploying`
Expand Down Expand Up @@ -433,7 +415,11 @@ export const deployTargetPromote = async function(data: any) {
}
promoteData.deployTarget = deployTarget
const buildDeployData = await getControllerBuildData(promoteData);
const sendTasks = await sendToLagoonTasks(buildDeployData.spec.project.deployTarget+':builddeploy', buildDeployData);
const payload = {
eventType: "lagoon:build",
payload: buildDeployData
}
const sendTasks = await sendToLagoonControllers(buildDeployData.spec.project.deployTarget, payload);
return true
}

Expand Down
Loading