Skip to content

Commit

Permalink
Fix imageTag for OpenShift bulilds
Browse files Browse the repository at this point in the history
Signed-off-by: Ricardo Zanini <[email protected]>
  • Loading branch information
ricardozanini committed Aug 4, 2023
1 parent 8ee9c55 commit 8cf4581
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
11 changes: 6 additions & 5 deletions controllers/builder/openshiftbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ func (o *openshiftBuilderManager) Schedule(build *operatorapi.SonataFlowBuild) e
if err != nil {
return err
}
build.Status.ImageTag = workflowdef.GetWorkflowAppImageNameTag(workflow)
bc := o.newDefaultBuildConfig(build)
bc := o.newDefaultBuildConfig(build, workflow)
if err = o.addExternalResources(bc, workflow); err != nil {
return err
}
Expand All @@ -131,7 +130,7 @@ func (o *openshiftBuilderManager) Schedule(build *operatorapi.SonataFlowBuild) e
if kubeutil.IsObjectNew(bc) {
return nil
}
referenceBC := o.newDefaultBuildConfig(build)
referenceBC := o.newDefaultBuildConfig(build, workflow)
bc.Spec = *referenceBC.Spec.DeepCopy()
return o.addExternalResources(bc, workflow)
}); err != nil {
Expand All @@ -142,7 +141,7 @@ func (o *openshiftBuilderManager) Schedule(build *operatorapi.SonataFlowBuild) e
return nil
}

func (o *openshiftBuilderManager) newDefaultBuildConfig(build *operatorapi.SonataFlowBuild) *buildv1.BuildConfig {
func (o *openshiftBuilderManager) newDefaultBuildConfig(build *operatorapi.SonataFlowBuild, workflow *operatorapi.SonataFlow) *buildv1.BuildConfig {
optimizationPol := buildv1.ImageOptimizationSkipLayers
dockerFile := platform.GetCustomizedDockerfile(o.commonConfig.Data[o.commonConfig.Data[configKeyDefaultBuilderResourceName]], *o.platform)
return &buildv1.BuildConfig{
Expand All @@ -165,7 +164,7 @@ func (o *openshiftBuilderManager) newDefaultBuildConfig(build *operatorapi.Sonat
Output: buildv1.BuildOutput{
To: &corev1.ObjectReference{
Namespace: build.Namespace,
Name: build.Status.ImageTag,
Name: workflowdef.GetWorkflowAppImageNameTag(workflow),
Kind: imageStreamTagKind,
},
},
Expand Down Expand Up @@ -218,6 +217,7 @@ func (o *openshiftBuilderManager) Reconcile(build *operatorapi.SonataFlowBuild)
return err
}
build.Status.BuildPhase = operatorapi.BuildPhaseScheduling
build.Status.ImageTag = openshiftBuild.Status.OutputDockerImageReference
return build.Status.SetInnerBuild(kubeutil.ToTypedLocalReference(openshiftBuild))
}

Expand All @@ -234,6 +234,7 @@ func (o *openshiftBuilderManager) Reconcile(build *operatorapi.SonataFlowBuild)
if openshiftBuild.Status.Phase == buildv1.BuildPhaseError {
build.Status.Error = openshiftBuild.Status.Message
}
build.Status.ImageTag = openshiftBuild.Status.OutputDockerImageReference

return build.Status.SetInnerBuild(kubeutil.ToTypedLocalReference(openshiftBuild))
}
Expand Down
2 changes: 1 addition & 1 deletion controllers/sonataflowbuild_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (r *SonataFlowBuildReconciler) Reconcile(ctx context.Context, req ctrl.Requ
if err = buildManager.Reconcile(build); err != nil {
return ctrl.Result{}, err
}
if !reflect.DeepEqual(build.Status.InnerBuild, beforeReconcileStatus.InnerBuild) {
if !reflect.DeepEqual(build.Status, beforeReconcileStatus) {
if err = r.manageStatusUpdate(ctx, build); err != nil {
return ctrl.Result{}, err
}
Expand Down
1 change: 1 addition & 0 deletions hack/local/run-operator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
kubectl apply -f ./bundle/manifests/sonataflow.org_sonataflowplatforms.yaml
kubectl apply -f ./bundle/manifests/sonataflow.org_sonataflowbuilds.yaml
kubectl apply -f ./bundle/manifests/sonataflow.org_sonataflows.yaml
kubectl apply -f ./bundle/manifests/sonataflow-operator-builder-config_v1_configmap.yaml

make debug

0 comments on commit 8cf4581

Please sign in to comment.