Skip to content

Commit

Permalink
Merge e89de9a into 79126fe
Browse files Browse the repository at this point in the history
  • Loading branch information
yaelharel authored Mar 10, 2023
2 parents 79126fe + e89de9a commit 595182f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
21 changes: 9 additions & 12 deletions pkg/reconciler/image/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"time"

"github.com/sclevine/spec"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
Expand Down Expand Up @@ -764,7 +765,11 @@ func testImageReconciler(t *testing.T, when spec.G, it spec.S) {
unresolvedSourceResolver(imageWithBuilder),
},
WantErr: false,
//no builds are created
WantCreates: nil,
})

assert.Equal(t, "SourceResolver image-name-source is not ready", imageWithBuilder.Status.GetCondition(corev1alpha1.ConditionReady).Message)
})

it("does not schedule a build if the builder is not ready", func() {
Expand Down Expand Up @@ -2247,16 +2252,7 @@ func testImageReconciler(t *testing.T, when spec.G, it spec.S) {
Status: buildapi.ImageStatus{
Status: corev1alpha1.Status{
ObservedGeneration: originalGeneration,
Conditions: corev1alpha1.Conditions{
{
Type: corev1alpha1.ConditionReady,
Status: corev1.ConditionUnknown,
},
{
Type: buildapi.ConditionBuilderReady,
Status: corev1.ConditionTrue,
},
},
Conditions: conditionReadyUnknown(),
},
LatestBuildRef: "image-name-build-1",
LatestImage: "some/image@sha256:build-1",
Expand Down Expand Up @@ -2596,8 +2592,9 @@ func limit(limit int64) *int64 {
func conditionReadyUnknown() corev1alpha1.Conditions {
return corev1alpha1.Conditions{
{
Type: corev1alpha1.ConditionReady,
Status: corev1.ConditionUnknown,
Type: corev1alpha1.ConditionReady,
Status: corev1.ConditionUnknown,
Message: "SourceResolver image-name-source is not ready",
},
{
Type: buildapi.ConditionBuilderReady,
Expand Down
9 changes: 7 additions & 2 deletions pkg/reconciler/image/reconcile_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (c *Reconciler) reconcileBuild(ctx context.Context, image *buildapi.Image,
case corev1.ConditionFalse:
return buildapi.ImageStatus{
Status: corev1alpha1.Status{
Conditions: noScheduledBuild(result.ConditionStatus, builder, latestBuild),
Conditions: noScheduledBuild(result.ConditionStatus, builder, latestBuild, sourceResolver),
},
LatestBuildRef: latestBuild.BuildRef(),
LatestBuildReason: latestBuild.BuildReason(),
Expand All @@ -70,12 +70,17 @@ func (c *Reconciler) reconcileBuild(ctx context.Context, image *buildapi.Image,
}
}

func noScheduledBuild(buildNeeded corev1.ConditionStatus, builder buildapi.BuilderResource, build *buildapi.Build) corev1alpha1.Conditions {
func noScheduledBuild(buildNeeded corev1.ConditionStatus, builder buildapi.BuilderResource, build *buildapi.Build, sourceResolver *buildapi.SourceResolver) corev1alpha1.Conditions {
if buildNeeded == corev1.ConditionUnknown {
message := ""
if !sourceResolver.Ready() {
message = fmt.Sprintf("SourceResolver %s is not ready", sourceResolver.GetName())
}
return corev1alpha1.Conditions{
{
Type: corev1alpha1.ConditionReady,
Status: corev1.ConditionUnknown,
Message: message,
LastTransitionTime: corev1alpha1.VolatileTime{Inner: metav1.Now()},
},
builderCondition(builder),
Expand Down

0 comments on commit 595182f

Please sign in to comment.