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

Improve the error message when source resolver is not resolving #1152

Merged
merged 8 commits into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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