From 02ecd0d5a7cbda04164ccd18d1b7733808418018 Mon Sep 17 00:00:00 2001 From: Aaron Alpar <55999015+aaron-kasten@users.noreply.github.com> Date: Mon, 26 Sep 2022 18:28:56 -0700 Subject: [PATCH] feat(repository): Allow clock drift to be specified on upgrade. (#2357) * add max-clock-drift flag * fixups * module dependencies * package fixup --- cli/command_repository_set_parameters_test.go | 5 +-- cli/command_repository_upgrade.go | 23 +++++------- cli/command_repository_upgrade_test.go | 29 ++++++++------- go.mod | 6 ++++ go.sum | 35 +++++++++++++++++++ repo/format/upgrade_lock_intent_test.go | 14 ++++---- tests/compat_test/compat_test.go | 7 ++-- 7 files changed, 76 insertions(+), 43 deletions(-) diff --git a/cli/command_repository_set_parameters_test.go b/cli/command_repository_set_parameters_test.go index 4427d846d..37fb4b3b9 100644 --- a/cli/command_repository_set_parameters_test.go +++ b/cli/command_repository_set_parameters_test.go @@ -3,11 +3,9 @@ import ( "fmt" "testing" - "time" "github.com/stretchr/testify/require" - "github.com/kopia/kopia/cli" "github.com/kopia/kopia/internal/blobtesting" "github.com/kopia/kopia/internal/repotesting" "github.com/kopia/kopia/internal/testutil" @@ -149,10 +147,9 @@ func (s *formatSpecificTestSuite) TestRepositorySetParametersUpgrade(t *testing. "--upgrade-owner-id", "owner", "--io-drain-timeout", "1s", "--allow-unsafe-upgrade", "--status-poll-interval", "1s", + "--max-permitted-clock-drift", "1s", } - cli.MaxPermittedClockDrift = func() time.Duration { return time.Second } - // You can only upgrade when you are not already upgraded if s.formatVersion < format.MaxFormatVersion { env.RunAndExpectSuccess(t, cmd...) diff --git a/cli/command_repository_upgrade.go b/cli/command_repository_upgrade.go index 98217d838..1e9235f8d 100644 --- a/cli/command_repository_upgrade.go +++ b/cli/command_repository_upgrade.go @@ -22,8 +22,9 @@ type commandRepositoryUpgrade struct { lockOnly bool // lock settings - ioDrainTimeout time.Duration - statusPollInterval time.Duration + ioDrainTimeout time.Duration + statusPollInterval time.Duration + maxPermittedClockDrift time.Duration svc advancedAppServices } @@ -33,17 +34,10 @@ type commandRepositoryUpgrade struct { You will need to set the env variable KOPIA_UPGRADE_LOCK_ENABLED in order to use this feature. ` - upgradeLockFeatureEnv = "KOPIA_UPGRADE_LOCK_ENABLED" - maxPermittedClockDrift time.Duration = 5 * time.Minute + upgradeLockFeatureEnv = "KOPIA_UPGRADE_LOCK_ENABLED" + maxPermittedClockDriftDefault = 5 * time.Minute ) -// MaxPermittedClockDrift is overridable interface for tests to define their -// own constants so that they do not have to wait for the default clock-drift to -// settle. -// -//nolint:gochecknoglobals -var MaxPermittedClockDrift = func() time.Duration { return maxPermittedClockDrift } - func (c *commandRepositoryUpgrade) setup(svc advancedAppServices, parent commandParent) { // override the parent, the upgrade sub-command becomes the new parent here-onwards parent = parent.Command("upgrade", fmt.Sprintf("Upgrade repository format.\n\n%s", warningColor.Sprint(experimentalWarning))).Hidden(). @@ -58,6 +52,7 @@ func (c *commandRepositoryUpgrade) setup(svc advancedAppServices, parent command beginCmd.Flag("io-drain-timeout", "Max time it should take all other Kopia clients to drop repository connections").Default(format.DefaultRepositoryBlobCacheDuration.String()).DurationVar(&c.ioDrainTimeout) beginCmd.Flag("allow-unsafe-upgrade", "Force using an unsafe io-drain-timeout for the upgrade lock").Default("false").Hidden().BoolVar(&c.force) beginCmd.Flag("status-poll-interval", "An advisory polling interval to check for the status of upgrade").Default("60s").DurationVar(&c.statusPollInterval) + beginCmd.Flag("max-permitted-clock-drift", "The maximum drift between repository and client clocks").Default(maxPermittedClockDriftDefault.String()).DurationVar(&c.maxPermittedClockDrift) beginCmd.Flag("lock-only", "Advertise the upgrade lock and exit without actually performing the drain or upgrade").Default("false").Hidden().BoolVar(&c.lockOnly) // this is used by tests // upgrade phases @@ -135,7 +130,7 @@ func (c *commandRepositoryUpgrade) setLockIntent(ctx context.Context, rep repo.D IODrainTimeout: c.ioDrainTimeout, StatusPollInterval: c.statusPollInterval, Message: fmt.Sprintf("Upgrading from format version %d -> %d", mp.Version, format.MaxFormatVersion), - MaxPermittedClockDrift: MaxPermittedClockDrift(), + MaxPermittedClockDrift: c.maxPermittedClockDrift, } // Update format-blob and clear the cache. @@ -250,7 +245,7 @@ func (c *commandRepositoryUpgrade) drainAllClients(ctx context.Context, rep repo return nil } -// upgrade phase perfoms the actual upgrade action that upgrades the target +// upgrade phase performs the actual upgrade action that upgrades the target // repository. This phase runs after the lock has been acquired in one of the // prior phases. func (c *commandRepositoryUpgrade) upgrade(ctx context.Context, rep repo.DirectRepositoryWriter) error { @@ -301,7 +296,7 @@ func (c *commandRepositoryUpgrade) upgrade(ctx context.Context, rep repo.DirectR } // commitUpgrade is the upgrade CLI phase that commits the upgrade and removes -// the lock after the actual upgrade phase has been ru nsuccessfully. We will +// the lock after the actual upgrade phase has been run successfully. We will // not end up here if any of the prior phases have failed. This will also // cleanup and backups used for the rollback mechanism, so we cannot rollback // after this phase. diff --git a/cli/command_repository_upgrade_test.go b/cli/command_repository_upgrade_test.go index b42600de5..20ccda715 100644 --- a/cli/command_repository_upgrade_test.go +++ b/cli/command_repository_upgrade_test.go @@ -6,7 +6,6 @@ "github.com/stretchr/testify/require" - "github.com/kopia/kopia/cli" "github.com/kopia/kopia/repo/format" "github.com/kopia/kopia/tests/testenv" ) @@ -19,15 +18,14 @@ func (s *formatSpecificTestSuite) TestRepositoryUpgrade(t *testing.T) { env.Environment["KOPIA_UPGRADE_LOCK_ENABLED"] = "1" - cli.MaxPermittedClockDrift = func() time.Duration { return time.Second } - switch s.formatVersion { case format.FormatVersion1: require.Contains(t, out, "Format version: 1") _, stderr := env.RunAndExpectSuccessWithErrOut(t, "repository", "upgrade", "--upgrade-owner-id", "owner", "--io-drain-timeout", "1s", "--allow-unsafe-upgrade", - "--status-poll-interval", "1s") + "--status-poll-interval", "1s", + "--max-permitted-clock-drift", "1s") require.Contains(t, stderr, "Repository indices have been upgraded.") require.Contains(t, stderr, "Repository has been successfully upgraded.") case format.FormatVersion2: @@ -35,7 +33,8 @@ func (s *formatSpecificTestSuite) TestRepositoryUpgrade(t *testing.T) { _, stderr := env.RunAndExpectSuccessWithErrOut(t, "repository", "upgrade", "--upgrade-owner-id", "owner", "--io-drain-timeout", "1s", "--allow-unsafe-upgrade", - "--status-poll-interval", "1s") + "--status-poll-interval", "1s", + "--max-permitted-clock-drift", "1s") require.Contains(t, stderr, "Repository indices have already been migrated to the epoch format, no need to drain other clients") require.Contains(t, stderr, "Repository has been successfully upgraded.") default: @@ -43,7 +42,8 @@ func (s *formatSpecificTestSuite) TestRepositoryUpgrade(t *testing.T) { env.RunAndExpectFailure(t, "repository", "upgrade", "--upgrade-owner-id", "owner", "--io-drain-timeout", "1s", "--allow-unsafe-upgrade", - "--status-poll-interval", "1s") + "--status-poll-interval", "1s", + "--max-permitted-clock-drift", "1s") } out = env.RunAndExpectSuccess(t, "repository", "status", "--upgrade-no-block") @@ -59,7 +59,8 @@ func lockRepositoryForUpgrade(t *testing.T, env *testenv.CLITest) { env.RunAndExpectSuccess(t, "repository", "upgrade", "--upgrade-owner-id", "owner", "--io-drain-timeout", "30s", "--allow-unsafe-upgrade", - "--status-poll-interval", "1s", "--lock-only") + "--status-poll-interval", "1s", "--lock-only", + "--max-permitted-clock-drift", "1s") } func (s *formatSpecificTestSuite) TestRepositoryUpgradeStatusWhileLocked(t *testing.T) { @@ -70,8 +71,6 @@ func (s *formatSpecificTestSuite) TestRepositoryUpgradeStatusWhileLocked(t *test env.Environment["KOPIA_UPGRADE_LOCK_ENABLED"] = "1" - cli.MaxPermittedClockDrift = func() time.Duration { return time.Second } - switch s.formatVersion { case format.FormatVersion1: require.Contains(t, out, "Format version: 1") @@ -81,7 +80,8 @@ func (s *formatSpecificTestSuite) TestRepositoryUpgradeStatusWhileLocked(t *test env.RunAndExpectFailure(t, "repository", "upgrade", "--upgrade-owner-id", "non-owner", "--io-drain-timeout", "15s", "--allow-unsafe-upgrade", - "--status-poll-interval", "1s", "--upgrade-no-block") + "--status-poll-interval", "1s", "--upgrade-no-block", + "--max-permitted-clock-drift", "1s") // until we drain, we would be able to see the upgrade status as // "Draining" @@ -112,7 +112,8 @@ func (s *formatSpecificTestSuite) TestRepositoryUpgradeStatusWhileLocked(t *test _, stderr := env.RunAndExpectSuccessWithErrOut(t, "repository", "upgrade", "--upgrade-owner-id", "owner", "--io-drain-timeout", "15s", "--allow-unsafe-upgrade", - "--status-poll-interval", "1s") + "--status-poll-interval", "1s", + "--max-permitted-clock-drift", "1s") require.Contains(t, stderr, "Repository has been successfully upgraded.") // verify that non-owner clients can resume access @@ -124,7 +125,8 @@ func (s *formatSpecificTestSuite) TestRepositoryUpgradeStatusWhileLocked(t *test _, stderr := env.RunAndExpectSuccessWithErrOut(t, "repository", "upgrade", "--upgrade-owner-id", "owner", "--io-drain-timeout", "1s", "--allow-unsafe-upgrade", - "--status-poll-interval", "1s") + "--status-poll-interval", "1s", + "--max-permitted-clock-drift", "1s") require.Contains(t, stderr, "Repository has been successfully upgraded.") // verify that non-owner clients can resume access @@ -134,7 +136,8 @@ func (s *formatSpecificTestSuite) TestRepositoryUpgradeStatusWhileLocked(t *test env.RunAndExpectFailure(t, "repository", "upgrade", "--upgrade-owner-id", "owner", "--io-drain-timeout", "1s", "--allow-unsafe-upgrade", - "--status-poll-interval", "1s") + "--status-poll-interval", "1s", + "--max-permitted-clock-drift", "1s") } out = env.RunAndExpectSuccess(t, "repository", "status", "--upgrade-no-block") diff --git a/go.mod b/go.mod index 2787b13d7..619595319 100644 --- a/go.mod +++ b/go.mod @@ -117,6 +117,7 @@ require ( require ( cloud.google.com/go/compute v1.7.0 // indirect cloud.google.com/go/iam v0.3.0 // indirect + code.cloudfoundry.org/bytefmt v0.0.0-20211005130812-5bb3c17173e5 // indirect github.com/alessio/shellescape v1.4.1 // indirect github.com/chromedp/sysutil v1.0.0 // indirect github.com/go-logr/logr v1.2.3 // indirect @@ -125,7 +126,12 @@ require ( github.com/gobwas/pool v0.2.1 // indirect github.com/gobwas/ws v1.1.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.1.0 // indirect + github.com/gosuri/uilive v0.0.4 // indirect + github.com/gosuri/uiprogress v0.0.1 // indirect + github.com/jessevdk/go-flags v1.5.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/mailru/easyjson v0.7.7 // indirect + github.com/pierrec/cmdflag v0.0.2 // indirect + github.com/schollz/progressbar v1.0.0 // indirect github.com/xhit/go-str2duration v1.2.0 // indirect ) diff --git a/go.sum b/go.sum index 9d336adfc..6e1f8a49a 100644 --- a/go.sum +++ b/go.sum @@ -115,6 +115,8 @@ cloud.google.com/go/vision v1.2.0/go.mod h1:SmNwgObm5DpFBme2xpyOyasvBc1aPdjvMk2b cloud.google.com/go/vision/v2 v2.2.0/go.mod h1:uCdV4PpN1S0jyCyq8sIM42v2Y6zOLkZs+4R9LrGYwFo= cloud.google.com/go/webrisk v1.4.0/go.mod h1:Hn8X6Zr+ziE2aNd8SliSDWpEnSS1u4R9+xXZmFiHmGE= cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1Vwf+KmJENM0= +code.cloudfoundry.org/bytefmt v0.0.0-20211005130812-5bb3c17173e5 h1:tM5+dn2C9xZw1RzgI6WTQW1rGqdUimKB3RFbyu4h6Hc= +code.cloudfoundry.org/bytefmt v0.0.0-20211005130812-5bb3c17173e5/go.mod h1:v4VVB6oBMz/c9fRY6vZrwr5xKRWOH5NPDjQZlPk0Gbs= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/Azure/azure-pipeline-go v0.2.3 h1:7U9HBg1JFK3jHl5qmo4CTZKFTVgMwdFHMVtCdfBE21U= github.com/Azure/azure-pipeline-go v0.2.3/go.mod h1:x841ezTBIMG6O3lAcl8ATHnsOPVl2bqk7S3ta6S6u4k= @@ -226,6 +228,8 @@ github.com/foomo/htpasswd v0.0.0-20200116085101-e3a90e78da9c/go.mod h1:SHawtolbB github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/frankban/quicktest v1.13.1 h1:xVm/f9seEhZFL9+n5kv5XLrGwy6elc4V9v/XFY2vmd8= github.com/frankban/quicktest v1.13.1/go.mod h1:NeW+ay9A/U67EYXNFA1nPE8e/tnQv/09mUdL/ijj8og= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -244,6 +248,7 @@ github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbV github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU= github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM= github.com/gobwas/pool v0.2.1 h1:xfeeEhW7pwmX8nuLVlqbzVc7udMDrwetjEv+TZIz1og= @@ -358,6 +363,10 @@ github.com/googleapis/gax-go/v2 v2.5.1/go.mod h1:h6B0KMMFNtI2ddbGJn3T3ZbwkeT6yqE github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+cLsWGBF62rFAi7WjWO4= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= +github.com/gosuri/uilive v0.0.4 h1:hUEBpQDj8D8jXgtCdBu7sWsy5sbW/5GhuO8KBwJ2jyY= +github.com/gosuri/uilive v0.0.4/go.mod h1:V/epo5LjjlDE5RJUcqx8dbw+zc93y5Ya3yg8tfZ74VI= +github.com/gosuri/uiprogress v0.0.1 h1:0kpv/XY/qTmFWl/SkaJykZXrBBzwwadmW8fRb7RJSxw= +github.com/gosuri/uiprogress v0.0.1/go.mod h1:C1RTYn4Sc7iEyf6j8ft5dyoZ4212h8G1ol9QQluh5+0= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/hanwen/go-fuse/v2 v2.1.1-0.20220112183258-f57e95bda82d h1:ibbzF2InxMOS+lLCphY9PHNKPURDUBNKaG6ErSq8gJQ= github.com/hanwen/go-fuse/v2 v2.1.1-0.20220112183258-f57e95bda82d/go.mod h1:B1nGE/6RBFyBRC1RRnf23UpwCdyJ31eukw34oAKukAc= @@ -365,8 +374,11 @@ github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/jessevdk/go-flags v1.5.0 h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LFvc= +github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= @@ -448,8 +460,18 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/natefinch/atomic v1.0.1 h1:ZPYKxkqQOx3KZ+RsbnP/YsgvxWQPGxjC0oBt2AhwV0A= github.com/natefinch/atomic v1.0.1/go.mod h1:N/D/ELrljoqDyT3rZrsUmtsuzvHkeB/wWjHV22AZRbM= +github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= +github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= +github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= +github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +github.com/onsi/gomega v1.16.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde h1:x0TT0RDC7UhAVbbWWBzr41ElhJx5tXPWkIHA2HWPRuw= github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0= +github.com/pierrec/cmdflag v0.0.2 h1:ybjGJnPr/aURn2IKWjO49znx9N0DL6YfGsIxN0PYuVY= +github.com/pierrec/cmdflag v0.0.2/go.mod h1:a3zKGZ3cdQUfxjd0RGMLZr8xI3nvpJOB+m6o/1X5BmU= github.com/pierrec/lz4 v2.6.1+incompatible h1:9UY3+iC23yxF0UfGaYrGplQ+79Rg+h/q9FV9ix19jjM= github.com/pierrec/lz4 v2.6.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -498,6 +520,8 @@ github.com/rs/xid v1.4.0 h1:qd7wPTDkN6KQx2VmMBLrpHkiyQwgFXRnkOLacUiaSNY= github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/sanity-io/litter v1.5.5 h1:iE+sBxPBzoK6uaEP5Lt3fHNgpKcHXc/A2HGETy0uJQo= github.com/sanity-io/litter v1.5.5/go.mod h1:9gzJgR2i4ZpjZHsKvUXIRQVk7P+yM3e+jAF7bU2UI5U= +github.com/schollz/progressbar v1.0.0 h1:gbyFReLHDkZo8mxy/dLWMr+Mpb1MokGJ1FqCiqacjZM= +github.com/schollz/progressbar v1.0.0/go.mod h1:/l9I7PC3L3erOuz54ghIRKUEFcosiWfLvJv+Eq26UMs= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= @@ -618,6 +642,7 @@ golang.org/x/mod v0.5.1 h1:OJxoQ/rynoF0dcCdI7cLPktw/hR2cueqYfjm43oqK38= golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -641,6 +666,7 @@ golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= @@ -654,6 +680,7 @@ golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= @@ -709,6 +736,7 @@ golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f h1:Ax0t5p6N38Ga0dThY21weqDE golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -719,8 +747,11 @@ golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191112214154-59a1497f0cea/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -746,6 +777,7 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201207223542-d4d67f95c62d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -848,6 +880,7 @@ golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82u golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= @@ -1072,10 +1105,12 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/ini.v1 v1.66.6 h1:LATuAqN/shcYAOkv3wl2L4rkaKqkcgTBQjOyYDvcPKI= gopkg.in/ini.v1 v1.66.6/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/kothar/go-backblaze.v0 v0.0.0-20210124194846-35409b867216 h1:2TSTkQ8PMvGOD5eeqqRVv6Z9+BYI+bowK97RCr3W+9M= gopkg.in/kothar/go-backblaze.v0 v0.0.0-20210124194846-35409b867216/go.mod h1:zJ2QpyDCYo1KvLXlmdnFlQAyF/Qfth0fB8239Qg7BIE= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/repo/format/upgrade_lock_intent_test.go b/repo/format/upgrade_lock_intent_test.go index ad6cbcc78..a5ffcc09f 100644 --- a/repo/format/upgrade_lock_intent_test.go +++ b/repo/format/upgrade_lock_intent_test.go @@ -192,26 +192,26 @@ func TestUpgradeLockIntentSufficientAdvanceLock(t *testing.T) { MaxPermittedClockDrift: 5 * time.Second, } - // Verify that the lock intent has been placed but is not locked at all + // Verify that the lock intent has been placed but is not locked at all, // at the time of taking the lock with advance notice locked, writersDrained := l.IsLocked(now) require.False(t, locked) require.False(t, writersDrained) - // Verify that the lock intent has been placed but is not locked at all + // Verify that the lock intent has been placed but is not locked at all, // even at the next drain timeout mark locked, writersDrained = l.IsLocked(now.Add(l.IODrainTimeout)) require.False(t, locked) require.False(t, writersDrained) - // Verify that the lock intent has been placed but is not locked at all - // even at the twice the drain timeout mark + // Verify that the lock intent has been placed but is not locked at all, + // even at twice drain timeout mark locked, writersDrained = l.IsLocked(now.Add(2 * l.IODrainTimeout)) require.False(t, locked) require.False(t, writersDrained) - // Verify that the lock intent has been placed but is not locked at all - // even at the twice the drain timeout mark + clock drift + // Verify that the lock intent has been placed but is not locked at all, + // even at twice the drain timeout mark + clock drift locked, writersDrained = l.IsLocked(now.Add(l.MaxPermittedClockDrift + 2*l.IODrainTimeout)) require.False(t, locked) require.False(t, writersDrained) @@ -260,7 +260,7 @@ func TestUpgradeLockIntentInSufficientAdvanceLock(t *testing.T) { } // Verify that the lock intent has been placed and is held right at the - // creation time because there si insufficient time to drain fro mthe + // creation time because there is insufficient time to drain from the // advance notice. locked, writersDrained := l.IsLocked(now) require.True(t, locked) diff --git a/tests/compat_test/compat_test.go b/tests/compat_test/compat_test.go index 6d355cb68..389d94579 100644 --- a/tests/compat_test/compat_test.go +++ b/tests/compat_test/compat_test.go @@ -3,9 +3,7 @@ import ( "os" "testing" - "time" - "github.com/kopia/kopia/cli" "github.com/kopia/kopia/tests/testenv" ) @@ -36,13 +34,12 @@ func TestRepoCreatedWith08CanBeOpenedWithCurrent(t *testing.T) { e2.Environment["KOPIA_UPGRADE_LOCK_ENABLED"] = "1" - cli.MaxPermittedClockDrift = func() time.Duration { return time.Second } - // upgrade e2.RunAndExpectSuccess(t, "repository", "upgrade", "--upgrade-owner-id", "owner", "--io-drain-timeout", "1s", "--allow-unsafe-upgrade", - "--status-poll-interval", "1s") + "--status-poll-interval", "1s", + "--max-permitted-clock-drift", "1s") // now 0.8 client can't open it anymore because they won't understand format V2 e3 := testenv.NewCLITest(t, testenv.RepoFormatNotImportant, runner08)