Skip to content
Open
Show file tree
Hide file tree
Changes from 10 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## Unreleased
* Support StatefulSet in Helm charts ([#1108](https://github.com/opendevstack/ods-jenkins-shared-library/pull/1108))
* The Document History indicates clearly when an SLC document has not changed ([#1099](https://github.com/opendevstack/ods-jenkins-shared-library/pull/1099))

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion src/org/ods/component/AbstractDeploymentStrategy.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import org.ods.util.PodData

abstract class AbstractDeploymentStrategy implements IDeploymentStrategy {

protected final List<String> DEPLOYMENT_KINDS = [
protected List<String> DEPLOYMENT_KINDS = [
OpenShiftService.DEPLOYMENT_KIND, OpenShiftService.DEPLOYMENTCONFIG_KIND,
]

Expand Down
15 changes: 15 additions & 0 deletions src/org/ods/component/HelmDeploymentStrategy.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ class HelmDeploymentStrategy extends AbstractDeploymentStrategy {
this.options = new RolloutOpenShiftDeploymentOptions(config)
this.openShift = openShift
this.jenkins = jenkins

// Why? In Groovy protected fields are implicitly final.
// As per Google: This seems to be the idiomatic way to override protected fields
DEPLOYMENT_KINDS.clear()
DEPLOYMENT_KINDS.addAll(
OpenShiftService.DEPLOYMENT_KIND, OpenShiftService.DEPLOYMENTCONFIG_KIND,
OpenShiftService.STATEFULSET_KIND,
)
}

@Override
Expand Down Expand Up @@ -173,6 +181,13 @@ class HelmDeploymentStrategy extends AbstractDeploymentStrategy {
def rolloutData = [:]
deploymentResources.each { resourceKind, resourceNames ->
resourceNames.each { resourceName ->

logger.info(
"Fetching resource for resourcekind: "
+ "${resourceKind}/${resourceName}"
+ "(selector: ${options.selector})"
)

def podData = []
for (def i = 0; i < options.deployTimeoutRetries; i++) {
podData = openShift.checkForPodData(context.targetProject, options.selector, resourceName)
Expand Down
11 changes: 10 additions & 1 deletion src/org/ods/orchestration/phases/DeployOdsComponent.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,24 @@ class DeployOdsComponent {
applyTemplates(openShiftDir, deploymentMean)

def retries = project.environmentConfig?.openshiftRolloutTimeoutRetries ?: 10
def podData = null
for (def i = 0; i < retries; i++) {
def podData = os.checkForPodData(project.targetProject, deploymentMean.selector)
podData = os.checkForPodData(project.targetProject, deploymentMean.selector)
if (podData) {
return podData
}
steps.echo("Could not find 'running' pod(s) with label '${deploymentMean.selector}' - waiting")
steps.sleep(12)
}

if (podData == null) {
throw new RuntimeException(
"Error: Could not find 'running' pod(s) with label"
+ "'${deploymentMean.selector}'"
)
}

// TODO: What if podData is empty?
// TODO: Once the orchestration pipeline can deal with multiple replicas,
// update this to deal with multiple pods.
def pod = podData[0].toMap()
Expand Down
1 change: 1 addition & 0 deletions src/org/ods/services/OpenShiftService.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class OpenShiftService {
static final String ROLLOUT_WAITING = 'waiting'
static final String DEPLOYMENTCONFIG_KIND = 'DeploymentConfig'
static final String DEPLOYMENT_KIND = 'Deployment'
static final String STATEFULSET_KIND = 'StatefulSet'

private final IPipelineSteps steps
private final ILogger logger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class OdsComponentStageRolloutOpenShiftDeploymentSpec extends PipelineSpockTestB
def c = config + [environment: 'dev',targetProject: 'foo-dev',openshiftRolloutTimeoutRetries: 5,chartDir: 'chart']
IContext context = new Context(null, c, logger)
OpenShiftService openShiftService = Mock(OpenShiftService.class)
openShiftService.getResourcesForComponent('foo-dev', ['Deployment', 'DeploymentConfig'], 'app=foo-bar') >> [Deployment: ['bar']]
openShiftService.getResourcesForComponent('foo-dev', ['Deployment', 'DeploymentConfig', 'StatefulSet'], 'app=foo-bar') >> [Deployment: ['bar']]
openShiftService.getRevision(*_) >> 123
openShiftService.rollout(*_) >> "${config.componentId}-124"
openShiftService.getPodDataForDeployment(*_) >> [new PodData([ deploymentId: "${config.componentId}-124" ])]
Expand Down