Change controller-runtime List option from MatchingFields to ListOptions.
Signed-off-by: Xun Jiang <jxun@vmware.com>pull/6958/head
parent
fd8350f919
commit
79c75718ca
|
@ -0,0 +1 @@
|
|||
Change controller-runtime List option from MatchingFields to ListOptions
|
|
@ -419,7 +419,7 @@ func (s *nodeAgentServer) markDataDownloadsCancel(r *controller.DataDownloadReco
|
|||
|
||||
func (s *nodeAgentServer) markInProgressPVBsFailed(client ctrlclient.Client) {
|
||||
pvbs := &velerov1api.PodVolumeBackupList{}
|
||||
if err := client.List(s.ctx, pvbs, &ctrlclient.MatchingFields{"metadata.namespace": s.namespace}); err != nil {
|
||||
if err := client.List(s.ctx, pvbs, &ctrlclient.ListOptions{Namespace: s.namespace}); err != nil {
|
||||
s.logger.WithError(errors.WithStack(err)).Error("failed to list podvolumebackups")
|
||||
return
|
||||
}
|
||||
|
@ -445,7 +445,7 @@ func (s *nodeAgentServer) markInProgressPVBsFailed(client ctrlclient.Client) {
|
|||
|
||||
func (s *nodeAgentServer) markInProgressPVRsFailed(client ctrlclient.Client) {
|
||||
pvrs := &velerov1api.PodVolumeRestoreList{}
|
||||
if err := client.List(s.ctx, pvrs, &ctrlclient.MatchingFields{"metadata.namespace": s.namespace}); err != nil {
|
||||
if err := client.List(s.ctx, pvrs, &ctrlclient.ListOptions{Namespace: s.namespace}); err != nil {
|
||||
s.logger.WithError(errors.WithStack(err)).Error("failed to list podvolumerestores")
|
||||
return
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ import (
|
|||
corev1api "k8s.io/api/core/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
kubeerrs "k8s.io/apimachinery/pkg/util/errors"
|
||||
|
@ -1056,7 +1057,7 @@ func markInProgressCRsFailed(ctx context.Context, cfg *rest.Config, scheme *runt
|
|||
|
||||
func markInProgressBackupsFailed(ctx context.Context, client ctrlclient.Client, namespace string, log logrus.FieldLogger) {
|
||||
backups := &velerov1api.BackupList{}
|
||||
if err := client.List(ctx, backups, &ctrlclient.MatchingFields{"metadata.namespace": namespace}); err != nil {
|
||||
if err := client.List(ctx, backups, &ctrlclient.ListOptions{Namespace: namespace}); err != nil {
|
||||
log.WithError(errors.WithStack(err)).Error("failed to list backups")
|
||||
return
|
||||
}
|
||||
|
@ -1081,7 +1082,7 @@ func markInProgressBackupsFailed(ctx context.Context, client ctrlclient.Client,
|
|||
|
||||
func markInProgressRestoresFailed(ctx context.Context, client ctrlclient.Client, namespace string, log logrus.FieldLogger) {
|
||||
restores := &velerov1api.RestoreList{}
|
||||
if err := client.List(ctx, restores, &ctrlclient.MatchingFields{"metadata.namespace": namespace}); err != nil {
|
||||
if err := client.List(ctx, restores, &ctrlclient.ListOptions{Namespace: namespace}); err != nil {
|
||||
log.WithError(errors.WithStack(err)).Error("failed to list restores")
|
||||
return
|
||||
}
|
||||
|
@ -1106,7 +1107,12 @@ func markInProgressRestoresFailed(ctx context.Context, client ctrlclient.Client,
|
|||
func markDataUploadsCancel(ctx context.Context, client ctrlclient.Client, backup velerov1api.Backup, log logrus.FieldLogger) {
|
||||
dataUploads := &velerov2alpha1api.DataUploadList{}
|
||||
|
||||
if err := client.List(ctx, dataUploads, &ctrlclient.MatchingFields{"metadata.namespace": backup.GetNamespace()}, &ctrlclient.MatchingLabels{velerov1api.BackupUIDLabel: string(backup.GetUID())}); err != nil {
|
||||
if err := client.List(ctx, dataUploads, &ctrlclient.ListOptions{
|
||||
Namespace: backup.GetNamespace(),
|
||||
LabelSelector: labels.Set(map[string]string{
|
||||
velerov1api.BackupUIDLabel: string(backup.GetUID()),
|
||||
}).AsSelector(),
|
||||
}); err != nil {
|
||||
log.WithError(errors.WithStack(err)).Error("failed to list dataUploads")
|
||||
return
|
||||
}
|
||||
|
@ -1134,7 +1140,12 @@ func markDataUploadsCancel(ctx context.Context, client ctrlclient.Client, backup
|
|||
func markDataDownloadsCancel(ctx context.Context, client ctrlclient.Client, restore velerov1api.Restore, log logrus.FieldLogger) {
|
||||
dataDownloads := &velerov2alpha1api.DataDownloadList{}
|
||||
|
||||
if err := client.List(ctx, dataDownloads, &ctrlclient.MatchingFields{"metadata.namespace": restore.GetNamespace()}, &ctrlclient.MatchingLabels{velerov1api.RestoreUIDLabel: string(restore.GetUID())}); err != nil {
|
||||
if err := client.List(ctx, dataDownloads, &ctrlclient.ListOptions{
|
||||
Namespace: restore.GetNamespace(),
|
||||
LabelSelector: labels.Set(map[string]string{
|
||||
velerov1api.RestoreUIDLabel: string(restore.GetUID()),
|
||||
}).AsSelector(),
|
||||
}); err != nil {
|
||||
log.WithError(errors.WithStack(err)).Error("failed to list dataDownloads")
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue