Skip to content

Commit

Permalink
Disabling validation for volumesnapshotlocation if the backup has sna…
Browse files Browse the repository at this point in the history
…pshotvolume set to false

Signed-off-by: mayank <mayank.patel@mayadata.io>
  • Loading branch information
mayank committed Apr 22, 2020
1 parent 9db74ba commit 949eb3f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/controller/backup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,11 @@ func (c *backupController) prepareBackupRequest(backup *velerov1api.Backup) *pkg
}
}

// if snapshotVolume is set to false then we don't need to validate volumesnapshotlocation
if request.Spec.SnapshotVolumes != nil && !*request.Spec.SnapshotVolumes {
return request
}

// validate and get the backup's VolumeSnapshotLocations, and store the
// VolumeSnapshotLocation API objs on the request
if locs, errs := c.validateAndGetSnapshotLocations(request.Backup); len(errs) > 0 {
Expand Down
11 changes: 11 additions & 0 deletions pkg/controller/backup_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,17 @@ func TestValidateAndGetSnapshotLocations(t *testing.T) {
expectedErrors: "more than one VolumeSnapshotLocation name specified for provider aws: aws-us-west-1; unexpected name was aws-us-east-1",
expectedSuccess: false,
},
{
name: "multiple non-dupe location names per provider with snapshot pv set to false should not error",
backup: defaultBackup().Phase(velerov1api.BackupPhaseNew).VolumeSnapshotLocations("aws-us-east-1", "aws-us-west-1").SnapshotVolumes(false).Result(),
locations: []*velerov1api.VolumeSnapshotLocation{
builder.ForVolumeSnapshotLocation(velerov1api.DefaultNamespace, "aws-us-east-1").Provider("aws").Result(),
builder.ForVolumeSnapshotLocation(velerov1api.DefaultNamespace, "aws-us-west-1").Provider("aws").Result(),
builder.ForVolumeSnapshotLocation(velerov1api.DefaultNamespace, "some-name").Provider("fake-provider").Result(),
},
expectedErrors: "more than one VolumeSnapshotLocation name specified for provider aws: aws-us-west-1; unexpected name was aws-us-east-1",
expectedSuccess: false,
},
{
name: "no location name for the provider exists, only one VSL for the provider: use it",
backup: defaultBackup().Phase(velerov1api.BackupPhaseNew).Result(),
Expand Down

0 comments on commit 949eb3f

Please sign in to comment.