Invert incremental flags, default to incremental (#2051)

## Description

Sets the default run behavior for exchange to use
incremental backups.  The cli feature flag for enabling exchange incrementals has been swapped for a toggle that disables incrementals, forcing a full backup

## Does this PR need a docs update or release note?

- [x]  Yes, it's included

## Type of change

- [x] 🌻 Feature

## Issue(s)

* #1901

## Test Plan

- [x]  Unit test
- [x] 💚 E2E
This commit is contained in:
Keepers 2023-01-08 13:22:56 -07:00 committed by GitHub
parent 186569087c
commit 059b860fde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 42 additions and 38 deletions

View File

@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] (alpha) ## [Unreleased] (alpha)
### Added
- Incremental backup support for exchange is now enabled by default.
### Changed ### Changed
- The selectors Reduce() process will only include details that match the DiscreteOwner, if one is specified. - The selectors Reduce() process will only include details that match the DiscreteOwner, if one is specified.

View File

@ -105,7 +105,7 @@ func addExchangeCommands(cmd *cobra.Command) *cobra.Command {
switch cmd.Use { switch cmd.Use {
case createCommand: case createCommand:
c, fs = utils.AddCommand(cmd, exchangeCreateCmd()) c, fs = utils.AddCommand(cmd, exchangeCreateCmd())
options.AddFeatureFlags(cmd, options.ExchangeIncrementals()) options.AddFeatureToggle(cmd, options.DisableIncrementals())
c.Use = c.Use + " " + exchangeServiceCommandCreateUseSuffix c.Use = c.Use + " " + exchangeServiceCommandCreateUseSuffix
c.Example = exchangeServiceCommandCreateExamples c.Example = exchangeServiceCommandCreateExamples

View File

@ -19,8 +19,8 @@ func Control() control.Options {
opt.DisableMetrics = true opt.DisableMetrics = true
} }
if exchangeIncrementals { if disableIncrementals {
opt.EnabledFeatures.ExchangeIncrementals = true opt.ToggleFeatures.DisableIncrementals = true
} }
return opt return opt
@ -53,28 +53,28 @@ func AddGlobalOperationFlags(cmd *cobra.Command) {
// Feature Flags // Feature Flags
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
var exchangeIncrementals bool var disableIncrementals bool
type exposeFeatureFlag func(*pflag.FlagSet) type exposeFeatureFlag func(*pflag.FlagSet)
// AddFeatureFlags adds CLI flags for each exposed feature flags to the // AddFeatureToggle adds CLI flags for each exposed feature toggle to the
// persistent flag set within the command. // persistent flag set within the command.
func AddFeatureFlags(cmd *cobra.Command, effs ...exposeFeatureFlag) { func AddFeatureToggle(cmd *cobra.Command, effs ...exposeFeatureFlag) {
fs := cmd.PersistentFlags() fs := cmd.PersistentFlags()
for _, fflag := range effs { for _, fflag := range effs {
fflag(fs) fflag(fs)
} }
} }
// Adds the '--exchange-incrementals' cli flag which, when set, enables // Adds the hidden '--no-incrementals' cli flag which, when set, disables
// incrementals data retrieval for exchange backups. // incremental backups.
func ExchangeIncrementals() func(*pflag.FlagSet) { func DisableIncrementals() func(*pflag.FlagSet) {
return func(fs *pflag.FlagSet) { return func(fs *pflag.FlagSet) {
fs.BoolVar( fs.BoolVar(
&exchangeIncrementals, &disableIncrementals,
"exchange-incrementals", "disable-incrementals",
false, false,
"Enable incremental data retrieval in Exchange backups.") "Disable incremental data retrieval in backups.")
cobra.CheckErr(fs.MarkHidden("exchange-incrementals")) cobra.CheckErr(fs.MarkHidden("disable-incrementals"))
} }
} }

View File

@ -644,11 +644,7 @@ func (suite *ServiceIteratorsSuite) TestFilterContainersAndFillCollections_incre
test.resolver, test.resolver,
allScope, allScope,
test.dps, test.dps,
control.Options{ control.Options{},
EnabledFeatures: control.FeatureFlags{
ExchangeIncrementals: true,
},
},
) )
assert.NoError(t, err) assert.NoError(t, err)

View File

@ -212,7 +212,7 @@ func (op *BackupOperation) Run(ctx context.Context) (err error) {
// checker to see if conditions are correct for incremental backup behavior such as // checker to see if conditions are correct for incremental backup behavior such as
// retrieving metadata like delta tokens and previous paths. // retrieving metadata like delta tokens and previous paths.
func useIncrementalBackup(sel selectors.Selector, opts control.Options) bool { func useIncrementalBackup(sel selectors.Selector, opts control.Options) bool {
return opts.EnabledFeatures.ExchangeIncrementals && sel.Service == selectors.ServiceExchange return !opts.ToggleFeatures.DisableIncrementals
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

View File

@ -52,7 +52,7 @@ func prepNewTestBackupOp(
ctx context.Context, ctx context.Context,
bus events.Eventer, bus events.Eventer,
sel selectors.Selector, sel selectors.Selector,
featureFlags control.FeatureFlags, featureToggles control.Toggles,
) (BackupOperation, account.Account, *kopia.Wrapper, *kopia.ModelStore, func()) { ) (BackupOperation, account.Account, *kopia.Wrapper, *kopia.ModelStore, func()) {
//revive:enable:context-as-argument //revive:enable:context-as-argument
acct := tester.NewM365Account(t) acct := tester.NewM365Account(t)
@ -90,7 +90,7 @@ func prepNewTestBackupOp(
ms.Close(ctx) ms.Close(ctx)
} }
bo := newTestBackupOp(t, ctx, kw, ms, acct, sel, bus, featureFlags, closer) bo := newTestBackupOp(t, ctx, kw, ms, acct, sel, bus, featureToggles, closer)
return bo, acct, kw, ms, closer return bo, acct, kw, ms, closer
} }
@ -109,7 +109,7 @@ func newTestBackupOp(
acct account.Account, acct account.Account,
sel selectors.Selector, sel selectors.Selector,
bus events.Eventer, bus events.Eventer,
featureFlags control.FeatureFlags, featureToggles control.Toggles,
closer func(), closer func(),
) BackupOperation { ) BackupOperation {
//revive:enable:context-as-argument //revive:enable:context-as-argument
@ -118,7 +118,7 @@ func newTestBackupOp(
opts = control.Options{} opts = control.Options{}
) )
opts.EnabledFeatures = featureFlags opts.ToggleFeatures = featureToggles
bo, err := NewBackupOperation(ctx, opts, kw, sw, acct, sel, bus) bo, err := NewBackupOperation(ctx, opts, kw, sw, acct, sel, bus)
if !assert.NoError(t, err) { if !assert.NoError(t, err) {
@ -554,7 +554,7 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run_exchange() {
var ( var (
mb = evmock.NewBus() mb = evmock.NewBus()
sel = test.selector().Selector sel = test.selector().Selector
ffs = control.FeatureFlags{ExchangeIncrementals: test.runIncremental} ffs = control.Toggles{}
) )
bo, acct, kw, ms, closer := prepNewTestBackupOp(t, ctx, mb, sel, ffs) bo, acct, kw, ms, closer := prepNewTestBackupOp(t, ctx, mb, sel, ffs)
@ -630,7 +630,7 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run_exchangeIncrementals() {
var ( var (
t = suite.T() t = suite.T()
acct = tester.NewM365Account(t) acct = tester.NewM365Account(t)
ffs = control.FeatureFlags{ExchangeIncrementals: true} ffs = control.Toggles{}
mb = evmock.NewBus() mb = evmock.NewBus()
now = common.Now() now = common.Now()
users = []string{suite.user} users = []string{suite.user}
@ -1010,7 +1010,7 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run_oneDrive() {
sel.Include(sel.AllData()) sel.Include(sel.AllData())
bo, _, _, _, closer := prepNewTestBackupOp(t, ctx, mb, sel.Selector, control.FeatureFlags{}) bo, _, _, _, closer := prepNewTestBackupOp(t, ctx, mb, sel.Selector, control.Toggles{})
defer closer() defer closer()
runAndCheckBackup(t, ctx, &bo, mb) runAndCheckBackup(t, ctx, &bo, mb)
@ -1032,7 +1032,7 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run_sharePoint() {
sel.Include(sel.AllData()) sel.Include(sel.AllData())
bo, _, _, _, closer := prepNewTestBackupOp(t, ctx, mb, sel.Selector, control.FeatureFlags{}) bo, _, _, _, closer := prepNewTestBackupOp(t, ctx, mb, sel.Selector, control.Toggles{})
defer closer() defer closer()
runAndCheckBackup(t, ctx, &bo, mb) runAndCheckBackup(t, ctx, &bo, mb)

View File

@ -6,17 +6,17 @@ import (
// Options holds the optional configurations for a process // Options holds the optional configurations for a process
type Options struct { type Options struct {
Collision CollisionPolicy `json:"-"` Collision CollisionPolicy `json:"-"`
DisableMetrics bool `json:"disableMetrics"` DisableMetrics bool `json:"disableMetrics"`
FailFast bool `json:"failFast"` FailFast bool `json:"failFast"`
EnabledFeatures FeatureFlags `json:"enabledFeatures"` ToggleFeatures Toggles `json:"ToggleFeatures"`
} }
// Defaults provides an Options with the default values set. // Defaults provides an Options with the default values set.
func Defaults() Options { func Defaults() Options {
return Options{ return Options{
FailFast: true, FailFast: true,
EnabledFeatures: FeatureFlags{}, ToggleFeatures: Toggles{},
} }
} }
@ -63,11 +63,15 @@ func DefaultRestoreDestination(timeFormat common.TimeFormat) RestoreDestination
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Feature Flags // Feature Flags and Toggles
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
type FeatureFlags struct { // Toggles allows callers to force corso to behave in ways that deviate from
// ExchangeIncrementals allow for re-use of delta links when backing up // the default expectations by turning on or shutting off certain features.
// exchange data, reducing the amount of data pulled from graph. // The default state for every toggle is false; toggles are only turned on
ExchangeIncrementals bool `json:"incrementals,omitempty"` // if specified by the caller.
type Toggles struct {
// DisableIncrementals prevents backups from using incremental lookups,
// forcing a new, complete backup of all data regardless of prior state.
DisableIncrementals bool `json:"exchangeIncrementals,omitempty"`
} }