From 88de8ba8bb00ec805c715027e581b50f3f43b265 Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Sat, 25 Aug 2018 22:23:47 +0200 Subject: [PATCH] initial repl policy: get rid of unimplemented options --- cmd/config_job_local.go | 5 ----- cmd/config_job_pull.go | 7 ------ cmd/config_parse.go | 27 +----------------------- cmd/sampleconf/localbackup/host1.yml | 1 - cmd/sampleconf/pullbackup/backuphost.yml | 1 - docs/configuration/jobs.rst | 8 ++----- docs/tutorial.rst | 1 - replication/mainfsm.go | 3 +-- replication/policy.go | 11 ---------- 9 files changed, 4 insertions(+), 60 deletions(-) delete mode 100644 replication/policy.go diff --git a/cmd/config_job_local.go b/cmd/config_job_local.go index fce3708..7fa88ae 100644 --- a/cmd/config_job_local.go +++ b/cmd/config_job_local.go @@ -17,7 +17,6 @@ type LocalJob struct { Mapping *DatasetMapFilter SnapshotPrefix string Interval time.Duration - InitialReplPolicy replication.InitialReplPolicy PruneLHS PrunePolicy PruneRHS PrunePolicy Debug JobDebugSettings @@ -60,10 +59,6 @@ func parseLocalJob(c JobParsingContext, name string, i map[string]interface{}) ( return } - if j.InitialReplPolicy, err = parseInitialReplPolicy(asMap.InitialReplPolicy, replication.DEFAULT_INITIAL_REPL_POLICY); err != nil { - return - } - if j.PruneLHS, err = parsePrunePolicy(asMap.PruneLHS, true); err != nil { err = errors.Wrap(err, "cannot parse 'prune_lhs'") return diff --git a/cmd/config_job_pull.go b/cmd/config_job_pull.go index 871166c..e4aba5c 100644 --- a/cmd/config_job_pull.go +++ b/cmd/config_job_pull.go @@ -23,7 +23,6 @@ type PullJob struct { // constructed from mapping during parsing pruneFilter *DatasetMapFilter SnapshotPrefix string - InitialReplPolicy replication.InitialReplPolicy Prune PrunePolicy Debug JobDebugSettings @@ -72,12 +71,6 @@ func parsePullJob(c JobParsingContext, name string, i map[string]interface{}) (j return nil, err } - j.InitialReplPolicy, err = parseInitialReplPolicy(asMap.InitialReplPolicy, replication.DEFAULT_INITIAL_REPL_POLICY) - if err != nil { - err = errors.Wrap(err, "cannot parse 'initial_repl_policy'") - return - } - if j.SnapshotPrefix, err = parseSnapshotPrefix(asMap.SnapshotPrefix); err != nil { return } diff --git a/cmd/config_parse.go b/cmd/config_parse.go index 573436a..3a5b1eb 100644 --- a/cmd/config_parse.go +++ b/cmd/config_parse.go @@ -4,11 +4,10 @@ import ( "io/ioutil" "fmt" - yaml "github.com/go-yaml/yaml" + "github.com/go-yaml/yaml" "github.com/mitchellh/mapstructure" "github.com/pkg/errors" "github.com/problame/go-streamrpc" - "github.com/zrepl/zrepl/replication" "os" "regexp" "strconv" @@ -228,30 +227,6 @@ func parseConnect(i map[string]interface{}) (c streamrpc.Connecter, err error) { } -func parseInitialReplPolicy(v interface{}, defaultPolicy replication.InitialReplPolicy) (p replication.InitialReplPolicy, err error) { - s, ok := v.(string) - if !ok { - goto err - } - - switch { - case s == "": - p = defaultPolicy - case s == "most_recent": - p = replication.InitialReplPolicyMostRecent - case s == "all": - p = replication.InitialReplPolicyAll - default: - goto err - } - - return - -err: - err = errors.New(fmt.Sprintf("expected InitialReplPolicy, got %#v", v)) - return -} - func parsePrunePolicy(v map[string]interface{}, willSeeBookmarks bool) (p PrunePolicy, err error) { policyName, err := extractStringField(v, "policy", true) diff --git a/cmd/sampleconf/localbackup/host1.yml b/cmd/sampleconf/localbackup/host1.yml index e48cf02..5ef4f65 100644 --- a/cmd/sampleconf/localbackup/host1.yml +++ b/cmd/sampleconf/localbackup/host1.yml @@ -12,7 +12,6 @@ jobs: } snapshot_prefix: zrepl_ interval: 10m - initial_repl_policy: most_recent # keep one hour of 10m interval snapshots of filesystems matched by # the left-hand-side of the mapping diff --git a/cmd/sampleconf/pullbackup/backuphost.yml b/cmd/sampleconf/pullbackup/backuphost.yml index f6871d0..206e947 100644 --- a/cmd/sampleconf/pullbackup/backuphost.yml +++ b/cmd/sampleconf/pullbackup/backuphost.yml @@ -17,7 +17,6 @@ jobs: mapping: { "<":"storage/backups/zrepl/pull/prod1.example.com" } - initial_repl_policy: most_recent # follow a grandfathering scheme for filesystems on the right-hand-side of the mapping snapshot_prefix: zrepl_ diff --git a/docs/configuration/jobs.rst b/docs/configuration/jobs.rst index b921e79..1854bd5 100644 --- a/docs/configuration/jobs.rst +++ b/docs/configuration/jobs.rst @@ -88,8 +88,6 @@ Example: :sampleconf:`pullbackup/backuphost.yml` - Interval between pull attempts * - ``mapping`` - |mapping| for remote to local filesystems - * - ``initial_repl_policy`` - - default = ``most_recent``, initial replication policy * - ``snapshot_prefix`` - prefix snapshots must match to be considered for replication & pruning * - ``prune`` @@ -103,7 +101,7 @@ Example: :sampleconf:`pullbackup/backuphost.yml` #. Only snapshots with prefix ``snapshot_prefix`` are replicated. #. If possible, incremental replication takes place. - #. If the local target filesystem does not exist, ``initial_repl_policy`` is used. + #. If the local target filesystem does not exist, the most recent snapshot is sent fully (non-incremental). #. On conflicts, an error is logged but replication of other filesystems with mapping continues. #. The ``prune`` policy is evaluated for all *target filesystems* @@ -135,8 +133,6 @@ Example: :sampleconf:`localbackup/host1.yml` - prefix for ZFS snapshots taken by this job * - ``interval`` - snapshotting & replication interval - * - ``initial_repl_policy`` - - default = ``most_recent``, initial replication policy * - ``prune_lhs`` - pruning policy on left-hand-side (source) * - ``prune_rhs`` @@ -151,7 +147,7 @@ Example: :sampleconf:`localbackup/host1.yml` #. Only snapshots with prefix ``snapshot_prefix`` are replicated. #. If possible, incremental replication takes place. - #. If the *target filesystem* does not exist, ``initial_repl_policy`` is used. + #. If the *target filesystem* does not exist, the most recent snapshot is sent fully (non-incremental). #. On conflicts, an error is logged but replication of other *mapped filesystems* continues. #. The ``prune_lhs`` policy is triggered for all *mapped filesystems* diff --git a/docs/tutorial.rst b/docs/tutorial.rst index 40192d8..fa769ed 100644 --- a/docs/tutorial.rst +++ b/docs/tutorial.rst @@ -75,7 +75,6 @@ We define a **pull job** named ``pull_app-srv`` in the |mainconfig| on host ``ba mapping: { "<":"storage/zrepl/pull/app-srv" } - initial_repl_policy: most_recent snapshot_prefix: zrepl_pull_backup_ prune: policy: grid diff --git a/replication/mainfsm.go b/replication/mainfsm.go index f9a0dcb..68fefc4 100644 --- a/replication/mainfsm.go +++ b/replication/mainfsm.go @@ -151,8 +151,7 @@ func (r *Replication) Drive(ctx context.Context, sender Sender, receiver Receive func resolveConflict(conflict error) (path []*pdu.FilesystemVersion, msg string) { if noCommonAncestor, ok := conflict.(*ConflictNoCommonAncestor); ok { if len(noCommonAncestor.SortedReceiverVersions) == 0 { - // FIXME hard-coded replication policy: most recent - // snapshot as source + // TODO this is hard-coded replication policy: most recent snapshot as source var mostRecentSnap *pdu.FilesystemVersion for n := len(noCommonAncestor.SortedSenderVersions) - 1; n >= 0; n-- { if noCommonAncestor.SortedSenderVersions[n].Type == pdu.FilesystemVersion_Snapshot { diff --git a/replication/policy.go b/replication/policy.go deleted file mode 100644 index 83398af..0000000 --- a/replication/policy.go +++ /dev/null @@ -1,11 +0,0 @@ -package replication - -// FIXME: Leftovers from previous versions, not used currently -type InitialReplPolicy string - -const ( - InitialReplPolicyMostRecent InitialReplPolicy = "most_recent" - InitialReplPolicyAll InitialReplPolicy = "all" -) - -const DEFAULT_INITIAL_REPL_POLICY = InitialReplPolicyMostRecent