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

Bug 1854857: initial create errors should map to SamplesExists instead of ImageChangesInProgress #303

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/stub/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -877,8 +877,8 @@ func (h *Handler) Handle(event util.Event) error {

if err != nil {
cfg = h.refetchCfgMinimizeConflicts(cfg)
h.processError(cfg, v1.ImageChangesInProgress, corev1.ConditionUnknown, err, "error creating samples: %v")
dbg := "setting in progress to unknown"
h.processError(cfg, v1.SamplesExist, corev1.ConditionUnknown, err, "error creating samples: %v")
dbg := "setting samples exists to unknown"
logrus.Printf("CRDUPDATE %s", dbg)
e := h.crdwrapper.UpdateStatus(cfg, dbg)
if e != nil {
Expand Down
40 changes: 37 additions & 3 deletions pkg/stub/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,8 @@ func TestImageGetError(t *testing.T) {
statuses := []corev1.ConditionStatus{corev1.ConditionFalse, corev1.ConditionTrue, corev1.ConditionTrue, corev1.ConditionTrue, corev1.ConditionFalse, corev1.ConditionFalse, corev1.ConditionFalse}
err := h.Handle(event)
if !kerrors.IsNotFound(iserr) {
statuses[3] = corev1.ConditionUnknown
statuses[0] = corev1.ConditionUnknown
statuses[3] = corev1.ConditionFalse
validate(false, err, "getstreamerror", cfg, conditions, statuses, t)
} else {
validate(true, err, "", cfg, conditions, statuses, t)
Expand All @@ -841,6 +842,23 @@ func TestImageGetError(t *testing.T) {

}

func TestImageUpdateError(t *testing.T) {

h, cfg, event := setup()

mimic(&h, x86OCPContentRootDir)

fakeisclient := h.imageclientwrapper.(*fakeImageStreamClientWrapper)
fakeisclient.upserterrors = map[string]error{"foo": kerrors.NewServiceUnavailable("upsertstreamerror")}

statuses := []corev1.ConditionStatus{corev1.ConditionFalse, corev1.ConditionTrue, corev1.ConditionTrue, corev1.ConditionTrue, corev1.ConditionFalse, corev1.ConditionFalse, corev1.ConditionFalse}
err := h.Handle(event)
statuses[0] = corev1.ConditionUnknown
statuses[3] = corev1.ConditionFalse
validate(false, err, "upsertstreamerror", cfg, conditions, statuses, t)

}

func TestImageStreamImportError(t *testing.T) {
two := int64(2)
one := int64(1)
Expand Down Expand Up @@ -1142,7 +1160,7 @@ func TestImageImportRequestCreation(t *testing.T) {
}
}

func TestTemplateGetEreror(t *testing.T) {
func TestTemplateGetError(t *testing.T) {
errors := []error{
fmt.Errorf("gettemplateerror"),
kerrors.NewNotFound(schema.GroupResource{}, "gettemplateerror"),
Expand All @@ -1158,7 +1176,8 @@ func TestTemplateGetEreror(t *testing.T) {
statuses := []corev1.ConditionStatus{corev1.ConditionFalse, corev1.ConditionTrue, corev1.ConditionTrue, corev1.ConditionTrue, corev1.ConditionFalse, corev1.ConditionFalse, corev1.ConditionFalse}
err := h.Handle(event)
if !kerrors.IsNotFound(terr) {
statuses[3] = corev1.ConditionUnknown
statuses[0] = corev1.ConditionUnknown
statuses[3] = corev1.ConditionFalse
validate(false, err, "gettemplateerror", cfg, conditions, statuses, t)
} else {
validate(true, err, "", cfg, conditions, statuses, t)
Expand All @@ -1167,6 +1186,21 @@ func TestTemplateGetEreror(t *testing.T) {

}

func TestTemplateUpsertError(t *testing.T) {
h, cfg, event := setup()

mimic(&h, x86OCPContentRootDir)

faketclient := h.templateclientwrapper.(*fakeTemplateClientWrapper)
faketclient.upserterrors = map[string]error{"bo": kerrors.NewServiceUnavailable("upsertstreamerror")}

statuses := []corev1.ConditionStatus{corev1.ConditionFalse, corev1.ConditionTrue, corev1.ConditionTrue, corev1.ConditionTrue, corev1.ConditionFalse, corev1.ConditionFalse, corev1.ConditionFalse}
err := h.Handle(event)
statuses[0] = corev1.ConditionUnknown
statuses[3] = corev1.ConditionFalse
validate(false, err, "upsertstreamerror", cfg, conditions, statuses, t)
}

func TestDeletedCR(t *testing.T) {
h, cfg, event := setup()
event.Deleted = true
Expand Down