Merge pull request #374 from sanketjpatel/feat/exclude-events-restore
Add events to nonRestorableResources and cohabitatingResourcespull/378/head
commit
51c546786e
|
@ -34,7 +34,7 @@ Namespaces:
|
|||
|
||||
Resources:
|
||||
Included: serviceaccounts
|
||||
Excluded: nodes
|
||||
Excluded: nodes, events, events.events.k8s.io
|
||||
Cluster-scoped: auto
|
||||
|
||||
Namespace mappings: <none>
|
||||
|
|
|
@ -233,6 +233,7 @@ func (kb *kubernetesBackupper) Backup(backup *api.Backup, backupFile, logFile io
|
|||
cohabitatingResources := map[string]*cohabitatingResource{
|
||||
"deployments": newCohabitatingResource("deployments", "extensions", "apps"),
|
||||
"networkpolicies": newCohabitatingResource("networkpolicies", "extensions", "networking.k8s.io"),
|
||||
"events": newCohabitatingResource("events", "", "events.k8s.io"),
|
||||
}
|
||||
|
||||
resolvedActions, err := resolveActions(actions, kb.discoveryHelper)
|
||||
|
|
|
@ -527,6 +527,7 @@ func TestBackup(t *testing.T) {
|
|||
cohabitatingResources := map[string]*cohabitatingResource{
|
||||
"deployments": newCohabitatingResource("deployments", "extensions", "apps"),
|
||||
"networkpolicies": newCohabitatingResource("networkpolicies", "extensions", "networking.k8s.io"),
|
||||
"events": newCohabitatingResource("events", "", "events.k8s.io"),
|
||||
}
|
||||
|
||||
groupBackupperFactory.On("newGroupBackupper",
|
||||
|
|
|
@ -51,7 +51,7 @@ import (
|
|||
|
||||
// nonRestorableResources is a blacklist for the restoration process. Any resources
|
||||
// included here are explicitly excluded from the restoration process.
|
||||
var nonRestorableResources = []string{"nodes"}
|
||||
var nonRestorableResources = []string{"nodes", "events", "events.events.k8s.io"}
|
||||
|
||||
type restoreController struct {
|
||||
namespace string
|
||||
|
@ -304,7 +304,7 @@ func (controller *restoreController) getValidationErrors(itm *api.Restore) []str
|
|||
includedResources := sets.NewString(itm.Spec.IncludedResources...)
|
||||
for _, nonRestorableResource := range nonRestorableResources {
|
||||
if includedResources.Has(nonRestorableResource) {
|
||||
validationErrors = append(validationErrors, fmt.Sprintf("%v are a non-restorable resource", nonRestorableResource))
|
||||
validationErrors = append(validationErrors, fmt.Sprintf("%v are non-restorable resources", nonRestorableResource))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -229,10 +229,32 @@ func TestProcessRestore(t *testing.T) {
|
|||
expectedErr: false,
|
||||
expectedPhase: string(api.RestorePhaseFailedValidation),
|
||||
expectedValidationErrors: []string{
|
||||
"nodes are a non-restorable resource",
|
||||
"nodes are non-restorable resources",
|
||||
"Invalid included/excluded resource lists: excludes list cannot contain an item in the includes list: nodes",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "restoration of events is not supported",
|
||||
restore: NewRestore("foo", "bar", "backup-1", "ns-1", "events", api.RestorePhaseNew).Restore,
|
||||
backup: arktest.NewTestBackup().WithName("backup-1").Backup,
|
||||
expectedErr: false,
|
||||
expectedPhase: string(api.RestorePhaseFailedValidation),
|
||||
expectedValidationErrors: []string{
|
||||
"events are non-restorable resources",
|
||||
"Invalid included/excluded resource lists: excludes list cannot contain an item in the includes list: events",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "restoration of events.events.k8s.io is not supported",
|
||||
restore: NewRestore("foo", "bar", "backup-1", "ns-1", "events.events.k8s.io", api.RestorePhaseNew).Restore,
|
||||
backup: arktest.NewTestBackup().WithName("backup-1").Backup,
|
||||
expectedErr: false,
|
||||
expectedPhase: string(api.RestorePhaseFailedValidation),
|
||||
expectedValidationErrors: []string{
|
||||
"events.events.k8s.io are non-restorable resources",
|
||||
"Invalid included/excluded resource lists: excludes list cannot contain an item in the includes list: events.events.k8s.io",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
|
Loading…
Reference in New Issue