Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions apis/stash/v1alpha1/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,15 @@ func (r Repository) IsValid() error {
return fmt.Errorf("wipe out operation is not supported for B2 backend")
}
}

if r.Spec.Backend.Local != nil && r.Spec.Backend.Local.MountPath != "" {
parts := strings.Split(r.Spec.Backend.Local.MountPath, "/")
if len(parts) >= 2 && parts[1] == "stash" {
return fmt.Errorf("\n\t" +
"Error: Invalid `mountPath` specification for local backend.\n\t" +
"Reason: We have put `stash` binary in the root directory. Hence, you can not use `/stash` or `/stash/*` as `mountPath` \n\t" +
"Hints: Use `/stash-backup` or anything else except the forbidden ones as `mountPath`.")
}
}
return nil
}
4 changes: 2 additions & 2 deletions pkg/controller/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ func (c *StashController) handleAutoBackupResourcesCreationSuccess(ref *core.Obj
c.kubeClient,
eventer.EventSourceAutoBackupHandler,
ref,
core.EventTypeWarning,
core.EventTypeNormal,
eventer.EventReasonAutoBackupResourcesCreationSucceeded,
fmt.Sprintf("Successfully created auto backup resources for %s %s/%s.", ref.Kind, ref.Namespace, ref.Name),
)
Expand Down Expand Up @@ -448,7 +448,7 @@ func (c *StashController) handleAutoBackupResourcesDeletionSuccess(ref *core.Obj
c.kubeClient,
eventer.EventSourceAutoBackupHandler,
ref,
core.EventTypeWarning,
core.EventTypeNormal,
eventer.EventReasonAutoBackupResourcesDeletionSucceeded,
fmt.Sprintf("Successfully deleted auto backup resources for %s %s/%s.", ref.Kind, ref.Namespace, ref.Name),
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func NewPVCRestorerJob(rs *api_v1beta1.RestoreSession, repository *api_v1alpha1.
Image: image.ToContainerImage(),
Args: append([]string{
"restore",
"--restore-session=" + rs.Name,
"--restoresession=" + rs.Name,
"--restore-model=job",
"--secret-dir=" + StashSecretMountDir,
fmt.Sprintf("--enable-cache=%v", !rs.Spec.TempDir.DisableCaching),
Expand Down
11 changes: 3 additions & 8 deletions test/e2e/advance-configuration/runtimesettings.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ limitations under the License.
package advance_configuration

import (
"fmt"

"stash.appscode.dev/stash/apis"
"stash.appscode.dev/stash/apis/stash/v1beta1"
"stash.appscode.dev/stash/test/e2e/framework"
Expand All @@ -40,10 +38,7 @@ var _ = Describe("Advanced Configuration", func() {
})

JustAfterEach(func() {
if CurrentGinkgoTestDescription().Failed {
f.PrintDebugHelpers()
framework.TestFailed = true
}
f.PrintDebugInfoOnFailure()
})

AfterEach(func() {
Expand All @@ -55,7 +50,7 @@ var _ = Describe("Advanced Configuration", func() {
Context("With NICE and IONICE", func() {
It("should Backup & Restore successfully", func() {
// Deploy a Deployment
deployment, err := f.DeployDeployment(fmt.Sprintf("source-deployment1-%s", f.App()), int32(1))
deployment, err := f.DeployDeployment(framework.SourceDeployment, int32(1), framework.SourceVolume)
Expect(err).NotTo(HaveOccurred())

// Generate Sample Data
Expand Down Expand Up @@ -99,7 +94,7 @@ var _ = Describe("Advanced Configuration", func() {

// Restore the backed up data
By("Restoring the backed up data in the original Deployment")
restoreSession, err := f.SetupRestoreProcess(deployment.ObjectMeta, repo, apis.KindDeployment, func(restore *v1beta1.RestoreSession) {
restoreSession, err := f.SetupRestoreProcess(deployment.ObjectMeta, repo, apis.KindDeployment, framework.SourceVolume, func(restore *v1beta1.RestoreSession) {
restore.Spec.RuntimeSettings = ofst.RuntimeSettings{
Container: &ofst.ContainerRuntimeSettings{
Nice: &ofst.NiceSettings{
Expand Down
23 changes: 10 additions & 13 deletions test/e2e/auto-backup/daemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ var _ = Describe("Auto-Backup", func() {
})

JustAfterEach(func() {
if CurrentGinkgoTestDescription().Failed {
f.PrintDebugHelpers()
framework.TestFailed = true
}
f.PrintDebugInfoOnFailure()
})

AfterEach(func() {
Expand All @@ -56,7 +53,7 @@ var _ = Describe("Auto-Backup", func() {
return map[string]string{
v1beta1.KeyBackupBlueprint: backupBlueprintName,
v1beta1.KeyTargetPaths: framework.TestSourceDataTargetPath,
v1beta1.KeyVolumeMounts: framework.TestSourceDataVolumeMount,
v1beta1.KeyVolumeMounts: framework.TestSourceVolumeAndMount,
}
}

Expand All @@ -66,11 +63,11 @@ var _ = Describe("Auto-Backup", func() {

It("should backup successfully", func() {
// Create BackupBlueprint
bb, err := f.CreateBackupBlueprintForWorkload(fmt.Sprintf("backupblueprint-%s", f.App()))
bb, err := f.CreateBackupBlueprintForWorkload(framework.WorkloadBackupBlueprint)
Expect(err).NotTo(HaveOccurred())

// Deploy a DaemonSet
dmn, err := f.DeployDaemonSet(fmt.Sprintf("dmn-%s", f.App()))
dmn, err := f.DeployDaemonSet(framework.SourceDaemonSet, framework.SourceVolume)
Expect(err).NotTo(HaveOccurred())

// Generate Sample Data
Expand Down Expand Up @@ -113,7 +110,7 @@ var _ = Describe("Auto-Backup", func() {
f.AppendToCleanupList(bb)

// Deploy a DaemonSet
dmn, err := f.DeployDaemonSet(fmt.Sprintf("dmn-%s", f.App()))
dmn, err := f.DeployDaemonSet(framework.SourceDaemonSet, framework.SourceVolume)
Expect(err).NotTo(HaveOccurred())

// Generate Sample Data
Expand Down Expand Up @@ -150,7 +147,7 @@ var _ = Describe("Auto-Backup", func() {
Expect(err).NotTo(HaveOccurred())

// Deploy a DaemonSet
dmn, err := f.DeployDaemonSet(fmt.Sprintf("dmn-%s", f.App()))
dmn, err := f.DeployDaemonSet(framework.SourceDaemonSet, framework.SourceVolume)
Expect(err).NotTo(HaveOccurred())

// Generate Sample Data
Expand Down Expand Up @@ -179,11 +176,11 @@ var _ = Describe("Auto-Backup", func() {
Context("Add inappropriate annotation to Target", func() {
It("should fail to create AutoBackup resources", func() {
// Create BackupBlueprint
_, err := f.CreateBackupBlueprintForWorkload(fmt.Sprintf("backupblueprint-%s", f.App()))
_, err := f.CreateBackupBlueprintForWorkload(framework.WorkloadBackupBlueprint)
Expect(err).NotTo(HaveOccurred())

// Deploy a DaemonSet
dmn, err := f.DeployDaemonSet(fmt.Sprintf("dmn-%s", f.App()))
dmn, err := f.DeployDaemonSet(framework.SourceDaemonSet, framework.SourceVolume)
Expect(err).NotTo(HaveOccurred())

// Generate Sample Data
Expand All @@ -200,11 +197,11 @@ var _ = Describe("Auto-Backup", func() {
})
It("should fail BackupSession for adding inappropriate TargetPath/MountPath", func() {
// Create BackupBlueprint
bb, err := f.CreateBackupBlueprintForWorkload(fmt.Sprintf("backupblueprint-%s", f.App()))
bb, err := f.CreateBackupBlueprintForWorkload(framework.WorkloadBackupBlueprint)
Expect(err).NotTo(HaveOccurred())

// Deploy a DaemonSet
dmn, err := f.DeployDaemonSet(fmt.Sprintf("dmn-%s", f.App()))
dmn, err := f.DeployDaemonSet(framework.SourceDaemonSet, framework.SourceVolume)
Expect(err).NotTo(HaveOccurred())

// Generate Sample Data
Expand Down
23 changes: 10 additions & 13 deletions test/e2e/auto-backup/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ var _ = Describe("Auto-Backup", func() {
})

JustAfterEach(func() {
if CurrentGinkgoTestDescription().Failed {
f.PrintDebugHelpers()
framework.TestFailed = true
}
f.PrintDebugInfoOnFailure()
})

AfterEach(func() {
Expand All @@ -56,7 +53,7 @@ var _ = Describe("Auto-Backup", func() {
return map[string]string{
v1beta1.KeyBackupBlueprint: backupBlueprintName,
v1beta1.KeyTargetPaths: framework.TestSourceDataTargetPath,
v1beta1.KeyVolumeMounts: framework.TestSourceDataVolumeMount,
v1beta1.KeyVolumeMounts: framework.TestSourceVolumeAndMount,
}
}

Expand All @@ -65,11 +62,11 @@ var _ = Describe("Auto-Backup", func() {
Context("Success Case", func() {
It("should backup successfully", func() {
// Create BackupBlueprint
bb, err := f.CreateBackupBlueprintForWorkload(fmt.Sprintf("backupblueprint-%s", f.App()))
bb, err := f.CreateBackupBlueprintForWorkload(framework.WorkloadBackupBlueprint)
Expect(err).NotTo(HaveOccurred())

// Deploy a Deployment
deployment, err := f.DeployDeployment(fmt.Sprintf("deployment1-%s", f.App()), int32(1))
deployment, err := f.DeployDeployment(framework.SourceDaemonSet, int32(1), framework.SourceVolume)
Expect(err).NotTo(HaveOccurred())

// Generate Sample Data
Expand Down Expand Up @@ -112,7 +109,7 @@ var _ = Describe("Auto-Backup", func() {
f.AppendToCleanupList(bb)

// Deploy a Deployment
deployment, err := f.DeployDeployment(fmt.Sprintf("deployment2-%s", f.App()), int32(1))
deployment, err := f.DeployDeployment(framework.SourceDeployment, int32(1), framework.SourceVolume)
Expect(err).NotTo(HaveOccurred())

// Generate Sample Data
Expand Down Expand Up @@ -149,7 +146,7 @@ var _ = Describe("Auto-Backup", func() {
Expect(err).NotTo(HaveOccurred())

// Deploy a Deployment
deployment, err := f.DeployDeployment(fmt.Sprintf("deployment3-%s", f.App()), int32(1))
deployment, err := f.DeployDeployment(framework.SourceDeployment, int32(1), framework.SourceVolume)
Expect(err).NotTo(HaveOccurred())

// Generate Sample Data
Expand Down Expand Up @@ -178,11 +175,11 @@ var _ = Describe("Auto-Backup", func() {
Context("Add inappropriate annotation to Target", func() {
It("should fail to create AutoBackup resources", func() {
// Create BackupBlueprint
_, err := f.CreateBackupBlueprintForWorkload(fmt.Sprintf("backupblueprint-%s", f.App()))
_, err := f.CreateBackupBlueprintForWorkload(framework.WorkloadBackupBlueprint)
Expect(err).NotTo(HaveOccurred())

// Deploy a Deployment
deployment, err := f.DeployDeployment(fmt.Sprintf("deployment4-%s", f.App()), int32(1))
deployment, err := f.DeployDeployment(framework.SourceDeployment, int32(1), framework.SourceVolume)
Expect(err).NotTo(HaveOccurred())

// Generate Sample Data
Expand All @@ -198,11 +195,11 @@ var _ = Describe("Auto-Backup", func() {
})
It("should fail BackupSession for adding inappropriate TargetPath/MountPath", func() {
// Create BackupBlueprint
bb, err := f.CreateBackupBlueprintForWorkload(fmt.Sprintf("backupblueprint-%s", f.App()))
bb, err := f.CreateBackupBlueprintForWorkload(framework.WorkloadBackupBlueprint)
Expect(err).NotTo(HaveOccurred())

// Deploy a Deployment
deployment, err := f.DeployDeployment(fmt.Sprintf("deployment5-%s", f.App()), int32(1))
deployment, err := f.DeployDeployment(framework.SourceDeployment, int32(1), framework.SourceVolume)
Expect(err).NotTo(HaveOccurred())

// Generate Sample Data
Expand Down
17 changes: 7 additions & 10 deletions test/e2e/auto-backup/pvc.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ var _ = Describe("Auto-Backup", func() {
})

JustAfterEach(func() {
if CurrentGinkgoTestDescription().Failed {
f.PrintDebugHelpers()
framework.TestFailed = true
}
f.PrintDebugInfoOnFailure()
})

AfterEach(func() {
Expand All @@ -64,11 +61,11 @@ var _ = Describe("Auto-Backup", func() {

It("should backup successfully", func() {
// Create BackupBlueprint
bb, err := f.CreateBackupBlueprintForPVC(fmt.Sprintf("backupblueprint-%s", f.App()))
bb, err := f.CreateBackupBlueprintForPVC(framework.PvcBackupBlueprint)
Expect(err).NotTo(HaveOccurred())

// Create a PVC
pvc, err := f.CreateNewPVC(fmt.Sprintf("pvc1-%s", f.App()))
pvc, err := f.CreateNewPVC(framework.SourceVolume)
Expect(err).NotTo(HaveOccurred())

// Deploy a Pod
Expand Down Expand Up @@ -115,7 +112,7 @@ var _ = Describe("Auto-Backup", func() {
f.AppendToCleanupList(bb)

// Create a PVC
pvc, err := f.CreateNewPVC(fmt.Sprintf("pvc2-%s", f.App()))
pvc, err := f.CreateNewPVC(framework.SourceVolume)
Expect(err).NotTo(HaveOccurred())

// Deploy a Pod
Expand Down Expand Up @@ -156,7 +153,7 @@ var _ = Describe("Auto-Backup", func() {
Expect(err).NotTo(HaveOccurred())

// Create a PVC
pvc, err := f.CreateNewPVC(fmt.Sprintf("pvc3-%s", f.App()))
pvc, err := f.CreateNewPVC(framework.SourceVolume)
Expect(err).NotTo(HaveOccurred())

// Deploy a Pod
Expand Down Expand Up @@ -189,11 +186,11 @@ var _ = Describe("Auto-Backup", func() {
Context("Add inappropriate annotation to Target", func() {
It("should fail to create AutoBackup resources", func() {
// Create BackupBlueprint
bb, err := f.CreateBackupBlueprintForPVC(fmt.Sprintf("backupblueprint-%s", f.App()))
bb, err := f.CreateBackupBlueprintForPVC(framework.PvcBackupBlueprint)
Expect(err).NotTo(HaveOccurred())

// Create a PVC
pvc, err := f.CreateNewPVC(fmt.Sprintf("pvc4-%s", f.App()))
pvc, err := f.CreateNewPVC(framework.SourceVolume)
Expect(err).NotTo(HaveOccurred())

// Deploy a Pod
Expand Down
25 changes: 10 additions & 15 deletions test/e2e/auto-backup/replicaset.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ var _ = Describe("Auto-Backup", func() {
})

JustAfterEach(func() {
if CurrentGinkgoTestDescription().Failed {
f.PrintDebugHelpers()
framework.TestFailed = true
}
f.PrintDebugInfoOnFailure()
})

AfterEach(func() {
Expand All @@ -56,7 +53,7 @@ var _ = Describe("Auto-Backup", func() {
return map[string]string{
v1beta1.KeyBackupBlueprint: backupBlueprintName,
v1beta1.KeyTargetPaths: framework.TestSourceDataTargetPath,
v1beta1.KeyVolumeMounts: framework.TestSourceDataVolumeMount,
v1beta1.KeyVolumeMounts: framework.TestSourceVolumeAndMount,
}
}

Expand All @@ -66,11 +63,11 @@ var _ = Describe("Auto-Backup", func() {

It("should success auto-backup for the ReplicaSet", func() {
// Create BackupBlueprint
bb, err := f.CreateBackupBlueprintForWorkload(fmt.Sprintf("backupblueprint-%s", f.App()))
bb, err := f.CreateBackupBlueprintForWorkload(framework.WorkloadBackupBlueprint)
Expect(err).NotTo(HaveOccurred())

// Deploy a ReplicaSet
rs, err := f.DeployReplicaSet(fmt.Sprintf("rs1-%s", f.App()), int32(1))
rs, err := f.DeployReplicaSet(framework.SourceReplicaSet, int32(1), framework.SourceVolume)
Expect(err).NotTo(HaveOccurred())

// Generate Sample Data
Expand Down Expand Up @@ -113,7 +110,7 @@ var _ = Describe("Auto-Backup", func() {
f.AppendToCleanupList(bb)

// Deploy a ReplicaSet
rs, err := f.DeployReplicaSet(fmt.Sprintf("rs2-%s", f.App()), int32(1))
rs, err := f.DeployReplicaSet(framework.SourceReplicaSet, int32(1), framework.SourceVolume)
Expect(err).NotTo(HaveOccurred())

// Generate Sample Data
Expand Down Expand Up @@ -150,7 +147,7 @@ var _ = Describe("Auto-Backup", func() {
Expect(err).NotTo(HaveOccurred())

// Deploy a ReplicaSet
rs, err := f.DeployReplicaSet(fmt.Sprintf("rs3-%s", f.App()), int32(1))
rs, err := f.DeployReplicaSet(framework.SourceReplicaSet, int32(1), framework.SourceVolume)
Expect(err).NotTo(HaveOccurred())

// Generate Sample Data
Expand Down Expand Up @@ -179,11 +176,11 @@ var _ = Describe("Auto-Backup", func() {
Context("Add inappropriate annotation to Target", func() {
It("should fail to create AutoBackup resources", func() {
// Create BackupBlueprint
_, err := f.CreateBackupBlueprintForWorkload(fmt.Sprintf("backupblueprint-%s", f.App()))
_, err := f.CreateBackupBlueprintForWorkload(framework.WorkloadBackupBlueprint)
Expect(err).NotTo(HaveOccurred())

// Deploy a ReplicaSet
rs, err := f.DeployReplicaSet(fmt.Sprintf("rs4-%s", f.App()), int32(1))
rs, err := f.DeployReplicaSet(framework.SourceReplicaSet, int32(1), framework.SourceVolume)
Expect(err).NotTo(HaveOccurred())

// Generate Sample Data
Expand All @@ -199,11 +196,11 @@ var _ = Describe("Auto-Backup", func() {
})
It("should fail BackupSession for adding inappropriate TargetPath/MountPath", func() {
// Create BackupBlueprint
bb, err := f.CreateBackupBlueprintForWorkload(fmt.Sprintf("backupblueprint-%s", f.App()))
bb, err := f.CreateBackupBlueprintForWorkload(framework.WorkloadBackupBlueprint)
Expect(err).NotTo(HaveOccurred())

// Deploy a ReplicaSet
rs, err := f.DeployReplicaSet(fmt.Sprintf("rs5-%s", f.App()), int32(1))
rs, err := f.DeployReplicaSet(framework.SourceReplicaSet, int32(1), framework.SourceVolume)
Expect(err).NotTo(HaveOccurred())

// Generate Sample Data
Expand All @@ -229,9 +226,7 @@ var _ = Describe("Auto-Backup", func() {
Expect(err).NotTo(HaveOccurred())
Expect(completedBS.Status.Phase).Should(Equal(v1beta1.BackupSessionFailed))
})

})
})
})

})
Loading