Skip to content

Commit

Permalink
Adds a check for 'resourceName'
Browse files Browse the repository at this point in the history
This allows us to extract the relevant pod data
in case there are multiple pods in a mono-repo like rollout

fixes opendevstack#1011
fixes opendevstack#1011
  • Loading branch information
serverhorror committed Jul 24, 2023
1 parent cca38ac commit 2c9d4eb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/org/ods/component/HelmDeploymentStrategy.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class HelmDeploymentStrategy extends AbstractDeploymentStrategy {
resourceNames.each { resourceName ->

def podData = [:]
podData = openShift.checkForPodData(context.targetProject, options.selector)
podData = openShift.checkForPodData(context.targetProject, options.selector, resourceName)
context.addDeploymentToArtifactURIs("${resourceName}-deploymentMean",
[
'type': 'helm',
Expand Down
8 changes: 6 additions & 2 deletions src/org/ods/services/OpenShiftService.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ class OpenShiftService {
// checkForPodData returns a subset of information from every pod, once
// all pods matching the label are "running". If this is not the case,
// it returns an empty list.
List<PodData> checkForPodData(String project, String label) {
List<PodData> checkForPodData(String project, String label, String resourceName=null) {
List<PodData> pods = []
def stdout = steps.sh(
script: "oc -n ${project} get pod -l ${label} -o json",
Expand All @@ -1033,7 +1033,11 @@ class OpenShiftService {
).toString().trim()
def podJson = new JsonSlurperClassic().parseText(stdout)
if (podJson && podJson.items.collect { it.status?.phase?.toLowerCase() }.every { it == 'running' }) {
pods = extractPodData(podJson)
if (podJson && resourceName && podJson.items.collect { it.metadata.name }.every { it.startsWith(resourceName) }) {
pods = extractPodData(podJson)
}else{
pods = extractPodData(podJson)
}
}
pods
}
Expand Down

0 comments on commit 2c9d4eb

Please sign in to comment.