Skip to content

Commit

Permalink
Bug/981 component fails to deploy more than one deploymentconfig (#982)
Browse files Browse the repository at this point in the history
  • Loading branch information
serverhorror authored Mar 21, 2023
1 parent 731e182 commit 7aab67d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 29 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## Unreleased
- Fix Component fails to deploy with more than one DeploymentConfig([#981](https://github.com/opendevstack/ods-jenkins-shared-library/issues/981))

### Fixed
- Change default registry to match Openshift 4 ([#983] (https://github.com/opendevstack/ods-jenkins-shared-library/issues/983))
Expand Down
56 changes: 27 additions & 29 deletions src/org/ods/orchestration/phases/FinalizeOdsComponent.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -137,41 +137,39 @@ class FinalizeOdsComponent {
throw new RuntimeException ("Deploymentmeans for repo ${repo.id}" +
" are not found. These means are automatically generated!\n" +
" Likely you upgraded and tried to deploy to Q instead of rebuilding on dev")
} else if (deploymentMeans.size() > 1) {
throw new RuntimeException ("Found more than 1 Deploymentmeans ${deploymentMeans.size()} " +
"for repo ${repo.id}. This is not supported!")
}

Map deploymentMean = deploymentMeans.values().get(0)
deploymentMeans.values().each{deploymentMean->
String componentSelector = deploymentMean.selector

String componentSelector = deploymentMean.selector
def allComponentDeploymentsByKind = os.getResourcesForComponent(
project.targetProject,
[OpenShiftService.DEPLOYMENTCONFIG_KIND, OpenShiftService.DEPLOYMENT_KIND],
componentSelector
)
def allComponentDeployments = allComponentDeploymentsByKind[OpenShiftService.DEPLOYMENTCONFIG_KIND] ?: []
if (allComponentDeploymentsByKind[OpenShiftService.DEPLOYMENT_KIND]) {
allComponentDeployments.addAll(allComponentDeploymentsByKind[OpenShiftService.DEPLOYMENT_KIND])
}
logger.debug(
"ODS created deployments for ${repo.id}: " +
"${odsBuiltDeployments}, all deployments: ${allComponentDeployments}"
)

def allComponentDeploymentsByKind = os.getResourcesForComponent(
project.targetProject,
[OpenShiftService.DEPLOYMENTCONFIG_KIND, OpenShiftService.DEPLOYMENT_KIND],
componentSelector
)
def allComponentDeployments = allComponentDeploymentsByKind[OpenShiftService.DEPLOYMENTCONFIG_KIND] ?: []
if (allComponentDeploymentsByKind[OpenShiftService.DEPLOYMENT_KIND]) {
allComponentDeployments.addAll(allComponentDeploymentsByKind[OpenShiftService.DEPLOYMENT_KIND])
}
logger.debug(
"ODS created deployments for ${repo.id}: " +
"${odsBuiltDeployments}, all deployments: ${allComponentDeployments}"
)
odsBuiltDeployments.each { odsBuiltDeploymentName ->
allComponentDeployments.remove(odsBuiltDeploymentName)
}

odsBuiltDeployments.each { odsBuiltDeploymentName ->
allComponentDeployments.remove(odsBuiltDeploymentName)
}

if (allComponentDeployments != null && allComponentDeployments.size() > 0 ) {
def message = "DeploymentConfigs (component: '${repo.id}') found that are not ODS managed: " +
"'${allComponentDeployments}'!\r" +
"Please fix by rolling them out through 'odsComponentStageRolloutOpenShiftDeployment()'!"
if (project.isWorkInProgress) {
util.warnBuild(message)
} else {
throw new RuntimeException(message)
if (allComponentDeployments != null && allComponentDeployments.size() > 0 ) {
def message = "DeploymentConfigs (component: '${repo.id}') found that are not ODS managed: " +
"'${allComponentDeployments}'!\r" +
"Please fix by rolling them out through 'odsComponentStageRolloutOpenShiftDeployment()'!"
if (project.isWorkInProgress) {
util.warnBuild(message)
} else {
throw new RuntimeException(message)
}
}
}

Expand Down

0 comments on commit 7aab67d

Please sign in to comment.