diff --git a/pkg/cmds/restore_volumesnapshot.go b/pkg/cmds/restore_volumesnapshot.go index 008e87373..b77125d38 100644 --- a/pkg/cmds/restore_volumesnapshot.go +++ b/pkg/cmds/restore_volumesnapshot.go @@ -85,7 +85,7 @@ func (opt *VSoption) restoreVolumeSnapshot() (*restic.RestoreOutput, error) { return nil, fmt.Errorf("no target has been specified for RestoreSession %s/%s", restoreSession.Namespace, restoreSession.Name) } - pvcList := make([]core.PersistentVolumeClaim, 0) + var pvcList []core.PersistentVolumeClaim // if replica field is specified, then use it. otherwise, default it to 1 replicas := int32(1) if restoreSession.Spec.Target.Replicas != nil { @@ -117,7 +117,7 @@ func (opt *VSoption) restoreVolumeSnapshot() (*restic.RestoreOutput, error) { Phase: api_v1beta1.HostRestoreFailed, Error: fmt.Sprintf("VolumeSnapshot %s/%s does not exist", pvcList[i].Namespace, pvcList[i].Spec.DataSource.Name), }) - // continue to process next pvc + // continue to process next VolumeSnapshot continue } else { return nil, err @@ -126,7 +126,7 @@ func (opt *VSoption) restoreVolumeSnapshot() (*restic.RestoreOutput, error) { } // now, create the PVC - _, err := opt.kubeClient.CoreV1().PersistentVolumeClaims(opt.namespace).Create(&pvcList[i]) + pvc, err := opt.kubeClient.CoreV1().PersistentVolumeClaims(opt.namespace).Create(&pvcList[i]) if err != nil { if kerr.IsAlreadyExists(err) { restoreOutput.HostRestoreStats = append(restoreOutput.HostRestoreStats, api_v1beta1.HostRestoreStats{ @@ -141,7 +141,7 @@ func (opt *VSoption) restoreVolumeSnapshot() (*restic.RestoreOutput, error) { } } // PVC has been created successfully. store it's definition so that we can wait for it to be initialized - createdPVCs = append(createdPVCs, pvcList[i]) + createdPVCs = append(createdPVCs, *pvc) } // now, wait for the PVCs to be initialized from respective VolumeSnapshot diff --git a/pkg/controller/backup_session.go b/pkg/controller/backup_session.go index 71e39ec2c..b86eef568 100644 --- a/pkg/controller/backup_session.go +++ b/pkg/controller/backup_session.go @@ -136,7 +136,7 @@ func (c *StashController) runBackupSessionProcessor(key string) error { // skip if backup model is sidecar. // for sidecar model controller inside sidecar will take care of it. - if backupConfig.Spec.Target != nil && util.BackupModel(backupConfig.Spec.Target.Ref.Kind) == util.ModelSidecar { + if backupConfig.Spec.Target != nil && backupConfig.Spec.Driver != api_v1beta1.VolumeSnapshotter && util.BackupModel(backupConfig.Spec.Target.Ref.Kind) == util.ModelSidecar { log.Infof("Skipping processing BackupSession %s/%s. Reason: Backup model is sidecar. Controller inside sidecar will take care of it.", backupSession.Namespace, backupSession.Name) return c.setBackupSessionRunning(backupSession) } diff --git a/pkg/controller/sidecar.go b/pkg/controller/sidecar.go index b0945dc41..22c8a4ec3 100644 --- a/pkg/controller/sidecar.go +++ b/pkg/controller/sidecar.go @@ -326,7 +326,7 @@ func isPodOwnedByWorkload(w *wapi.Workload, pod core.Pod) bool { } func (c *StashController) handleSidecarInjectionFailure(ref *core.ObjectReference, err error) error { - log.Warningf("Failed to inject stash sidecar inot %s %s/%s. Reason: %v", ref.Kind, ref.Namespace, ref.Name, err) + log.Warningf("Failed to inject stash sidecar into %s %s/%s. Reason: %v", ref.Kind, ref.Namespace, ref.Name, err) // write event to respective resource _, err2 := eventer.CreateEvent( diff --git a/pkg/resolve/task.go b/pkg/resolve/task.go index ae8c3afeb..a49cf2869 100644 --- a/pkg/resolve/task.go +++ b/pkg/resolve/task.go @@ -142,11 +142,12 @@ func GetPVCFromVolumeClaimTemplates(ordinal int32, claimTemplates []core.Persist for i := range claimTemplates { inputs := make(map[string]string) inputs[util.KeyPodOrdinal] = strconv.Itoa(int(ordinal)) - err := ResolvePVCSpec(&claimTemplates[i], inputs) + claim := claimTemplates[i].DeepCopy() + err := ResolvePVCSpec(claim, inputs) if err != nil { return pvcList, err } - pvcList = append(pvcList, claimTemplates[i]) + pvcList = append(pvcList, *claim) } return pvcList, nil } diff --git a/pkg/restic/restic_test.go b/pkg/restic/restic_test.go index 2d64b7d75..663f8e56a 100644 --- a/pkg/restic/restic_test.go +++ b/pkg/restic/restic_test.go @@ -58,7 +58,7 @@ func setupTest(tempDir string) (*ResticWrapper, error) { setupOpt := SetupOptions{ Provider: storage.ProviderLocal, - Bucket: localRepoDir, + Bucket: localRepoDir, SecretDir: secretDir, ScratchDir: scratchDir, EnableCache: false, diff --git a/pkg/status/status.go b/pkg/status/status.go index 34f15db09..56edd5042 100644 --- a/pkg/status/status.go +++ b/pkg/status/status.go @@ -67,7 +67,7 @@ func (o UpdateStatusOptions) UpdatePostBackupStatus(backupOutput *restic.BackupO // add or update entry for each host in BackupSession status + create event for _, hostStats := range backupOutput.HostBackupStats { log.Infof("Updating status of BackupSession: %s/%s for host: %s", backupSession.Namespace, backupSession.Name, hostStats.Hostname) - _, err = stash_util_v1beta1.UpdateBackupSessionStatusForHost(o.StashClient.StashV1beta1(), backupSession, hostStats) + backupSession, err = stash_util_v1beta1.UpdateBackupSessionStatusForHost(o.StashClient.StashV1beta1(), backupSession, hostStats) if err != nil { return err } @@ -150,7 +150,7 @@ func (o UpdateStatusOptions) UpdatePostRestoreStatus(restoreOutput *restic.Resto // add or update entry for each host in RestoreSession status for _, hostStats := range restoreOutput.HostRestoreStats { log.Infof("Updating status of RestoreSession: %s/%s for host: %s", restoreSession.Namespace, restoreSession.Name, hostStats.Hostname) - _, err = stash_util_v1beta1.UpdateRestoreSessionStatusForHost(o.StashClient.StashV1beta1(), restoreSession, hostStats) + restoreSession, err = stash_util_v1beta1.UpdateRestoreSessionStatusForHost(o.StashClient.StashV1beta1(), restoreSession, hostStats) if err != nil { return err }