opendevstack / ods-jenkins-shared-library

Shared Jenkins library which all ODS projects & components use - provisioning, SonarQube code scanning, Nexus publishing, OpenShift template based deployments and repository orchestration
Apache License 2.0
75 stars 57 forks source link

Deployment rollout doesn't support replicas=0 #969

Closed hrcornejo closed 1 year ago

hrcornejo commented 1 year ago

Describe the bug Is not possible to use a component with size 0 in replicas.

To Reproduce Steps to reproduce the behavior:

  1. Configure in OpenShift a component with 0 replicas:
    - apiVersion: apps.openshift.io/v1
    kind: DeploymentConfig
    ...
    spec:
    replicas: 0
    revisionHistoryLimit: 10
    selector:
      app: dummy-component
      deploymentconfig: component
  2. Compile the component / Launch a Dev Preview.
  3. See error.

Expected behavior The deploy finalizes correctly and the component has a DeploymentConfig with replicas = 0.

Affected version (please complete the following information):

Log Output:

+ oc -n dummy-dev rollout status DeploymentConfig/component --watch=true
Waiting for rollout to finish: 1 old replicas are pending termination...
Waiting for latest deployment config spec to be observed by the controller loop...
replication controller "component-278" successfully rolled out
[Pipeline] }
[Pipeline] // timeout
[Pipeline] sh (Get latest version of DeploymentConfig/component)
+ oc -n dummy-dev get DeploymentConfig/component -o 'jsonpath={.status.latestVersion}'
[Pipeline] sh (Get {.metadata.annotations.openshift\.io/deployment\.phase} of rc component-278)
+ oc -n dummy-dev get rc/component-278 -o 'jsonpath={.metadata.annotations.openshift\.io/deployment\.phase}'
[Pipeline] echo
Rollout #278 of DeploymentConfig 'component' successful.
[Pipeline] sh (Getting OpenShift pod data for pods labelled with deployment=component-278)
+ oc -n dummy-dev get pod -l deployment=component-278 -o json
[Pipeline] echo
2023-01-17 10:08:15Z Could not find 'running' pod(s) with label 'deployment=component-278' - waiting
[Pipeline] sleep
Sleeping for 12 sec
[Pipeline] sh (Getting OpenShift pod data for pods labelled with deployment=component-278)
+ oc -n dummy-dev get pod -l deployment=component-278 -o json
[Pipeline] echo
2023-01-17 10:08:28Z Could not find 'running' pod(s) with label 'deployment=component-278' - waiting
[Pipeline] sleep
Sleeping for 12 sec
[Pipeline] sh (Getting OpenShift pod data for pods labelled with deployment=component-278)
+ oc -n dummy-dev get pod -l deployment=component-278 -o json
[Pipeline] echo
2023-01-17 10:08:41Z Could not find 'running' pod(s) with label 'deployment=component-278' - waiting
[Pipeline] sleep
Sleeping for 12 sec
[Pipeline] sh (Getting OpenShift pod data for pods labelled with deployment=component-278)
+ oc -n dummy-dev get pod -l deployment=component-278 -o json
[Pipeline] echo
2023-01-17 10:08:54Z Could not find 'running' pod(s) with label 'deployment=component-278' - waiting
[Pipeline] sleep
Sleeping for 12 sec
[Pipeline] sh (Getting OpenShift pod data for pods labelled with deployment=component-278)
+ oc -n dummy-dev get pod -l deployment=component-278 -o json
[Pipeline] echo
2023-01-17 10:09:07Z Could not find 'running' pod(s) with label 'deployment=component-278' - waiting
[Pipeline] sleep
Sleeping for 12 sec
[Pipeline] sh (Getting all Deployment,DeploymentConfig names for selector 'app=dummy-component')
+ oc -n dummy-dev get Deployment,DeploymentConfig -l app=dummy-component -o 'template={{range .items}}{{.kind}}:{{.metadata.name}} {{end}}'
expected to call org.codehaus.groovy.runtime.MethodClosure.call but wound up catching org.ods.services.OpenShiftService.resume; see: https://jenkins.io/redirect/pipeline-cps-method-mismatches/
[Pipeline] sh (Resume DeploymentConfig/component)
+ oc rollout resume DeploymentConfig/component -n dummy-dev
error: deploymentconfigs.apps.openshift.io "component" is not paused
[Pipeline] }
[Pipeline] // stage
[Pipeline] echo
[Deploy to OpenShift-component] **** ENDED stage 'Deploy to OpenShift' for component 'component' branch 'master' **** (took 139754 ms)
[Pipeline] }
[Pipeline] // wrap
[Pipeline] stage
[Pipeline] { (odsPipeline error)
[Pipeline] echo
WARN: [component] ***** Finished ODS Pipeline for component (with error) ***** (took 473290 ms)