Merge pull request #8404 from Lyndon-Li/release-1.15

[1.15] Issue 8391: check ErrCancelled from suffix
pull/8465/head
lyndon-li 2024-11-13 13:42:03 +08:00 committed by GitHub
commit 40b8551a18
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 2 deletions

View File

@ -0,0 +1 @@
Fix issue #8391, check ErrCancelled from suffix of data mover pod's termination message

View File

@ -20,6 +20,7 @@ import (
"context"
"encoding/json"
"os"
"strings"
"sync"
"time"
@ -321,7 +322,7 @@ func (ms *microServiceBRWatcher) startWatch() {
if lastPod.Status.Phase == v1.PodSucceeded {
ms.callbacks.OnCompleted(ms.ctx, ms.namespace, ms.taskName, funcGetResultFromMessage(ms.taskType, terminateMessage, ms.log))
} else {
if terminateMessage == ErrCancelled {
if strings.HasSuffix(terminateMessage, ErrCancelled) {
ms.callbacks.OnCancelled(ms.ctx, ms.namespace, ms.taskName)
} else {
ms.callbacks.OnFailed(ms.ctx, ms.namespace, ms.taskName, errors.New(terminateMessage))

View File

@ -360,7 +360,7 @@ func TestStartWatch(t *testing.T) {
event: &v1.Event{Reason: EventReasonStopped},
},
},
terminationMessage: ErrCancelled,
terminationMessage: fmt.Sprintf("Failed to init data path service for DataUpload %s: %v", "fake-du-name", errors.New(ErrCancelled)),
expectStartEvent: true,
expectTerminateEvent: true,
expectCancel: true,