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
70 stars 57 forks source link

REGRESSION: 4.x/master - allowPartialRebuild functionality is broken #977

Open clemensutschig opened 1 year ago

clemensutschig commented 1 year ago

Describe the bug The release manager allows to configure "allowPartialRebuild" - which is especially helpful for large projects where only one component is changed, and only that one should be rebuild

To Reproduce

  1. New releasemanager
  2. 2 ods components - add both to RM and build (in WIP)
  3. set allowPartialRebuild in metadata.yml -> true
  4. change one component
  5. rebuild the RM in WIP

Expected behavior only the changed component gets rebuild, the other stays as is - and gets resurrected

Affected version (please complete the following information):

Log Output (ensure to remove any confidential information like tokens, project names, etc.

DEBUG: Checking if repo can be resurrected from previous build ...
[Pipeline] fileExists
[..]
[Pipeline] echo
Checking if image SHAs for 'gol' of 1 deployment(s) are up-to-date ...
[Pipeline] echo
DEBUG: Verifying images of DeploymentConfig 'gol'
[Pipeline] sh (Get latest version of DeploymentConfig/gol)
+ oc -n null get DeploymentConfig/gol -o 'jsonpath={.status.latestVersion}'
Error from server (Forbidden): deploymentconfigs.apps.openshift.io "gol" is forbidden: User "system:serviceaccount:dcare-cd:jenkins" cannot get resource "deploymentconfigs" in API group "apps.openshift.io" in the namespace "null"
[Pipeline] echo
DEBUG: DeploymentConfig 'gol' does not exist!
[..]
Resurrection of previous build for 'gol' not possible as deployment 'gol' was not found in OpenShift.
[Pipeline] echo

Note the oc -n null - which makes this break

clemensutschig commented 1 year ago

@metmajer, fyi ..

clemensutschig commented 1 year ago

While fixing this - I took a pretty hard look at the codebase - and propose two things on top of this fix

I also found some interesting behaviour on unirest / getAsFile -> where the directory must exist - and the only way to make this happen is vie jenkins means (steps.dir)

clemensutschig commented 1 year ago

Fix(es):

DEBUG: Verifiying image of container 'plain' ...
[Pipeline] echo
DEBUG: Container 'plain' is using defined image 'sha256:2ad8c81dc786477d5a84685eb5cba7db7ccb257dd3a010d712b58462443c616d'.
[Pipeline] echo
Resurrection of previous build for 'plain' possible.
[Pipeline] echo
DEBUG: Data from previous Jenkins build:
[resurrectedBuild:test2/41, deployments:[plain:[podName:plain-3-cdnn2, ... dev/plain@sha256:2ad8c81dc786477d5a84685eb5cba7db7ccb257dd3a010d712b58462443c616d]]]]
[Pipeline] echo
DEBUG: [plain-resurrect-data]  (took 19607 ms)

Commits (are not happening anymore on untouched code): image

vs a rebuild of repos (so forceRebuild): image