-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use pvb/pvr with updated failed phase for patching during startup
Use the same pvb/pvr update functions across pkg/controller and pkg/cli/nodeagent for consistency of behavior Signed-off-by: Tiger Kaovilai <[email protected]>
- Loading branch information
Showing
5 changed files
with
53 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package podvolumebackup | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
pkgclient "sigs.k8s.io/controller-runtime/pkg/client" | ||
) | ||
|
||
func UpdateStatusToFailed(client pkgclient.Client, ctx context.Context, pvb *velerov1api.PodVolumeBackup, errString string, time time.Time) error { | ||
original := pvb.DeepCopy() | ||
pvb.Status.Phase = velerov1api.PodVolumeBackupPhaseFailed | ||
pvb.Status.Message = errString | ||
pvb.Status.CompletionTimestamp = &metav1.Time{Time: time} | ||
|
||
return client.Patch(ctx, pvb, pkgclient.MergeFrom(original)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package podvolumerestore | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
pkgclient "sigs.k8s.io/controller-runtime/pkg/client" | ||
) | ||
|
||
func UpdateStatusToFailed(client pkgclient.Client, ctx context.Context, pvr *velerov1api.PodVolumeRestore, errString string, time time.Time) error { | ||
original := pvr.DeepCopy() | ||
pvr.Status.Phase = velerov1api.PodVolumeRestorePhaseFailed | ||
pvr.Status.Message = errString | ||
pvr.Status.CompletionTimestamp = &metav1.Time{Time: time} | ||
|
||
return client.Patch(ctx, pvr, pkgclient.MergeFrom(original)) | ||
} |