mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-04-26 02:30:35 +00:00
Pass Velero server command args to the plugins
Pass Velero server command args to the plugins Fixes #7806 Signed-off-by: Wenkai Yin(尹文开) <yinw@vmware.com>
This commit is contained in:
@@ -42,6 +42,7 @@ import (
|
||||
"github.com/vmware-tanzu/velero/internal/volume"
|
||||
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
|
||||
pkgbackup "github.com/vmware-tanzu/velero/pkg/backup"
|
||||
"github.com/vmware-tanzu/velero/pkg/constant"
|
||||
"github.com/vmware-tanzu/velero/pkg/discovery"
|
||||
"github.com/vmware-tanzu/velero/pkg/features"
|
||||
"github.com/vmware-tanzu/velero/pkg/label"
|
||||
@@ -201,7 +202,7 @@ func getLastSuccessBySchedule(backups []velerov1api.Backup) map[string]time.Time
|
||||
|
||||
func (b *backupReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
|
||||
log := b.logger.WithFields(logrus.Fields{
|
||||
"controller": Backup,
|
||||
"controller": constant.ControllerBackup,
|
||||
"backuprequest": req.String(),
|
||||
})
|
||||
|
||||
@@ -591,16 +592,16 @@ func (b *backupReconciler) validateAndGetSnapshotLocations(backup *velerov1api.B
|
||||
// field is checked to see if the backup was a partial failure.
|
||||
|
||||
func (b *backupReconciler) runBackup(backup *pkgbackup.Request) error {
|
||||
b.logger.WithField(Backup, kubeutil.NamespaceAndName(backup)).Info("Setting up backup log")
|
||||
b.logger.WithField(constant.ControllerBackup, kubeutil.NamespaceAndName(backup)).Info("Setting up backup log")
|
||||
|
||||
// Log the backup to both a backup log file and to stdout. This will help see what happened if the upload of the
|
||||
// backup log failed for whatever reason.
|
||||
logCounter := logging.NewLogHook()
|
||||
backupLog, err := logging.NewTempFileLogger(b.backupLogLevel, b.formatFlag, logCounter, logrus.Fields{Backup: kubeutil.NamespaceAndName(backup)})
|
||||
backupLog, err := logging.NewTempFileLogger(b.backupLogLevel, b.formatFlag, logCounter, logrus.Fields{constant.ControllerBackup: kubeutil.NamespaceAndName(backup)})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error creating dual mode logger for backup")
|
||||
}
|
||||
defer backupLog.Dispose(b.logger.WithField(Backup, kubeutil.NamespaceAndName(backup)))
|
||||
defer backupLog.Dispose(b.logger.WithField(constant.ControllerBackup, kubeutil.NamespaceAndName(backup)))
|
||||
|
||||
backupLog.Info("Setting up backup temp file")
|
||||
backupFile, err := os.CreateTemp("", "")
|
||||
@@ -678,7 +679,7 @@ func (b *backupReconciler) runBackup(backup *pkgbackup.Request) error {
|
||||
"errors": backupErrors,
|
||||
}
|
||||
|
||||
backupLog.DoneForPersist(b.logger.WithField(Backup, kubeutil.NamespaceAndName(backup)))
|
||||
backupLog.DoneForPersist(b.logger.WithField(constant.ControllerBackup, kubeutil.NamespaceAndName(backup)))
|
||||
|
||||
// Assign finalize phase as close to end as possible so that any errors
|
||||
// logged to backupLog are captured. This is done before uploading the
|
||||
@@ -725,7 +726,7 @@ func (b *backupReconciler) runBackup(backup *pkgbackup.Request) error {
|
||||
}
|
||||
}
|
||||
|
||||
b.logger.WithField(Backup, kubeutil.NamespaceAndName(backup)).Infof("Initial backup processing complete, moving to %s", backup.Status.Phase)
|
||||
b.logger.WithField(constant.ControllerBackup, kubeutil.NamespaceAndName(backup)).Infof("Initial backup processing complete, moving to %s", backup.Status.Phase)
|
||||
|
||||
// if we return a non-nil error, the calling function will update
|
||||
// the backup's phase to Failed.
|
||||
|
||||
@@ -40,6 +40,7 @@ import (
|
||||
"github.com/vmware-tanzu/velero/internal/volume"
|
||||
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
|
||||
velerov2alpha1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v2alpha1"
|
||||
"github.com/vmware-tanzu/velero/pkg/constant"
|
||||
"github.com/vmware-tanzu/velero/pkg/discovery"
|
||||
"github.com/vmware-tanzu/velero/pkg/label"
|
||||
"github.com/vmware-tanzu/velero/pkg/metrics"
|
||||
@@ -114,7 +115,7 @@ func (r *backupDeletionReconciler) SetupWithManager(mgr ctrl.Manager) error {
|
||||
|
||||
func (r *backupDeletionReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
|
||||
log := r.logger.WithFields(logrus.Fields{
|
||||
"controller": BackupDeletion,
|
||||
"controller": constant.ControllerBackupDeletion,
|
||||
"deletebackuprequest": req.String(),
|
||||
})
|
||||
log.Debug("Getting deletebackuprequest")
|
||||
|
||||
@@ -30,6 +30,7 @@ import (
|
||||
|
||||
"github.com/vmware-tanzu/velero/internal/storage"
|
||||
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
|
||||
"github.com/vmware-tanzu/velero/pkg/constant"
|
||||
"github.com/vmware-tanzu/velero/pkg/persistence"
|
||||
"github.com/vmware-tanzu/velero/pkg/plugin/clientmgmt"
|
||||
"github.com/vmware-tanzu/velero/pkg/util/kube"
|
||||
@@ -80,7 +81,7 @@ func (r *backupStorageLocationReconciler) Reconcile(ctx context.Context, req ctr
|
||||
var unavailableErrors []string
|
||||
var location velerov1api.BackupStorageLocation
|
||||
|
||||
log := r.log.WithField("controller", BackupStorageLocation).WithField(BackupStorageLocation, req.NamespacedName.String())
|
||||
log := r.log.WithField("controller", constant.ControllerBackupStorageLocation).WithField(constant.ControllerBackupStorageLocation, req.NamespacedName.String())
|
||||
log.Debug("Validating availability of BackupStorageLocation")
|
||||
|
||||
locationList, err := storage.ListBackupStorageLocations(r.ctx, r.client, req.Namespace)
|
||||
@@ -155,7 +156,7 @@ func (r *backupStorageLocationReconciler) logReconciledPhase(defaultFound bool,
|
||||
var availableBSLs []*velerov1api.BackupStorageLocation
|
||||
var unAvailableBSLs []*velerov1api.BackupStorageLocation
|
||||
var unknownBSLs []*velerov1api.BackupStorageLocation
|
||||
log := r.log.WithField("controller", BackupStorageLocation)
|
||||
log := r.log.WithField("controller", constant.ControllerBackupStorageLocation)
|
||||
|
||||
for i, location := range locationList.Items {
|
||||
phase := location.Status.Phase
|
||||
@@ -198,7 +199,7 @@ func (r *backupStorageLocationReconciler) SetupWithManager(mgr ctrl.Manager) err
|
||||
)
|
||||
gp := kube.NewGenericEventPredicate(func(object client.Object) bool {
|
||||
location := object.(*velerov1api.BackupStorageLocation)
|
||||
return storage.IsReadyToValidate(location.Spec.ValidationFrequency, location.Status.LastValidationTime, r.defaultBackupLocationInfo.ServerValidationFrequency, r.log.WithField("controller", BackupStorageLocation))
|
||||
return storage.IsReadyToValidate(location.Spec.ValidationFrequency, location.Status.LastValidationTime, r.defaultBackupLocationInfo.ServerValidationFrequency, r.log.WithField("controller", constant.ControllerBackupStorageLocation))
|
||||
})
|
||||
return ctrl.NewControllerManagedBy(mgr).
|
||||
// As the "status.LastValidationTime" field is always updated, this triggers new reconciling process, skip the update event that include no spec change to avoid the reconcile loop
|
||||
|
||||
@@ -34,6 +34,7 @@ import (
|
||||
"sigs.k8s.io/controller-runtime/pkg/builder"
|
||||
|
||||
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
|
||||
"github.com/vmware-tanzu/velero/pkg/constant"
|
||||
"github.com/vmware-tanzu/velero/pkg/features"
|
||||
"github.com/vmware-tanzu/velero/pkg/label"
|
||||
"github.com/vmware-tanzu/velero/pkg/persistence"
|
||||
@@ -78,7 +79,7 @@ func NewBackupSyncReconciler(
|
||||
|
||||
// Reconcile syncs between the backups in cluster and backups metadata in object store.
|
||||
func (b *backupSyncReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
|
||||
log := b.logger.WithField("controller", BackupSync)
|
||||
log := b.logger.WithField("controller", constant.ControllerBackupSync)
|
||||
log = log.WithField("backupLocation", req.String())
|
||||
log.Debug("Begin to sync between backups' metadata in BSL object storage and cluster's existing backups.")
|
||||
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
Copyright 2020 the Velero contributors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package controller
|
||||
|
||||
const (
|
||||
Backup = "backup"
|
||||
BackupOperations = "backup-operations"
|
||||
BackupDeletion = "backup-deletion"
|
||||
BackupFinalizer = "backup-finalizer"
|
||||
BackupRepo = "backup-repo"
|
||||
BackupStorageLocation = "backup-storage-location"
|
||||
BackupSync = "backup-sync"
|
||||
DownloadRequest = "download-request"
|
||||
GarbageCollection = "gc"
|
||||
PodVolumeBackup = "pod-volume-backup"
|
||||
PodVolumeRestore = "pod-volume-restore"
|
||||
Restore = "restore"
|
||||
RestoreOperations = "restore-operations"
|
||||
Schedule = "schedule"
|
||||
ServerStatusRequest = "server-status-request"
|
||||
RestoreFinalizer = "restore-finalizer"
|
||||
)
|
||||
|
||||
// DisableableControllers is a list of controllers that can be disabled
|
||||
var DisableableControllers = []string{
|
||||
Backup,
|
||||
BackupOperations,
|
||||
BackupDeletion,
|
||||
BackupFinalizer,
|
||||
BackupSync,
|
||||
DownloadRequest,
|
||||
GarbageCollection,
|
||||
BackupRepo,
|
||||
Restore,
|
||||
RestoreOperations,
|
||||
Schedule,
|
||||
ServerStatusRequest,
|
||||
RestoreFinalizer,
|
||||
}
|
||||
@@ -32,6 +32,7 @@ import (
|
||||
"github.com/vmware-tanzu/velero/internal/velero"
|
||||
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
|
||||
"github.com/vmware-tanzu/velero/pkg/buildinfo"
|
||||
"github.com/vmware-tanzu/velero/pkg/constant"
|
||||
"github.com/vmware-tanzu/velero/pkg/plugin/framework"
|
||||
"github.com/vmware-tanzu/velero/pkg/plugin/framework/common"
|
||||
)
|
||||
@@ -77,7 +78,7 @@ func NewServerStatusRequestReconciler(
|
||||
|
||||
func (r *serverStatusRequestReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
|
||||
log := r.log.WithFields(logrus.Fields{
|
||||
"controller": ServerStatusRequest,
|
||||
"controller": constant.ControllerServerStatusRequest,
|
||||
"serverStatusRequest": req.NamespacedName,
|
||||
})
|
||||
|
||||
@@ -95,7 +96,7 @@ func (r *serverStatusRequestReconciler) Reconcile(ctx context.Context, req ctrl.
|
||||
}
|
||||
|
||||
log = r.log.WithFields(logrus.Fields{
|
||||
"controller": ServerStatusRequest,
|
||||
"controller": constant.ControllerServerStatusRequest,
|
||||
"serverStatusRequest": req.NamespacedName,
|
||||
"phase": statusRequest.Status.Phase,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user