eclipse-jkube / jkube

Build and Deploy java applications on Kubernetes
https://www.eclipse.dev/jkube/
Eclipse Public License 2.0
744 stars 482 forks source link

OpenShift Build resources not going via enrichment phase`oc:build` on subsequent builds #2561

Open rohanKanojia opened 8 months ago

rohanKanojia commented 8 months ago

Description

Taken from https://github.com/eclipse/jkube/issues/2500#issuecomment-1862477948

When using S2I build strategy OpenShift Maven Plugin creates BuildConfig and ImageStream, enrichs them via existing set of enrichers and then applies them on OpenShift Cluster.

This works well during the initial execution since all resources are created afresh. However, when we do subsequent oc:build on top of already existing BuildConfig (which was created from running oc:build for the first time, OpenShift Maven Plugin only updates the BuildConfig’s .spec.buildStrategy / .spec.buildOutput, Updated BuildConfig does not go via the enrichment phase.

You can see here in OpenShiftBuildService that BuildConfig is added to KubernetesListBuilder when creating a new BuildConfig. https://github.com/eclipse/jkube/blob/c387c2be37561f4a07788de0ce3aa63ed2a8b4fc/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/openshift/OpenshiftBuildService.java#L306

However, when updating it it’s not added to KubernetesListBuilder: https://github.com/eclipse/jkube/blob/c387c2be37561f4a07788de0ce3aa63ed2a8b4fc/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/openshift/OpenshiftBuildService.java#L320-L321

rohanKanojia commented 8 months ago

As a workaround, the user can force recreation of BuildConfig while running oc:build via jkube.build.recreate property:

$ mvn oc:build -Djkube.build.recreate=bc

This won't work for scenarios where you don't want to delete existing BuildConfig.

manusa commented 8 months ago

Following this morning internal discussion, as per our analysis, this doesn't seem like a valid issue, right?

The BuildConfig gets created and enriched. Then, for subsequent builds, the config just gets updated on the necessary fields. The whole point of the recreate optional flag is to fully recreate the build config if necessary as per de user needs.

rohanKanojia commented 8 months ago

@MimerPlusPlus: Hello, I have created PR https://github.com/eclipse/jkube/pull/2562 for adding git annotations to BuildConfig. Regarding our chat on Gitter about project version label not getting updated, Could you please check if using jkube.build.recreate sets project version label correctly in BuildConfig generated from oc:build?