2019-09-29 18:44:59 +02:00
|
|
|
.PHONY: generate build test vet cover release docs docs-clean clean format lint platformtest
|
2019-10-28 16:16:16 +01:00
|
|
|
.PHONY: release bins-all release-noarch
|
|
|
|
.DEFAULT_GOAL := zrepl-bin
|
2017-09-30 16:40:39 +02:00
|
|
|
|
|
|
|
ARTIFACTDIR := artifacts
|
|
|
|
|
2018-10-19 17:46:30 +02:00
|
|
|
ifdef ZREPL_VERSION
|
|
|
|
_ZREPL_VERSION := $(ZREPL_VERSION)
|
|
|
|
endif
|
|
|
|
ifndef _ZREPL_VERSION
|
2019-01-05 21:53:59 +01:00
|
|
|
_ZREPL_VERSION := $(shell git describe --always --dirty 2>/dev/null || echo "ZREPL_BUILD_INVALID_VERSION" )
|
2018-10-19 17:46:30 +02:00
|
|
|
ifeq ($(_ZREPL_VERSION),ZREPL_BUILD_INVALID_VERSION) # can't use .SHELLSTATUS because Debian Stretch is still on gmake 4.1
|
2017-11-18 20:34:28 +01:00
|
|
|
$(error cannot infer variable ZREPL_VERSION using git and variable is not overriden by make invocation)
|
|
|
|
endif
|
|
|
|
endif
|
2019-10-28 16:16:16 +01:00
|
|
|
|
2019-09-03 14:45:18 +02:00
|
|
|
GO := go
|
2019-10-28 16:16:16 +01:00
|
|
|
GOOS ?= $(shell bash -c 'source <($(GO) env) && echo "$$GOOS"')
|
|
|
|
GOARCH ?= $(shell bash -c 'source <($(GO) env) && echo "$$GOARCH"')
|
2020-02-09 12:45:30 +01:00
|
|
|
GOARM ?= $(shell bash -c 'source <($(GO) env) && echo "$$GOARM"')
|
2019-10-28 16:16:16 +01:00
|
|
|
GOHOSTOS ?= $(shell bash -c 'source <($(GO) env) && echo "$$GOHOSTOS"')
|
|
|
|
GOHOSTARCH ?= $(shell bash -c 'source <($(GO) env) && echo "$$GOHOSTARCH"')
|
2019-10-26 14:53:01 +02:00
|
|
|
GO_ENV_VARS := GO111MODULE=on
|
2018-10-19 17:46:30 +02:00
|
|
|
GO_LDFLAGS := "-X github.com/zrepl/zrepl/version.zreplVersion=$(_ZREPL_VERSION)"
|
2019-09-03 14:45:18 +02:00
|
|
|
GO_MOD_READONLY := -mod=readonly
|
2020-04-07 23:33:42 +02:00
|
|
|
GO_EXTRA_BUILDFLAGS :=
|
|
|
|
GO_BUILDFLAGS := $(GO_MOD_READONLY) $(GO_EXTRA_BUILDFLAGS)
|
2019-10-28 16:16:16 +01:00
|
|
|
GO_BUILD := $(GO_ENV_VARS) $(GO) build $(GO_BUILDFLAGS) -ldflags $(GO_LDFLAGS)
|
|
|
|
GOLANGCI_LINT := golangci-lint
|
2020-05-24 17:43:42 +02:00
|
|
|
GOCOVMERGE := gocovmerge
|
2021-02-20 17:27:33 +01:00
|
|
|
RELEASE_DOCKER_BASEIMAGE_TAG ?= 1.16
|
2020-09-06 15:39:34 +02:00
|
|
|
RELEASE_DOCKER_BASEIMAGE ?= golang:$(RELEASE_DOCKER_BASEIMAGE_TAG)
|
2020-05-24 17:43:42 +02:00
|
|
|
|
2020-02-09 12:45:30 +01:00
|
|
|
ifneq ($(GOARM),)
|
|
|
|
ZREPL_TARGET_TUPLE := $(GOOS)-$(GOARCH)v$(GOARM)
|
|
|
|
else
|
|
|
|
ZREPL_TARGET_TUPLE := $(GOOS)-$(GOARCH)
|
|
|
|
endif
|
2019-10-28 16:16:16 +01:00
|
|
|
|
|
|
|
.PHONY: printvars
|
|
|
|
printvars:
|
|
|
|
@echo GOOS=$(GOOS)
|
|
|
|
@echo GOARCH=$(GOARCH)
|
2020-02-09 12:45:30 +01:00
|
|
|
@echo GOARM=$(GOARM)
|
2019-10-28 16:16:16 +01:00
|
|
|
|
|
|
|
|
|
|
|
##################### PRODUCING A RELEASE #############
|
|
|
|
.PHONY: release wrapup-and-checksum check-git-clean sign clean
|
|
|
|
|
|
|
|
release: clean
|
|
|
|
# no cross-platform support for target test
|
2020-05-24 17:43:42 +02:00
|
|
|
$(MAKE) test-go
|
2019-10-28 16:16:16 +01:00
|
|
|
$(MAKE) bins-all
|
|
|
|
$(MAKE) noarch
|
|
|
|
$(MAKE) wrapup-and-checksum
|
|
|
|
$(MAKE) check-git-clean
|
|
|
|
ifeq (SIGN, 1)
|
|
|
|
$(make) sign
|
|
|
|
endif
|
|
|
|
@echo "ZREPL RELEASE ARTIFACTS AVAILABLE IN artifacts/release"
|
2017-11-18 20:34:28 +01:00
|
|
|
|
2020-09-06 15:39:34 +02:00
|
|
|
release-docker: $(ARTIFACTDIR)
|
|
|
|
sed 's/FROM.*!SUBSTITUTED_BY_MAKEFILE/FROM $(RELEASE_DOCKER_BASEIMAGE)/' build.Dockerfile > artifacts/release-docker.Dockerfile
|
|
|
|
docker build -t zrepl_release --pull -f artifacts/release-docker.Dockerfile .
|
2020-09-02 21:34:52 +02:00
|
|
|
docker run --rm -i -v $(CURDIR):/src -u $$(id -u):$$(id -g) \
|
|
|
|
zrepl_release \
|
|
|
|
make release GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM)
|
|
|
|
|
|
|
|
debs-docker:
|
|
|
|
$(MAKE) _debs_or_rpms_docker _DEB_OR_RPM=deb
|
|
|
|
rpms-docker:
|
|
|
|
$(MAKE) _debs_or_rpms_docker _DEB_OR_RPM=rpm
|
|
|
|
_debs_or_rpms_docker: # artifacts/_zrepl.zsh_completion artifacts/bash_completion docs zrepl-bin
|
|
|
|
$(MAKE) $(_DEB_OR_RPM)-docker GOOS=linux GOARCH=amd64
|
|
|
|
$(MAKE) $(_DEB_OR_RPM)-docker GOOS=linux GOARCH=arm64
|
|
|
|
$(MAKE) $(_DEB_OR_RPM)-docker GOOS=linux GOARCH=arm GOARM=7
|
|
|
|
$(MAKE) $(_DEB_OR_RPM)-docker GOOS=linux GOARCH=386
|
|
|
|
|
|
|
|
rpm: $(ARTIFACTDIR) # artifacts/_zrepl.zsh_completion artifacts/bash_completion docs zrepl-bin
|
|
|
|
$(eval _ZREPL_RPM_VERSION := $(subst -,.,$(_ZREPL_VERSION)))
|
|
|
|
$(eval _ZREPL_RPM_TOPDIR_ABS := $(CURDIR)/$(ARTIFACTDIR)/rpmbuild)
|
|
|
|
rm -rf "$(_ZREPL_RPM_TOPDIR_ABS)"
|
|
|
|
mkdir "$(_ZREPL_RPM_TOPDIR_ABS)"
|
|
|
|
mkdir -p "$(_ZREPL_RPM_TOPDIR_ABS)"/{SPECS,RPMS,BUILD,BUILDROOT}
|
|
|
|
sed "s/^Version:.*/Version: $(_ZREPL_RPM_VERSION)/g" \
|
|
|
|
packaging/rpm/zrepl.spec > $(_ZREPL_RPM_TOPDIR_ABS)/SPECS/zrepl.spec
|
|
|
|
|
|
|
|
# see /usr/lib/rpm/platform
|
|
|
|
ifeq ($(GOARCH),amd64)
|
|
|
|
$(eval _ZREPL_RPMBUILD_TARGET := x86_64)
|
|
|
|
else ifeq ($(GOARCH), 386)
|
|
|
|
$(eval _ZREPL_RPMBUILD_TARGET := i386)
|
|
|
|
else ifeq ($(GOARCH), arm64)
|
|
|
|
$(eval _ZREPL_RPMBUILD_TARGET := aarch64)
|
|
|
|
else ifeq ($(GOARCH), arm)
|
|
|
|
$(eval _ZREPL_RPMBUILD_TARGET := armv7hl)
|
|
|
|
else
|
|
|
|
$(eval _ZREPL_RPMBUILD_TARGET := $(GOARCH))
|
|
|
|
endif
|
|
|
|
rpmbuild \
|
|
|
|
--build-in-place \
|
|
|
|
--define "_sourcedir $(CURDIR)" \
|
|
|
|
--define "_topdir $(_ZREPL_RPM_TOPDIR_ABS)" \
|
|
|
|
--define "_zrepl_binary_filename zrepl-$(ZREPL_TARGET_TUPLE)" \
|
|
|
|
--target $(_ZREPL_RPMBUILD_TARGET) \
|
|
|
|
-bb "$(_ZREPL_RPM_TOPDIR_ABS)"/SPECS/zrepl.spec
|
|
|
|
cp "$(_ZREPL_RPM_TOPDIR_ABS)"/RPMS/$(_ZREPL_RPMBUILD_TARGET)/zrepl-$(_ZREPL_RPM_VERSION)*.rpm $(ARTIFACTDIR)/
|
|
|
|
|
|
|
|
rpm-docker:
|
|
|
|
docker build -t zrepl_rpm_pkg --pull -f packaging/rpm/Dockerfile .
|
|
|
|
docker run --rm -i -v $(CURDIR):/build/src -u $$(id -u):$$(id -g) \
|
|
|
|
zrepl_rpm_pkg \
|
|
|
|
make rpm GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM)
|
|
|
|
|
|
|
|
deb: $(ARTIFACTDIR) # artifacts/_zrepl.zsh_completion artifacts/bash_completion docs zrepl-bin
|
|
|
|
|
|
|
|
cp packaging/deb/debian/changelog.template packaging/deb/debian/changelog
|
|
|
|
sed -i 's/DATE_DASH_R_OUTPUT/$(shell date -R)/' packaging/deb/debian/changelog
|
|
|
|
VERSION="$(subst -,.,$(_ZREPL_VERSION))"; \
|
|
|
|
export VERSION="$${VERSION#v}"; \
|
|
|
|
sed -i 's/VERSION/'"$$VERSION"'/' packaging/deb/debian/changelog
|
|
|
|
|
|
|
|
ifeq ($(GOARCH), arm)
|
|
|
|
$(eval DEB_HOST_ARCH := armhf)
|
|
|
|
else ifeq ($(GOARCH), 386)
|
|
|
|
$(eval DEB_HOST_ARCH := i386)
|
|
|
|
else
|
|
|
|
$(eval DEB_HOST_ARCH := $(GOARCH))
|
|
|
|
endif
|
|
|
|
|
|
|
|
export ZREPL_DPKG_ZREPL_BINARY_FILENAME=zrepl-$(ZREPL_TARGET_TUPLE); \
|
|
|
|
dpkg-buildpackage -b --no-sign --host-arch $(DEB_HOST_ARCH)
|
|
|
|
cp ../*.deb artifacts/
|
|
|
|
|
|
|
|
deb-docker:
|
|
|
|
docker build -t zrepl_debian_pkg --pull -f packaging/deb/Dockerfile .
|
|
|
|
docker run --rm -i -v $(CURDIR):/build/src -u $$(id -u):$$(id -g) \
|
|
|
|
zrepl_debian_pkg \
|
|
|
|
make deb GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM)
|
|
|
|
|
2019-10-28 16:16:16 +01:00
|
|
|
# expects `release` target to have run before
|
|
|
|
NOARCH_TARBALL := $(ARTIFACTDIR)/zrepl-noarch.tar
|
|
|
|
wrapup-and-checksum:
|
|
|
|
rm -f $(NOARCH_TARBALL)
|
|
|
|
tar --mtime='1970-01-01' --sort=name \
|
|
|
|
--transform 's/$(ARTIFACTDIR)/zrepl-$(_ZREPL_VERSION)-noarch/' \
|
|
|
|
--transform 's#dist#zrepl-$(_ZREPL_VERSION)-noarch/dist#' \
|
|
|
|
--transform 's#config/samples#zrepl-$(_ZREPL_VERSION)-noarch/config#' \
|
|
|
|
-acf $(NOARCH_TARBALL) \
|
|
|
|
$(ARTIFACTDIR)/docs/html \
|
|
|
|
$(ARTIFACTDIR)/bash_completion \
|
2020-04-18 21:36:48 +02:00
|
|
|
$(ARTIFACTDIR)/_zrepl.zsh_completion \
|
2019-10-28 16:16:16 +01:00
|
|
|
$(ARTIFACTDIR)/go_env.txt \
|
|
|
|
dist \
|
|
|
|
config/samples
|
|
|
|
rm -rf "$(ARTIFACTDIR)/release"
|
|
|
|
mkdir -p "$(ARTIFACTDIR)/release"
|
|
|
|
cp -l $(ARTIFACTDIR)/zrepl-* \
|
|
|
|
$(ARTIFACTDIR)/platformtest-* \
|
|
|
|
"$(ARTIFACTDIR)/release"
|
|
|
|
cd "$(ARTIFACTDIR)/release" && sha512sum $$(ls | sort) > sha512sum.txt
|
2018-10-13 16:57:25 +02:00
|
|
|
|
2019-10-28 16:16:16 +01:00
|
|
|
check-git-clean:
|
|
|
|
@# note that we use ZREPL_VERSION and not _ZREPL_VERSION because we want to detect the override
|
|
|
|
@if git describe --always --dirty 2>/dev/null | grep dirty >/dev/null; then \
|
|
|
|
echo '[INFO] either git reports checkout is dirty or git is not installed or this is not a git checkout'; \
|
|
|
|
if [ "$(ZREPL_VERSION)" = "" ]; then \
|
|
|
|
echo '[WARN] git checkout is dirty and make variable ZREPL_VERSION was not used to override'; \
|
|
|
|
git status; \
|
|
|
|
echo "git diff:"; \
|
|
|
|
git diff | cat; \
|
|
|
|
exit 1; \
|
|
|
|
fi; \
|
|
|
|
fi;
|
2017-11-19 12:32:25 +01:00
|
|
|
|
2019-10-28 16:16:16 +01:00
|
|
|
sign:
|
|
|
|
gpg -u "89BC 5D89 C845 568B F578 B306 CDBD 8EC8 E27C A5FC" \
|
|
|
|
--armor \
|
|
|
|
--detach-sign $(ARTIFACTDIR)/release/sha512sum.txt
|
2017-09-30 16:40:39 +02:00
|
|
|
|
2019-10-28 16:16:16 +01:00
|
|
|
clean: docs-clean
|
|
|
|
rm -rf "$(ARTIFACTDIR)"
|
2019-03-22 20:45:27 +01:00
|
|
|
|
2019-10-28 16:16:16 +01:00
|
|
|
##################### BINARIES #####################
|
2020-05-24 17:43:42 +02:00
|
|
|
.PHONY: bins-all lint test-go test-platform cover-merge cover-html vet zrepl-bin test-platform-bin generate-platform-test-list
|
2019-03-22 19:41:12 +01:00
|
|
|
|
2020-05-24 17:43:42 +02:00
|
|
|
BINS_ALL_TARGETS := zrepl-bin test-platform-bin vet lint
|
2019-10-20 20:05:46 +02:00
|
|
|
GO_SUPPORTS_ILLUMOS := $(shell $(GO) version | gawk -F '.' '/^go version /{split($$0, comps, " "); split(comps[3], v, "."); if (v[1] == "go1" && v[2] >= 13) { print "illumos"; } else { print "noillumos"; }}')
|
2019-10-28 16:16:16 +01:00
|
|
|
bins-all:
|
|
|
|
$(MAKE) $(BINS_ALL_TARGETS) GOOS=freebsd GOARCH=amd64
|
|
|
|
$(MAKE) $(BINS_ALL_TARGETS) GOOS=freebsd GOARCH=386
|
|
|
|
$(MAKE) $(BINS_ALL_TARGETS) GOOS=linux GOARCH=amd64
|
|
|
|
$(MAKE) $(BINS_ALL_TARGETS) GOOS=linux GOARCH=arm64
|
2020-02-09 12:45:30 +01:00
|
|
|
$(MAKE) $(BINS_ALL_TARGETS) GOOS=linux GOARCH=arm GOARM=7
|
2019-10-28 16:16:16 +01:00
|
|
|
$(MAKE) $(BINS_ALL_TARGETS) GOOS=linux GOARCH=386
|
|
|
|
$(MAKE) $(BINS_ALL_TARGETS) GOOS=darwin GOARCH=amd64
|
2019-10-20 20:05:46 +02:00
|
|
|
$(MAKE) $(BINS_ALL_TARGETS) GOOS=solaris GOARCH=amd64
|
|
|
|
ifeq ($(GO_SUPPORTS_ILLUMOS), illumos)
|
|
|
|
$(MAKE) $(BINS_ALL_TARGETS) GOOS=illumos GOARCH=amd64
|
|
|
|
else ifeq ($(GO_SUPPORTS_ILLUMOS), noillumos)
|
|
|
|
@echo "SKIPPING ILLUMOS BUILD BECAUSE GO VERSION DOESN'T SUPPORT IT"
|
|
|
|
else
|
|
|
|
@echo "CANNOT DETERMINE WHETHER GO VERSION SUPPORTS GOOS=illumos"; exit 1
|
|
|
|
endif
|
2017-11-12 16:15:12 +01:00
|
|
|
|
2019-10-28 16:16:16 +01:00
|
|
|
lint:
|
|
|
|
$(GO_ENV_VARS) $(GOLANGCI_LINT) run ./...
|
2020-05-24 17:43:42 +02:00
|
|
|
|
2017-09-30 16:40:39 +02:00
|
|
|
vet:
|
2019-10-26 14:53:01 +02:00
|
|
|
$(GO_ENV_VARS) $(GO) vet $(GO_BUILDFLAGS) ./...
|
2019-10-28 16:16:16 +01:00
|
|
|
|
2020-05-24 17:43:42 +02:00
|
|
|
test-go: $(ARTIFACTDIR)
|
|
|
|
rm -f "$(ARTIFACTDIR)/gotest.cover"
|
|
|
|
ifeq ($(COVER),1)
|
|
|
|
$(GO_ENV_VARS) $(GO) test $(GO_BUILDFLAGS) \
|
|
|
|
-coverpkg github.com/zrepl/zrepl/... \
|
|
|
|
-covermode atomic \
|
|
|
|
-coverprofile "$(ARTIFACTDIR)/gotest.cover" \
|
|
|
|
./...
|
|
|
|
else
|
|
|
|
$(GO_ENV_VARS) $(GO) test $(GO_BUILDFLAGS) \
|
|
|
|
./...
|
|
|
|
endif
|
|
|
|
|
2019-10-28 16:16:16 +01:00
|
|
|
zrepl-bin:
|
2020-02-09 12:45:30 +01:00
|
|
|
$(GO_BUILD) -o "$(ARTIFACTDIR)/zrepl-$(ZREPL_TARGET_TUPLE)"
|
2019-10-28 16:16:16 +01:00
|
|
|
|
2020-05-24 17:43:42 +02:00
|
|
|
generate-platform-test-list:
|
|
|
|
$(GO_BUILD) -o $(ARTIFACTDIR)/generate-platform-test-list ./platformtest/tests/gen
|
2019-10-28 16:16:16 +01:00
|
|
|
|
2020-08-21 23:01:35 +02:00
|
|
|
COVER_PLATFORM_BIN_PATH := $(ARTIFACTDIR)/platformtest-cover-$(ZREPL_TARGET_TUPLE)
|
|
|
|
cover-platform-bin:
|
2020-05-24 17:43:42 +02:00
|
|
|
$(GO_ENV_VARS) $(GO) test $(GO_BUILDFLAGS) \
|
2020-08-21 23:01:35 +02:00
|
|
|
-c -o "$(COVER_PLATFORM_BIN_PATH)" \
|
2020-05-24 17:43:42 +02:00
|
|
|
-covermode=atomic -cover -coverpkg github.com/zrepl/zrepl/... \
|
|
|
|
./platformtest/harness
|
2020-08-21 23:01:35 +02:00
|
|
|
cover-platform:
|
|
|
|
# do not track dependency on cover-platform-bin to allow build of binary outside of test VM
|
|
|
|
export _TEST_PLATFORM_CMD="$(COVER_PLATFORM_BIN_PATH) \
|
|
|
|
-test.coverprofile \"$(ARTIFACTDIR)/platformtest.cover\" \
|
|
|
|
-test.v \
|
|
|
|
__DEVEL--i-heard-you-like-tests"; \
|
|
|
|
$(MAKE) _test-or-cover-platform-impl
|
|
|
|
|
|
|
|
TEST_PLATFORM_BIN_PATH := $(ARTIFACTDIR)/platformtest-$(ZREPL_TARGET_TUPLE)
|
|
|
|
test-platform-bin:
|
|
|
|
$(GO_BUILD) -o "$(TEST_PLATFORM_BIN_PATH)" ./platformtest/harness
|
|
|
|
test-platform:
|
|
|
|
export _TEST_PLATFORM_CMD="\"$(TEST_PLATFORM_BIN_PATH)\""; \
|
|
|
|
$(MAKE) _test-or-cover-platform-impl
|
2017-09-30 16:40:39 +02:00
|
|
|
|
2019-09-29 18:44:59 +02:00
|
|
|
ZREPL_PLATFORMTEST_POOLNAME := zreplplatformtest
|
|
|
|
ZREPL_PLATFORMTEST_IMAGEPATH := /tmp/zreplplatformtest.pool.img
|
new features: {resumable,encrypted,hold-protected} send-recv, last-received-hold
- **Resumable Send & Recv Support**
No knobs required, automatically used where supported.
- **Hold-Protected Send & Recv**
Automatic ZFS holds to ensure that we can always resume a replication step.
- **Encrypted Send & Recv Support** for OpenZFS native encryption.
Configurable at the job level, i.e., for all filesystems a job is responsible for.
- **Receive-side hold on last received dataset**
The counterpart to the replication cursor bookmark on the send-side.
Ensures that incremental replication will always be possible between a sender and receiver.
Design Doc
----------
`replication/design.md` doc describes how we use ZFS holds and bookmarks to ensure that a single replication step is always resumable.
The replication algorithm described in the design doc introduces the notion of job IDs (please read the details on this design doc).
We reuse the job names for job IDs and use `JobID` type to ensure that a job name can be embedded into hold tags, bookmark names, etc.
This might BREAK CONFIG on upgrade.
Protocol Version Bump
---------------------
This commit makes backwards-incompatible changes to the replication/pdu protobufs.
Thus, bump the version number used in the protocol handshake.
Replication Cursor Format Change
--------------------------------
The new replication cursor bookmark format is: `#zrepl_CURSOR_G_${this.GUID}_J_${jobid}`
Including the GUID enables transaction-safe moving-forward of the cursor.
Including the job id enables that multiple sending jobs can send the same filesystem without interfering.
The `zrepl migrate replication-cursor:v1-v2` subcommand can be used to safely destroy old-format cursors once zrepl has created new-format cursors.
Changes in This Commit
----------------------
- package zfs
- infrastructure for holds
- infrastructure for resume token decoding
- implement a variant of OpenZFS's `entity_namecheck` and use it for validation in new code
- ZFSSendArgs to specify a ZFS send operation
- validation code protects against malicious resume tokens by checking that the token encodes the same send parameters that the send-side would use if no resume token were available (i.e. same filesystem, `fromguid`, `toguid`)
- RecvOptions support for `recv -s` flag
- convert a bunch of ZFS operations to be idempotent
- achieved through more differentiated error message scraping / additional pre-/post-checks
- package replication/pdu
- add field for encryption to send request messages
- add fields for resume handling to send & recv request messages
- receive requests now contain `FilesystemVersion To` in addition to the filesystem into which the stream should be `recv`d into
- can use `zfs recv $root_fs/$client_id/path/to/dataset@${To.Name}`, which enables additional validation after recv (i.e. whether `To.Guid` matched what we received in the stream)
- used to set `last-received-hold`
- package replication/logic
- introduce `PlannerPolicy` struct, currently only used to configure whether encrypted sends should be requested from the sender
- integrate encryption and resume token support into `Step` struct
- package endpoint
- move the concepts that endpoint builds on top of ZFS to a single file `endpoint/endpoint_zfs.go`
- step-holds + step-bookmarks
- last-received-hold
- new replication cursor + old replication cursor compat code
- adjust `endpoint/endpoint.go` handlers for
- encryption
- resumability
- new replication cursor
- last-received-hold
- client subcommand `zrepl holds list`: list all holds and hold-like bookmarks that zrepl thinks belong to it
- client subcommand `zrepl migrate replication-cursor:v1-v2`
2019-09-11 17:19:17 +02:00
|
|
|
ZREPL_PLATFORMTEST_MOUNTPOINT := /tmp/zreplplatformtest.pool
|
|
|
|
ZREPL_PLATFORMTEST_ZFS_LOG := /tmp/zreplplatformtest.zfs.log
|
|
|
|
# ZREPL_PLATFORMTEST_STOP_AND_KEEP := -failure.stop-and-keep-pool
|
2020-09-02 21:34:52 +02:00
|
|
|
ZREPL_PLATFORMTEST_ARGS :=
|
2020-08-21 23:01:35 +02:00
|
|
|
_test-or-cover-platform-impl: $(ARTIFACTDIR)
|
|
|
|
ifndef _TEST_PLATFORM_CMD
|
|
|
|
$(error _TEST_PLATFORM_CMD is undefined, caller 'cover-platform' or 'test-platform' should have defined it)
|
|
|
|
endif
|
new features: {resumable,encrypted,hold-protected} send-recv, last-received-hold
- **Resumable Send & Recv Support**
No knobs required, automatically used where supported.
- **Hold-Protected Send & Recv**
Automatic ZFS holds to ensure that we can always resume a replication step.
- **Encrypted Send & Recv Support** for OpenZFS native encryption.
Configurable at the job level, i.e., for all filesystems a job is responsible for.
- **Receive-side hold on last received dataset**
The counterpart to the replication cursor bookmark on the send-side.
Ensures that incremental replication will always be possible between a sender and receiver.
Design Doc
----------
`replication/design.md` doc describes how we use ZFS holds and bookmarks to ensure that a single replication step is always resumable.
The replication algorithm described in the design doc introduces the notion of job IDs (please read the details on this design doc).
We reuse the job names for job IDs and use `JobID` type to ensure that a job name can be embedded into hold tags, bookmark names, etc.
This might BREAK CONFIG on upgrade.
Protocol Version Bump
---------------------
This commit makes backwards-incompatible changes to the replication/pdu protobufs.
Thus, bump the version number used in the protocol handshake.
Replication Cursor Format Change
--------------------------------
The new replication cursor bookmark format is: `#zrepl_CURSOR_G_${this.GUID}_J_${jobid}`
Including the GUID enables transaction-safe moving-forward of the cursor.
Including the job id enables that multiple sending jobs can send the same filesystem without interfering.
The `zrepl migrate replication-cursor:v1-v2` subcommand can be used to safely destroy old-format cursors once zrepl has created new-format cursors.
Changes in This Commit
----------------------
- package zfs
- infrastructure for holds
- infrastructure for resume token decoding
- implement a variant of OpenZFS's `entity_namecheck` and use it for validation in new code
- ZFSSendArgs to specify a ZFS send operation
- validation code protects against malicious resume tokens by checking that the token encodes the same send parameters that the send-side would use if no resume token were available (i.e. same filesystem, `fromguid`, `toguid`)
- RecvOptions support for `recv -s` flag
- convert a bunch of ZFS operations to be idempotent
- achieved through more differentiated error message scraping / additional pre-/post-checks
- package replication/pdu
- add field for encryption to send request messages
- add fields for resume handling to send & recv request messages
- receive requests now contain `FilesystemVersion To` in addition to the filesystem into which the stream should be `recv`d into
- can use `zfs recv $root_fs/$client_id/path/to/dataset@${To.Name}`, which enables additional validation after recv (i.e. whether `To.Guid` matched what we received in the stream)
- used to set `last-received-hold`
- package replication/logic
- introduce `PlannerPolicy` struct, currently only used to configure whether encrypted sends should be requested from the sender
- integrate encryption and resume token support into `Step` struct
- package endpoint
- move the concepts that endpoint builds on top of ZFS to a single file `endpoint/endpoint_zfs.go`
- step-holds + step-bookmarks
- last-received-hold
- new replication cursor + old replication cursor compat code
- adjust `endpoint/endpoint.go` handlers for
- encryption
- resumability
- new replication cursor
- last-received-hold
- client subcommand `zrepl holds list`: list all holds and hold-like bookmarks that zrepl thinks belong to it
- client subcommand `zrepl migrate replication-cursor:v1-v2`
2019-09-11 17:19:17 +02:00
|
|
|
rm -f "$(ZREPL_PLATFORMTEST_ZFS_LOG)"
|
2020-05-24 17:43:42 +02:00
|
|
|
rm -f "$(ARTIFACTDIR)/platformtest.cover"
|
new features: {resumable,encrypted,hold-protected} send-recv, last-received-hold
- **Resumable Send & Recv Support**
No knobs required, automatically used where supported.
- **Hold-Protected Send & Recv**
Automatic ZFS holds to ensure that we can always resume a replication step.
- **Encrypted Send & Recv Support** for OpenZFS native encryption.
Configurable at the job level, i.e., for all filesystems a job is responsible for.
- **Receive-side hold on last received dataset**
The counterpart to the replication cursor bookmark on the send-side.
Ensures that incremental replication will always be possible between a sender and receiver.
Design Doc
----------
`replication/design.md` doc describes how we use ZFS holds and bookmarks to ensure that a single replication step is always resumable.
The replication algorithm described in the design doc introduces the notion of job IDs (please read the details on this design doc).
We reuse the job names for job IDs and use `JobID` type to ensure that a job name can be embedded into hold tags, bookmark names, etc.
This might BREAK CONFIG on upgrade.
Protocol Version Bump
---------------------
This commit makes backwards-incompatible changes to the replication/pdu protobufs.
Thus, bump the version number used in the protocol handshake.
Replication Cursor Format Change
--------------------------------
The new replication cursor bookmark format is: `#zrepl_CURSOR_G_${this.GUID}_J_${jobid}`
Including the GUID enables transaction-safe moving-forward of the cursor.
Including the job id enables that multiple sending jobs can send the same filesystem without interfering.
The `zrepl migrate replication-cursor:v1-v2` subcommand can be used to safely destroy old-format cursors once zrepl has created new-format cursors.
Changes in This Commit
----------------------
- package zfs
- infrastructure for holds
- infrastructure for resume token decoding
- implement a variant of OpenZFS's `entity_namecheck` and use it for validation in new code
- ZFSSendArgs to specify a ZFS send operation
- validation code protects against malicious resume tokens by checking that the token encodes the same send parameters that the send-side would use if no resume token were available (i.e. same filesystem, `fromguid`, `toguid`)
- RecvOptions support for `recv -s` flag
- convert a bunch of ZFS operations to be idempotent
- achieved through more differentiated error message scraping / additional pre-/post-checks
- package replication/pdu
- add field for encryption to send request messages
- add fields for resume handling to send & recv request messages
- receive requests now contain `FilesystemVersion To` in addition to the filesystem into which the stream should be `recv`d into
- can use `zfs recv $root_fs/$client_id/path/to/dataset@${To.Name}`, which enables additional validation after recv (i.e. whether `To.Guid` matched what we received in the stream)
- used to set `last-received-hold`
- package replication/logic
- introduce `PlannerPolicy` struct, currently only used to configure whether encrypted sends should be requested from the sender
- integrate encryption and resume token support into `Step` struct
- package endpoint
- move the concepts that endpoint builds on top of ZFS to a single file `endpoint/endpoint_zfs.go`
- step-holds + step-bookmarks
- last-received-hold
- new replication cursor + old replication cursor compat code
- adjust `endpoint/endpoint.go` handlers for
- encryption
- resumability
- new replication cursor
- last-received-hold
- client subcommand `zrepl holds list`: list all holds and hold-like bookmarks that zrepl thinks belong to it
- client subcommand `zrepl migrate replication-cursor:v1-v2`
2019-09-11 17:19:17 +02:00
|
|
|
platformtest/logmockzfs/logzfsenv "$(ZREPL_PLATFORMTEST_ZFS_LOG)" `which zfs` \
|
2020-08-21 23:01:35 +02:00
|
|
|
$(_TEST_PLATFORM_CMD) \
|
new features: {resumable,encrypted,hold-protected} send-recv, last-received-hold
- **Resumable Send & Recv Support**
No knobs required, automatically used where supported.
- **Hold-Protected Send & Recv**
Automatic ZFS holds to ensure that we can always resume a replication step.
- **Encrypted Send & Recv Support** for OpenZFS native encryption.
Configurable at the job level, i.e., for all filesystems a job is responsible for.
- **Receive-side hold on last received dataset**
The counterpart to the replication cursor bookmark on the send-side.
Ensures that incremental replication will always be possible between a sender and receiver.
Design Doc
----------
`replication/design.md` doc describes how we use ZFS holds and bookmarks to ensure that a single replication step is always resumable.
The replication algorithm described in the design doc introduces the notion of job IDs (please read the details on this design doc).
We reuse the job names for job IDs and use `JobID` type to ensure that a job name can be embedded into hold tags, bookmark names, etc.
This might BREAK CONFIG on upgrade.
Protocol Version Bump
---------------------
This commit makes backwards-incompatible changes to the replication/pdu protobufs.
Thus, bump the version number used in the protocol handshake.
Replication Cursor Format Change
--------------------------------
The new replication cursor bookmark format is: `#zrepl_CURSOR_G_${this.GUID}_J_${jobid}`
Including the GUID enables transaction-safe moving-forward of the cursor.
Including the job id enables that multiple sending jobs can send the same filesystem without interfering.
The `zrepl migrate replication-cursor:v1-v2` subcommand can be used to safely destroy old-format cursors once zrepl has created new-format cursors.
Changes in This Commit
----------------------
- package zfs
- infrastructure for holds
- infrastructure for resume token decoding
- implement a variant of OpenZFS's `entity_namecheck` and use it for validation in new code
- ZFSSendArgs to specify a ZFS send operation
- validation code protects against malicious resume tokens by checking that the token encodes the same send parameters that the send-side would use if no resume token were available (i.e. same filesystem, `fromguid`, `toguid`)
- RecvOptions support for `recv -s` flag
- convert a bunch of ZFS operations to be idempotent
- achieved through more differentiated error message scraping / additional pre-/post-checks
- package replication/pdu
- add field for encryption to send request messages
- add fields for resume handling to send & recv request messages
- receive requests now contain `FilesystemVersion To` in addition to the filesystem into which the stream should be `recv`d into
- can use `zfs recv $root_fs/$client_id/path/to/dataset@${To.Name}`, which enables additional validation after recv (i.e. whether `To.Guid` matched what we received in the stream)
- used to set `last-received-hold`
- package replication/logic
- introduce `PlannerPolicy` struct, currently only used to configure whether encrypted sends should be requested from the sender
- integrate encryption and resume token support into `Step` struct
- package endpoint
- move the concepts that endpoint builds on top of ZFS to a single file `endpoint/endpoint_zfs.go`
- step-holds + step-bookmarks
- last-received-hold
- new replication cursor + old replication cursor compat code
- adjust `endpoint/endpoint.go` handlers for
- encryption
- resumability
- new replication cursor
- last-received-hold
- client subcommand `zrepl holds list`: list all holds and hold-like bookmarks that zrepl thinks belong to it
- client subcommand `zrepl migrate replication-cursor:v1-v2`
2019-09-11 17:19:17 +02:00
|
|
|
-poolname "$(ZREPL_PLATFORMTEST_POOLNAME)" \
|
|
|
|
-imagepath "$(ZREPL_PLATFORMTEST_IMAGEPATH)" \
|
|
|
|
-mountpoint "$(ZREPL_PLATFORMTEST_MOUNTPOINT)" \
|
|
|
|
$(ZREPL_PLATFORMTEST_STOP_AND_KEEP) \
|
|
|
|
$(ZREPL_PLATFORMTEST_ARGS)
|
2019-10-28 16:16:16 +01:00
|
|
|
|
2020-05-24 17:43:42 +02:00
|
|
|
cover-merge: $(ARTIFACTDIR)
|
|
|
|
$(GOCOVMERGE) $(ARTIFACTDIR)/platformtest.cover $(ARTIFACTDIR)/gotest.cover > $(ARTIFACTDIR)/merged.cover
|
|
|
|
cover-html: cover-merge
|
|
|
|
$(GO) tool cover -html "$(ARTIFACTDIR)/merged.cover" -o "$(ARTIFACTDIR)/merged.cover.html"
|
|
|
|
|
2020-08-21 23:01:35 +02:00
|
|
|
cover-full:
|
2020-05-24 17:43:42 +02:00
|
|
|
test "$$(id -u)" = "0" || echo "MUST RUN AS ROOT" 1>&2
|
|
|
|
$(MAKE) test-go COVER=1
|
2020-08-21 23:01:35 +02:00
|
|
|
$(MAKE) cover-platform-bin
|
|
|
|
$(MAKE) cover-platform
|
2020-05-24 17:43:42 +02:00
|
|
|
$(MAKE) cover-html
|
|
|
|
|
|
|
|
##################### DEV TARGETS #####################
|
|
|
|
# not part of the build, must do that manually
|
2020-08-31 15:17:51 +02:00
|
|
|
.PHONY: generate formatcheck format
|
2020-05-24 17:43:42 +02:00
|
|
|
|
|
|
|
generate: generate-platform-test-list
|
2021-01-24 23:31:45 +01:00
|
|
|
protoc -I=replication/logic/pdu --go_out=replication/logic/pdu --go-grpc_out=replication/logic/pdu replication/logic/pdu/pdu.proto
|
|
|
|
protoc -I=rpc/grpcclientidentity/example --go_out=rpc/grpcclientidentity/example/pdu --go-grpc_out=rpc/grpcclientidentity/example/pdu rpc/grpcclientidentity/example/grpcauth.proto
|
2020-05-24 17:43:42 +02:00
|
|
|
$(GO_ENV_VARS) $(GO) generate $(GO_BUILDFLAGS) -x ./...
|
|
|
|
|
2020-08-31 15:17:51 +02:00
|
|
|
GOIMPORTS := goimports -srcdir . -local 'github.com/zrepl/zrepl'
|
|
|
|
FINDSRCFILES := find . -type f -name '*.go' -not -path "./vendor/*" -not -name '*.pb.go' -not -name '*_enumer.go'
|
|
|
|
|
|
|
|
formatcheck:
|
2020-09-01 19:36:46 +02:00
|
|
|
@# goimports doesn't have a knob to exit with non-zero status code if formatting is needed
|
|
|
|
@# see https://go-review.googlesource.com/c/tools/+/237378
|
|
|
|
@ affectedfiles=$$($(GOIMPORTS) -l $(shell $(FINDSRCFILES)) | tee /dev/stderr | wc -l); test "$$affectedfiles" = 0
|
2020-08-31 15:17:51 +02:00
|
|
|
|
2020-05-24 17:43:42 +02:00
|
|
|
format:
|
2020-08-31 15:17:51 +02:00
|
|
|
@ $(GOIMPORTS) -w -d $(shell $(FINDSRCFILES))
|
2020-05-24 17:43:42 +02:00
|
|
|
|
2019-10-28 16:16:16 +01:00
|
|
|
##################### NOARCH #####################
|
2020-04-18 21:36:48 +02:00
|
|
|
.PHONY: noarch $(ARTIFACTDIR)/bash_completion $(ARTIFACTDIR)/_zrepl.zsh_completion $(ARTIFACTDIR)/go_env.txt docs docs-clean
|
2019-10-28 16:16:16 +01:00
|
|
|
|
2019-09-29 18:44:59 +02:00
|
|
|
|
2017-11-18 16:20:14 +01:00
|
|
|
$(ARTIFACTDIR):
|
|
|
|
mkdir -p "$@"
|
2017-11-18 16:21:53 +01:00
|
|
|
$(ARTIFACTDIR)/docs: $(ARTIFACTDIR)
|
|
|
|
mkdir -p "$@"
|
|
|
|
|
2020-04-18 19:09:49 +02:00
|
|
|
noarch: $(ARTIFACTDIR)/bash_completion $(ARTIFACTDIR)/_zrepl.zsh_completion $(ARTIFACTDIR)/go_env.txt docs
|
2019-10-28 16:16:16 +01:00
|
|
|
# pass
|
2017-12-27 13:48:28 +01:00
|
|
|
|
2019-10-28 16:16:16 +01:00
|
|
|
$(ARTIFACTDIR)/bash_completion:
|
|
|
|
$(MAKE) zrepl-bin GOOS=$(GOHOSTOS) GOARCH=$(GOHOSTARCH)
|
2020-04-18 19:09:49 +02:00
|
|
|
artifacts/zrepl-$(GOHOSTOS)-$(GOHOSTARCH) gencompletion bash "$@"
|
|
|
|
|
|
|
|
$(ARTIFACTDIR)/_zrepl.zsh_completion:
|
|
|
|
$(MAKE) zrepl-bin GOOS=$(GOHOSTOS) GOARCH=$(GOHOSTARCH)
|
|
|
|
artifacts/zrepl-$(GOHOSTOS)-$(GOHOSTARCH) gencompletion zsh "$@"
|
2019-10-28 16:16:16 +01:00
|
|
|
|
|
|
|
$(ARTIFACTDIR)/go_env.txt:
|
|
|
|
$(GO_ENV_VARS) $(GO) env > $@
|
2020-09-06 15:39:34 +02:00
|
|
|
$(GO) version >> $@
|
2018-02-18 16:46:54 +01:00
|
|
|
|
2017-11-18 16:21:53 +01:00
|
|
|
docs: $(ARTIFACTDIR)/docs
|
2020-09-05 16:41:22 +02:00
|
|
|
# https://www.sphinx-doc.org/en/master/man/sphinx-build.html
|
2017-11-18 16:21:53 +01:00
|
|
|
make -C docs \
|
|
|
|
html \
|
|
|
|
BUILDDIR=../artifacts/docs \
|
2020-09-05 16:41:22 +02:00
|
|
|
SPHINXOPTS="-W --keep-going -n"
|
2017-11-18 16:21:53 +01:00
|
|
|
|
|
|
|
docs-clean:
|
|
|
|
make -C docs \
|
|
|
|
clean \
|
|
|
|
BUILDDIR=../artifacts/docs
|