Skip to content

Commit

Permalink
Merge pull request #303 from gabemontero/api-svr-err-not-cleared
Browse files Browse the repository at this point in the history
Bug 1854857: initial create errors should map to SamplesExists instead of ImageChangesInProgress
  • Loading branch information
openshift-merge-robot committed Jul 9, 2020
2 parents b604211 + 02b9d0a commit 09de303
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
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

0 comments on commit 09de303

Please sign in to comment.