Skip to content

Commit

Permalink
Remove unused DescribeBackups function and related code (#2401)
Browse files Browse the repository at this point in the history
* Remove unused DescribeBackups function

* Remove related tests

* Remove related docs

* Use a different constant
  • Loading branch information
pavannd1 committed Oct 15, 2023
1 parent d4e4b79 commit 2167aef
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 352 deletions.
51 changes: 0 additions & 51 deletions docs/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -889,57 +889,6 @@ Example:
mode: restore-size
backupID: "{{ .ArtifactsIn.snapshot.KeyValue.backupIdentifier }}"
DescribeBackups
---------------

This function describes the backups for an object store location

.. note::
It is important that the application includes a ``kanister-tools``
sidecar container. This sidecar is necessary to run the
tools that get the information from the object store.

Arguments:

.. csv-table::
:header: "Argument", "Required", "Type", "Description"
:align: left
:widths: 5,5,5,15

`backupArtifactPrefix`, Yes, `string`, path to the object store location
`encryptionKey`, No, `string`, encryption key to be used for backups

Outputs:

.. csv-table::
:header: "Output", "Type", "Description"
:align: left
:widths: 5,5,15

`fileCount`,`string`, number of files in backup object store location
`size`, `string`, size of the number of files in in backup object store location
`passwordIncorrect`, `string`, true if encryption key is incorrect
`repoDoesNotExist`, `string`, true if object store location does not exist

Example:

.. code-block:: yaml
:linenos:
actions:
backupStats:
outputArtifacts:
backupStats:
keyValue:
fileCount: "{{ .Phases.DescribeBackupsFromObjectStore.Output.fileCount }}"
size: "{{ .Phases.DescribeBackupsFromObjectStore.Output.size }}"
passwordIncorrect: "{{ .Phases.DescribeBackupsFromObjectStore.Output.passwordIncorrect }}"
repoDoesNotExist: "{{ .Phases.DescribeBackupsFromObjectStore.Output.repoDoesNotExist }}"
phases:
- func: DescribeBackups
name: DescribeBackupsFromObjectStore
args:
backupArtifactPrefix: s3-bucket/path/artifactPrefix
CreateRDSSnapshot
-----------------
Expand Down
2 changes: 1 addition & 1 deletion pkg/function/backup_data_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (b *BackupDataStatsFunc) Exec(ctx context.Context, tp param.TemplateParams,
if err = OptArg(args, BackupDataStatsEncryptionKeyArg, &encryptionKey, restic.GeneratePassword()); err != nil {
return nil, err
}
podOverride, err := GetPodSpecOverride(tp, args, DescribeBackupsPodOverrideArg)
podOverride, err := GetPodSpecOverride(tp, args, CheckRepositoryPodOverrideArg)
if err != nil {
return nil, err
}
Expand Down
77 changes: 0 additions & 77 deletions pkg/function/data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,26 +175,6 @@ func newBackupDataBlueprint() *crv1alpha1.Blueprint {
}
}

func newDescribeBackupsBlueprint() *crv1alpha1.Blueprint {
return &crv1alpha1.Blueprint{
Actions: map[string]*crv1alpha1.BlueprintAction{
"describeBackups": {
Kind: param.StatefulSetKind,
Phases: []crv1alpha1.BlueprintPhase{
{
Name: "testDescribeBackups",
Func: DescribeBackupsFuncName,
Args: map[string]interface{}{
DescribeBackupsArtifactPrefixArg: "{{ .Profile.Location.Prefix }}",
DescribeBackupsEncryptionKeyArg: "{{ .Secrets.backupKey.Data.password | toString }}",
},
},
},
},
},
}
}

func newCheckRepositoryBlueprint() *crv1alpha1.Blueprint {
return &crv1alpha1.Blueprint{
Actions: map[string]*crv1alpha1.BlueprintAction{
Expand Down Expand Up @@ -590,63 +570,6 @@ func (s *DataSuite) initPVCTemplateParams(c *C, pvc *v1.PersistentVolumeClaim, o
tp.Profile = s.profile
return tp
}
func (s *DataSuite) TestDescribeBackups(c *C) {
tp, _ := s.getTemplateParamsAndPVCName(c, 1)

// Test backup
bp := *newBackupDataBlueprint()
out := runAction(c, bp, "backup", tp)
c.Assert(out[BackupDataOutputBackupID].(string), Not(Equals), "")
c.Assert(out[BackupDataOutputBackupTag].(string), Not(Equals), "")
c.Assert(out[FunctionOutputVersion].(string), Equals, kanister.DefaultVersion)

// Test DescribeBackups
bp2 := *newDescribeBackupsBlueprint()
out2 := runAction(c, bp2, "describeBackups", tp)
c.Assert(out2[DescribeBackupsFileCount].(string), Not(Equals), "")
c.Assert(out2[DescribeBackupsSize].(string), Not(Equals), "")
c.Assert(out2[DescribeBackupsPasswordIncorrect].(string), Not(Equals), "")
c.Assert(out2[DescribeBackupsRepoDoesNotExist].(string), Not(Equals), "")
c.Assert(out2[FunctionOutputVersion].(string), Equals, kanister.DefaultVersion)
}

func (s *DataSuite) TestDescribeBackupsWrongPassword(c *C) {
tp, _ := s.getTemplateParamsAndPVCName(c, 1)

// Test backup
bp := *newBackupDataBlueprint()
bp.Actions["backup"].Phases[0].Args[BackupDataBackupArtifactPrefixArg] = fmt.Sprintf("%s/%s", bp.Actions["backup"].Phases[0].Args[BackupDataBackupArtifactPrefixArg], "abcde")
bp.Actions["backup"].Phases[0].Args[BackupDataEncryptionKeyArg] = "foobar"
out := runAction(c, bp, "backup", tp)
c.Assert(out[BackupDataOutputBackupID].(string), Not(Equals), "")
c.Assert(out[BackupDataOutputBackupTag].(string), Not(Equals), "")
c.Assert(out[FunctionOutputVersion].(string), Equals, kanister.DefaultVersion)

// Test DescribeBackups
bp2 := *newDescribeBackupsBlueprint()
bp2.Actions["describeBackups"].Phases[0].Args[DescribeBackupsArtifactPrefixArg] = fmt.Sprintf("%s/%s", bp2.Actions["describeBackups"].Phases[0].Args[DescribeBackupsArtifactPrefixArg], "abcde")
out2 := runAction(c, bp2, "describeBackups", tp)
c.Assert(out2[DescribeBackupsPasswordIncorrect].(string), Equals, "true")
c.Assert(out2[FunctionOutputVersion].(string), Equals, kanister.DefaultVersion)
}

func (s *DataSuite) TestDescribeBackupsRepoNotAvailable(c *C) {
tp, _ := s.getTemplateParamsAndPVCName(c, 1)

// Test backup
bp := *newBackupDataBlueprint()
out := runAction(c, bp, "backup", tp)
c.Assert(out[BackupDataOutputBackupID].(string), Not(Equals), "")
c.Assert(out[BackupDataOutputBackupTag].(string), Not(Equals), "")
c.Assert(out[FunctionOutputVersion].(string), Equals, kanister.DefaultVersion)

// Test DescribeBackups
bp2 := *newDescribeBackupsBlueprint()
bp2.Actions["describeBackups"].Phases[0].Args[DescribeBackupsArtifactPrefixArg] = fmt.Sprintf("%s/%s", bp2.Actions["describeBackups"].Phases[0].Args[DescribeBackupsArtifactPrefixArg], c.TestName())
out2 := runAction(c, bp2, "describeBackups", tp)
c.Assert(out2[DescribeBackupsRepoDoesNotExist].(string), Equals, "true")
c.Assert(out2[FunctionOutputVersion].(string), Equals, kanister.DefaultVersion)
}

func (s *DataSuite) TestCheckRepository(c *C) {
tp, _ := s.getTemplateParamsAndPVCName(c, 1)
Expand Down
223 changes: 0 additions & 223 deletions pkg/function/describe_backups.go

This file was deleted.

0 comments on commit 2167aef

Please sign in to comment.