Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selector.startBuild() returns non-build objects from stdout and resulting selector sometimes doesn't contain any build object #488

Open
mkaspar opened this issue Jun 28, 2024 · 0 comments

Comments

@mkaspar
Copy link

mkaspar commented Jun 28, 2024

I'm trying to modify buildconfig in OpenShift and then run build from it (using --from-dir) wait for the build to finish and return resulting logs. However when i start the build from the buildconfig, the startBuild() returns 3 objects instead of just build each corresponding to one line of oc start-build --from-dir=xxx output and narrrowing the result to Build object type returns 0 objects in parallel builds even though the build is running and finishes.
The relevant code (k8sObjects contains IS and BC definitions):

openshift.withCluster() {
   openshift.withProject(BUILD_NAMESPACE) {
      builders['imageX'] = {
         ...
        def applySelector = openshift.apply(k8sObjects);
        def bcSelector = applySelector.narrow('BuildConfig');
        def buildSelector = bcSelector.startBuild("--from-dir=.")
        echo "Static selector names: ${buildSelector.names()}, ${buildSelector.narrow('Build').names()}"
        timeout(10) {
           buildSelector.narrow('Build').untilEach(1) {
              return it.object().status.phase == 'Complete' || it.object().status.phase == 'Failed';
           }
         }
      }
      parallel builders
   }
}

Output:

Static selector names: [Uploading directory "." as binary input for the build ..., ., Uploading finished, build/ceos-cmd-setup-35], [build/ceos-cmd-setup-35]
Static selector names: [Uploading directory "." as binary input for the build ..., /ceos-cmd-app-repository-100, Uploading finished], []
...
 ERROR: Selector is static and empty; watch would never terminate.
oc get build
ceos-cmd-app-repository-100        Docker   Binary@97c7b0d   Complete                          6 minutes ago    3m59s
ceos-cmd-setup-35                  Docker   Binary@97c7b0d   Complete                          6 minutes ago    3m56s

There was a build that succeded with a bit different output (mind the build name versus Uploading finished parts of the startBuild selector):

 Static selector names: [Uploading directory "." as binary input for the build ..., ., Uploading finished, build/ceos-cmd-setup-34], [build/ceos-cmd-setup-34]
Static selector names: [Uploading directory "." as binary input for the build ..., ., Uploading finished, build/ceos-cmd-app-repository-99], [build/ceos-cmd-app-repository-99]

So it looks like the selector selecting the build seems to work based on start-build output ordering.
Would be nice if the startBuild() selector returned only the build irrelevant of the other ouptut lines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant