Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
emosbaugh committed Dec 4, 2024
1 parent ee38c7d commit 7462fb2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 3 additions & 7 deletions pkg/kotsadmsnapshot/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ func getInstanceBackupSpec(ctx context.Context, k8sClient kubernetes.Interface,
},
Spec: velerov1.BackupSpec{
StorageLocation: "default",
IncludedNamespaces: []string{},
IncludedNamespaces: []string{metadata.kotsadmNamespace},
ExcludedNamespaces: []string{},
IncludeClusterResources: ptr.To(true),
OrLabelSelectors: instanceBackupLabelSelectors(metadata.ec != nil),
Expand All @@ -449,12 +449,8 @@ func getInstanceBackupSpec(ctx context.Context, k8sClient kubernetes.Interface,
},
}

appNamespace := metadata.kotsadmNamespace
if os.Getenv("KOTSADM_TARGET_NAMESPACE") != "" {
appNamespace = os.Getenv("KOTSADM_TARGET_NAMESPACE")
}
if appNamespace != metadata.kotsadmNamespace {
veleroBackup.Spec.IncludedNamespaces = append(veleroBackup.Spec.IncludedNamespaces, appNamespace)
if util.AppNamespace() != metadata.kotsadmNamespace {
veleroBackup.Spec.IncludedNamespaces = append(veleroBackup.Spec.IncludedNamespaces, util.AppNamespace())
}

isKurl, err := kurl.IsKurl(k8sClient)
Expand Down
6 changes: 5 additions & 1 deletion pkg/kotsadmsnapshot/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2087,7 +2087,10 @@ func Test_getInstanceBackupSpec(t *testing.T) {
{
name: "KOTSADM_TARGET_NAMESPACE should be added to includedNamespaces",
setup: func(t *testing.T, mockStore *mock_store.MockStore) {
t.Setenv("KOTSADM_TARGET_NAMESPACE", "kotsadm-target")
util.KotsadmTargetNamespace = "kotsadm-target"
t.Cleanup(func() {
util.KotsadmTargetNamespace = ""
})

mockStoreExpectApp1(mockStore)
},
Expand All @@ -2112,6 +2115,7 @@ func Test_getInstanceBackupSpec(t *testing.T) {
},
assert: func(t *testing.T, got *velerov1.Backup, err error) {
require.NoError(t, err)
assert.Contains(t, got.Spec.IncludedNamespaces, "kotsadm")
assert.Contains(t, got.Spec.IncludedNamespaces, "kotsadm-target")
},
},
Expand Down

0 comments on commit 7462fb2

Please sign in to comment.