diff --git a/.github/dependabot.yml b/.github/dependabot.yml index d608a82442..8ad6c71e96 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,3 +1,9 @@ + +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + version: 2 updates: # Dependencies listed in go.mod @@ -5,9 +11,8 @@ updates: directory: "/" # Location of package manifests schedule: interval: "weekly" - - # Dependencies listed in .github/workflows/*.yml - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "weekly" + labels: + - "kind/changelog-not-required" + ignore: + - dependency-name: "*" + update-types: ["version-update:semver-major", "version-update:semver-minor", "version-update:semver-patch"] diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 060dda2bd7..6a2e2f5709 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -20,9 +20,16 @@ jobs: with: go-version: 1.18 id: go - - - name: Check out code into the Go module directory - uses: actions/checkout@v2 + - run: | + sudo apt-get install python2.7 + export CLOUDSDK_PYTHON="/usr/bin/python2" + - uses: actions/checkout@v3 + - uses: google-github-actions/setup-gcloud@v0 + with: + version: '285.0.0' + service_account_key: ${{ secrets.GCP_SA_KEY }} + export_default_credentials: true + - run: gcloud info - name: Set up QEMU id: qemu @@ -42,29 +49,34 @@ jobs: - name: Test run: make test - - name: Upload test coverage - uses: codecov/codecov-action@v2 - with: - token: ${{ secrets.CODECOV_TOKEN }} - files: coverage.out - verbose: true # Only try to publish the container image from the root repo; forks don't have permission to do so and will always get failures. - name: Publish container image - if: github.repository == 'vmware-tanzu/velero' run: | docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }} - ./hack/docker-push.sh + BIN=velero + RESTORE_HELPER_BIN=velero-restore-helper + VERSION=$(./hack/docker-push.sh | grep 'VERSION:' | awk -F: '{print $2}' | xargs) - # Use the JSON key in secret to login gcr.io - - uses: 'docker/login-action@v1' - with: - registry: 'gcr.io' # or REGION.docker.pkg.dev - username: '_json_key' - password: '${{ secrets.GCR_SA_KEY }}' + # Push image to GCR to facilitate some environments that have rate limitation to docker hub, e.g. vSphere. + source hack/ci/build_util.sh - # Push image to GCR to facilitate some environments that have rate limitation to docker hub, e.g. vSphere. - - name: Publish container image to GCR - if: github.repository == 'vmware-tanzu/velero' + GS_BUCKET=velero-builds + VELERO_IMAGE=${BIN}-${VERSION} + VELERO_RESTORE_HELPER_IMAGE=${RESTORE_HELPER_BIN}-${VERSION} + VELERO_IMAGE_FILE=${VELERO_IMAGE}.tar.gz + VELERO_RESTORE_HELPER_IMAGE_FILE=${VELERO_RESTORE_HELPER_IMAGE}.tar.gz + VELERO_IMAGE_BACKUP_FILE=${VELERO_IMAGE}-'build.'${GITHUB_RUN_NUMBER}.tar.gz + VELERO_RESTORE_HELPER_IMAGE_BACKUP_FILE=${VELERO_RESTORE_HELPER_IMAGE}-'build.'${GITHUB_RUN_NUMBER}.tar.gz + + cp ${VELERO_IMAGE_FILE} ${VELERO_IMAGE_BACKUP_FILE} + cp ${VELERO_RESTORE_HELPER_IMAGE_FILE} ${VELERO_RESTORE_HELPER_IMAGE_BACKUP_FILE} + + uploader ${VELERO_IMAGE_FILE} ${GS_BUCKET} + uploader ${VELERO_RESTORE_HELPER_IMAGE_FILE} ${GS_BUCKET} + uploader ${VELERO_IMAGE_BACKUP_FILE} ${GS_BUCKET} + uploader ${VELERO_RESTORE_HELPER_IMAGE_BACKUP_FILE} ${GS_BUCKET} + - name: Publish container image to velero again run: | - REGISTRY=gcr.io/velero-gcp ./hack/docker-push.sh + docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }} + ./hack/docker-push.sh \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 2eacd87baf..757b03c075 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,8 +29,6 @@ WORKDIR /go/src/github.com/vmware-tanzu/velero COPY . /go/src/github.com/vmware-tanzu/velero -RUN apt-get update && apt-get install -y bzip2 - FROM --platform=$BUILDPLATFORM builder-env as builder ARG TARGETOS @@ -45,8 +43,8 @@ ENV GOOS=${TARGETOS} \ GOARM=${TARGETVARIANT} RUN mkdir -p /output/usr/bin && \ - bash ./hack/download-restic.sh && \ export GOARM=$( echo "${GOARM}" | cut -c2-) && \ + bash ./hack/build-restic.sh && \ go build -o /output/${BIN} \ -ldflags "${LDFLAGS}" ${PKG}/cmd/${BIN} diff --git a/Makefile b/Makefile index 4e8e728659..7cc18ef204 100644 --- a/Makefile +++ b/Makefile @@ -208,7 +208,14 @@ endif --build-arg=REGISTRY=$(REGISTRY) \ --build-arg=RESTIC_VERSION=$(RESTIC_VERSION) \ -f $(VELERO_DOCKERFILE) . - @echo "container: $(IMAGE):$(VERSION)" + echo "container1: $(IMAGE):$(VERSION)" +ifeq ($(BUILDX_OUTPUT_TYPE)_$(REGISTRY), registry_velero) + docker pull $(IMAGE):$(VERSION) + rm -f $(BIN)-$(VERSION).tar + docker save $(IMAGE):$(VERSION) -o $(BIN)-$(VERSION).tar + gzip -f $(BIN)-$(VERSION).tar +endif + echo "container2: $(IMAGE):$(VERSION)" SKIP_TESTS ?= test: build-dirs diff --git a/changelogs/unreleased/5468-qiuming-best b/changelogs/unreleased/5468-qiuming-best new file mode 100644 index 0000000000..96b49b4df6 --- /dev/null +++ b/changelogs/unreleased/5468-qiuming-best @@ -0,0 +1 @@ +Add v1.10 velero upgrade doc diff --git a/changelogs/unreleased/5572-qiuming-best b/changelogs/unreleased/5572-qiuming-best new file mode 100644 index 0000000000..40d53fc966 --- /dev/null +++ b/changelogs/unreleased/5572-qiuming-best @@ -0,0 +1 @@ +Fix controller problematic log output diff --git a/changelogs/unreleased/5574-qiuming-best b/changelogs/unreleased/5574-qiuming-best new file mode 100644 index 0000000000..c872212b5c --- /dev/null +++ b/changelogs/unreleased/5574-qiuming-best @@ -0,0 +1 @@ +Add compile restic binary for CVE fix diff --git a/coverage.out b/coverage.out new file mode 100644 index 0000000000..5f02b11199 --- /dev/null +++ b/coverage.out @@ -0,0 +1 @@ +mode: set diff --git a/go.mod b/go.mod index c69d4c2edd..bf53869dc5 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,6 @@ require ( github.com/evanphx/json-patch v5.6.0+incompatible github.com/fatih/color v1.13.0 github.com/gobwas/glob v0.2.3 - github.com/gofrs/uuid v3.2.0+incompatible github.com/golang/protobuf v1.5.2 github.com/google/go-cmp v0.5.8 github.com/google/uuid v1.3.0 @@ -35,22 +34,22 @@ require ( github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.7.1 github.com/vmware-tanzu/crash-diagnostics v0.3.7 - golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 + golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 golang.org/x/net v0.0.0-20220615171555-694bf12d69de golang.org/x/oauth2 v0.0.0-20220608161450-d0670ef3b1eb golang.org/x/sync v0.0.0-20210220032951-036812b2e83c google.golang.org/api v0.74.0 google.golang.org/grpc v1.45.0 google.golang.org/protobuf v1.28.0 - k8s.io/api v0.24.1 - k8s.io/apiextensions-apiserver v0.24.1 - k8s.io/apimachinery v0.24.1 + k8s.io/api v0.24.2 + k8s.io/apiextensions-apiserver v0.24.2 + k8s.io/apimachinery v0.24.2 k8s.io/cli-runtime v0.24.0 - k8s.io/client-go v0.24.1 + k8s.io/client-go v0.24.2 k8s.io/klog/v2 v2.60.1 k8s.io/kube-aggregator v0.19.12 k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 - sigs.k8s.io/controller-runtime v0.12.1 + sigs.k8s.io/controller-runtime v0.12.2 sigs.k8s.io/yaml v1.3.0 ) @@ -133,9 +132,9 @@ require ( go.uber.org/zap v1.21.0 // indirect golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd // indirect golang.org/x/exp v0.0.0-20210916165020-5cb4fee858ee // indirect - golang.org/x/sys v0.0.0-20220614162138-6c1b26c55098 // indirect + golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect golang.org/x/term v0.0.0-20220526004731-065cf7ba2467 // indirect - golang.org/x/text v0.3.7 // indirect + golang.org/x/text v0.3.8 // indirect golang.org/x/time v0.0.0-20220609170525-579cf78fd858 // indirect golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect @@ -146,7 +145,7 @@ require ( gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/component-base v0.24.1 // indirect + k8s.io/component-base v0.24.2 // indirect k8s.io/kube-openapi v0.0.0-20220614142933-1062c7ade5f8 // indirect sigs.k8s.io/json v0.0.0-20220525155127-227cbc7cc124 // indirect sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect diff --git a/go.sum b/go.sum index 7f200bfc43..c52fa1bcee 100644 --- a/go.sum +++ b/go.sum @@ -293,8 +293,6 @@ github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJA github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= -github.com/gofrs/uuid v3.2.0+incompatible h1:y12jRkkFxsd7GpqdSZ+/KCs/fJbqpEXSGd4+jfEaewE= -github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= @@ -844,8 +842,9 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o= golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20180530234432-1e491301e022/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 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= @@ -1029,8 +1028,8 @@ golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220614162138-6c1b26c55098 h1:PgOr27OhUx2IRqGJ2RxAWI4dJQ7bi9cSrB82uzFzfUA= -golang.org/x/sys v0.0.0-20220614162138-6c1b26c55098/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -1045,8 +1044,9 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.3.8 h1:nAL+RVCQ9uMn3vJZbV+MRnydTJFPf8qqY42YiA6MrqY= +golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1352,18 +1352,18 @@ k8s.io/api v0.19.0/go.mod h1:I1K45XlvTrDjmj5LoM5LuP/KYrhWbjUKT/SoPG0qTjw= k8s.io/api v0.19.12/go.mod h1:EK+KvSq2urA6+CjVdZyAHEphXoLq2K2eW6lxOzTKSaY= k8s.io/api v0.22.2/go.mod h1:y3ydYpLJAaDI+BbSe2xmGcqxiWHmWjkEeIbiwHvnPR8= k8s.io/api v0.24.0/go.mod h1:5Jl90IUrJHUJYEMANRURMiVvJ0g7Ax7r3R1bqO8zx8I= -k8s.io/api v0.24.1 h1:BjCMRDcyEYz03joa3K1+rbshwh1Ay6oB53+iUx2H8UY= -k8s.io/api v0.24.1/go.mod h1:JhoOvNiLXKTPQ60zh2g0ewpA+bnEYf5q44Flhquh4vQ= -k8s.io/apiextensions-apiserver v0.24.1 h1:5yBh9+ueTq/kfnHQZa0MAo6uNcPrtxPMpNQgorBaKS0= -k8s.io/apiextensions-apiserver v0.24.1/go.mod h1:A6MHfaLDGfjOc/We2nM7uewD5Oa/FnEbZ6cD7g2ca4Q= +k8s.io/api v0.24.2 h1:g518dPU/L7VRLxWfcadQn2OnsiGWVOadTLpdnqgY2OI= +k8s.io/api v0.24.2/go.mod h1:AHqbSkTm6YrQ0ObxjO3Pmp/ubFF/KuM7jU+3khoBsOg= +k8s.io/apiextensions-apiserver v0.24.2 h1:/4NEQHKlEz1MlaK/wHT5KMKC9UKYz6NZz6JE6ov4G6k= +k8s.io/apiextensions-apiserver v0.24.2/go.mod h1:e5t2GMFVngUEHUd0wuCJzw8YDwZoqZfJiGOW6mm2hLQ= k8s.io/apimachinery v0.19.0/go.mod h1:DnPGDnARWFvYa3pMHgSxtbZb7gpzzAZ1pTfaUNDVlmA= k8s.io/apimachinery v0.19.12/go.mod h1:9eb44nUQSsz9QZiilFRuMj3ZbTmoWolU8S2gnXoRMjo= k8s.io/apimachinery v0.22.2/go.mod h1:O3oNtNadZdeOMxHFVxOreoznohCpy0z6mocxbZr7oJ0= k8s.io/apimachinery v0.24.0/go.mod h1:82Bi4sCzVBdpYjyI4jY6aHX+YCUchUIrZrXKedjd2UM= -k8s.io/apimachinery v0.24.1 h1:ShD4aDxTQKN5zNf8K1RQ2u98ELLdIW7jEnlO9uAMX/I= -k8s.io/apimachinery v0.24.1/go.mod h1:82Bi4sCzVBdpYjyI4jY6aHX+YCUchUIrZrXKedjd2UM= +k8s.io/apimachinery v0.24.2 h1:5QlH9SL2C8KMcrNJPor+LbXVTaZRReml7svPEh4OKDM= +k8s.io/apimachinery v0.24.2/go.mod h1:82Bi4sCzVBdpYjyI4jY6aHX+YCUchUIrZrXKedjd2UM= k8s.io/apiserver v0.19.12/go.mod h1:ldZAZTNIKfMMv/UUEhk6UyTXC0/34iRdNFHo+MJOPc4= -k8s.io/apiserver v0.24.1/go.mod h1:dQWNMx15S8NqJMp0gpYfssyvhYnkilc1LpExd/dkLh0= +k8s.io/apiserver v0.24.2/go.mod h1:pSuKzr3zV+L+MWqsEo0kHHYwCo77AT5qXbFXP2jbvFI= k8s.io/cli-runtime v0.22.2/go.mod h1:tkm2YeORFpbgQHEK/igqttvPTRIHFRz5kATlw53zlMI= k8s.io/cli-runtime v0.24.0 h1:ot3Qf49T852uEyNApABO1UHHpFIckKK/NqpheZYN2gM= k8s.io/cli-runtime v0.24.0/go.mod h1:9XxoZDsEkRFUThnwqNviqzljtT/LdHtNWvcNFrAXl0A= @@ -1371,14 +1371,14 @@ k8s.io/client-go v0.19.0/go.mod h1:H9E/VT95blcFQnlyShFgnFT9ZnJOAceiUHM3MlRC+mU= k8s.io/client-go v0.19.12/go.mod h1:BAGKQraZ6fDmXhT46pGXWZQQqN7P4E0BJux0+9O6Gt0= k8s.io/client-go v0.22.2/go.mod h1:sAlhrkVDf50ZHx6z4K0S40wISNTarf1r800F+RlCF6U= k8s.io/client-go v0.24.0/go.mod h1:VFPQET+cAFpYxh6Bq6f4xyMY80G6jKKktU6G0m00VDw= -k8s.io/client-go v0.24.1 h1:w1hNdI9PFrzu3OlovVeTnf4oHDt+FJLd9Ndluvnb42E= -k8s.io/client-go v0.24.1/go.mod h1:f1kIDqcEYmwXS/vTbbhopMUbhKp2JhOeVTfxgaCIlF8= +k8s.io/client-go v0.24.2 h1:CoXFSf8if+bLEbinDqN9ePIDGzcLtqhfd6jpfnwGOFA= +k8s.io/client-go v0.24.2/go.mod h1:zg4Xaoo+umDsfCWr4fCnmLEtQXyCNXCvJuSsglNcV30= k8s.io/code-generator v0.19.0/go.mod h1:moqLn7w0t9cMs4+5CQyxnfA/HV8MF6aAVENF+WZZhgk= k8s.io/code-generator v0.19.12/go.mod h1:ADrDvaUQWGn4a8lX0ONtzb7uFmDRQOMSYIMk1qWIAx8= -k8s.io/code-generator v0.24.1/go.mod h1:dpVhs00hTuTdTY6jvVxvTFCk6gSMrtfRydbhZwHI15w= +k8s.io/code-generator v0.24.2/go.mod h1:dpVhs00hTuTdTY6jvVxvTFCk6gSMrtfRydbhZwHI15w= k8s.io/component-base v0.19.12/go.mod h1:tpwExE0sY3A7CwtlxGL7SnQOdQfUlnFybT6GmAD+z/s= -k8s.io/component-base v0.24.1 h1:APv6W/YmfOWZfo+XJ1mZwep/f7g7Tpwvdbo9CQLDuts= -k8s.io/component-base v0.24.1/go.mod h1:DW5vQGYVCog8WYpNob3PMmmsY8A3L9QZNg4j/dV3s38= +k8s.io/component-base v0.24.2 h1:kwpQdoSfbcH+8MPN4tALtajLDfSfYxBDYlXobNWI6OU= +k8s.io/component-base v0.24.2/go.mod h1:ucHwW76dajvQ9B7+zecZAP3BVqvrHoOxm8olHEg0nmM= k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/gengo v0.0.0-20200428234225-8167cfdcfc14/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/gengo v0.0.0-20210813121822-485abfe95c7c/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= @@ -1405,8 +1405,8 @@ rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.15/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.30/go.mod h1:fEO7lRTdivWO2qYVCVG7dEADOMo/MLDCVr8So2g88Uw= -sigs.k8s.io/controller-runtime v0.12.1 h1:4BJY01xe9zKQti8oRjj/NeHKRXthf1YkYJAgLONFFoI= -sigs.k8s.io/controller-runtime v0.12.1/go.mod h1:BKhxlA4l7FPK4AQcsuL4X6vZeWnKDXez/vp1Y8dxTU0= +sigs.k8s.io/controller-runtime v0.12.2 h1:nqV02cvhbAj7tbt21bpPpTByrXGn2INHRsi39lXy9sE= +sigs.k8s.io/controller-runtime v0.12.2/go.mod h1:qKsk4WE6zW2Hfj0G4v10EnNB2jMG1C+NTb8h+DwCoU0= sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2/go.mod h1:B+TnT182UBxE84DiCz4CVE26eOSDAeYCpfDnC2kdKMY= sigs.k8s.io/json v0.0.0-20220525155127-227cbc7cc124 h1:2sgAQQcY0dEW2SsQwTXhQV4vO6+rSslYx8K3XmM5hqQ= sigs.k8s.io/json v0.0.0-20220525155127-227cbc7cc124/go.mod h1:B+TnT182UBxE84DiCz4CVE26eOSDAeYCpfDnC2kdKMY= diff --git a/hack/build-restic.sh b/hack/build-restic.sh new file mode 100755 index 0000000000..5859414fd3 --- /dev/null +++ b/hack/build-restic.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +# Copyright 2020 the Velero contributors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -o errexit +set -o nounset +set -o pipefail + +# Use /output/usr/bin/ as the default output directory as this +# is the path expected by the Velero Dockerfile. +output_dir=${OUTPUT_DIR:-/output/usr/bin} +restic_bin=${output_dir}/restic +build_path=$(dirname "$PWD") + +if [[ -z "${BIN}" ]]; then + echo "BIN must be set" + exit 1 +fi + +if [[ "${BIN}" != "velero" ]]; then + echo "${BIN} does not need the restic binary" + exit 0 +fi + +if [[ -z "${GOOS}" ]]; then + echo "GOOS must be set" + exit 1 +fi +if [[ -z "${GOARCH}" ]]; then + echo "GOARCH must be set" + exit 1 +fi +if [[ -z "${RESTIC_VERSION}" ]]; then + echo "RESTIC_VERSION must be set" + exit 1 +fi + +mkdir ${build_path}/restic +git clone -b v${RESTIC_VERSION} https://github.com/restic/restic.git ${build_path}/restic +pushd ${build_path}/restic +go run build.go --goos "${GOOS}" --goarch "${GOARCH}" --goarm "${GOARM}" -o ${restic_bin} +chmod +x ${restic_bin} +popd diff --git a/hack/ci/build_util.sh b/hack/ci/build_util.sh new file mode 100644 index 0000000000..599c84b638 --- /dev/null +++ b/hack/ci/build_util.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -x + +set -e + +function uploader { + gsutil cp $1 gs://$2/$1 + gsutil -D setacl public-read gs://$2/$1 &> /dev/null +} diff --git a/internal/hook/item_hook_handler.go b/internal/hook/item_hook_handler.go index 0bced9484a..d84f9bcaa6 100644 --- a/internal/hook/item_hook_handler.go +++ b/internal/hook/item_hook_handler.go @@ -22,7 +22,7 @@ import ( "strings" "time" - uuid "github.com/gofrs/uuid" + "github.com/google/uuid" "github.com/pkg/errors" "github.com/sirupsen/logrus" corev1api "k8s.io/api/core/v1" @@ -377,7 +377,7 @@ func getInitContainerFromAnnotation(podName string, annotations map[string]strin log.Infof("RestoreHook init container for pod %s is using container's default entrypoint", podName, containerImage) } if containerName == "" { - uid, err := uuid.NewV4() + uid, err := uuid.NewRandom() uuidStr := "deadfeed" if err != nil { log.Errorf("Failed to generate UUID for container name") diff --git a/pkg/restore/restore.go b/pkg/restore/restore.go index 9f1130fc06..bea58fafc4 100644 --- a/pkg/restore/restore.go +++ b/pkg/restore/restore.go @@ -28,7 +28,7 @@ import ( "sync" "time" - uuid "github.com/gofrs/uuid" + "github.com/google/uuid" "github.com/pkg/errors" "github.com/sirupsen/logrus" v1 "k8s.io/api/core/v1" @@ -145,7 +145,7 @@ func NewKubernetesRestorer( resourcePriorities: resourcePriorities, logger: logger, pvRenamer: func(string) (string, error) { - veleroCloneUuid, err := uuid.NewV4() + veleroCloneUuid, err := uuid.NewRandom() if err != nil { return "", errors.WithStack(err) } diff --git a/pkg/util/kube/periodical_enqueue_source.go b/pkg/util/kube/periodical_enqueue_source.go index 1b0ec1a31f..885767f605 100644 --- a/pkg/util/kube/periodical_enqueue_source.go +++ b/pkg/util/kube/periodical_enqueue_source.go @@ -18,6 +18,7 @@ package kube import ( "context" + "fmt" "reflect" "time" @@ -109,3 +110,10 @@ func (p *PeriodicalEnqueueSource) Start(ctx context.Context, h handler.EventHand return nil } + +func (p *PeriodicalEnqueueSource) String() string { + if p.objList != nil { + return fmt.Sprintf("kind source: %T", p.objList) + } + return "kind source: unknown type" +} diff --git a/site/content/docs/main/upgrade-to-1.10.md b/site/content/docs/main/upgrade-to-1.10.md new file mode 100644 index 0000000000..e0b23bb156 --- /dev/null +++ b/site/content/docs/main/upgrade-to-1.10.md @@ -0,0 +1,97 @@ +--- +title: "Upgrading to Velero 1.10" +layout: docs +--- + +## Prerequisites + +- Velero [v1.9.x][5] installed. + +If you're not yet running at least Velero v1.6, see the following: + +- [Upgrading to v1.5][1] +- [Upgrading to v1.6][2] +- [Upgrading to v1.7][3] +- [Upgrading to v1.8][4] +- [Upgrading to v1.9][5] + +Before upgrading, check the [Velero compatibility matrix](https://github.com/vmware-tanzu/velero#velero-compatabilty-matrix) to make sure your version of Kubernetes is supported by the new version of Velero. + +## Instructions + +**Caution:** From Velero v1.10, except for using restic to do file-system level backup and restore, kopia is also been integrated, so there would be a little bit of difference when upgrading to v1.10 from a version lower than v1.10.0. + +1. Install the Velero v1.10 command-line interface (CLI) by following the [instructions here][0]. + + Verify that you've properly installed it by running: + + ```bash + velero version --client-only + ``` + + You should see the following output: + + ```bash + Client: + Version: v1.10.0 + Git commit: <git SHA> + ``` + +1. Update the Velero custom resource definitions (CRDs) to include schema changes across all CRDs that are at the core of the new features in this release: + + ```bash + velero install --crds-only --dry-run -o yaml | kubectl apply -f - + ``` + + **NOTE:** Since velero v1.10.0 only v1 CRD will be supported during installation, therefore, the v1.10.0 will only work on kubernetes version >= v1.16 + +1. Update the container image and objects fields used by the Velero deployment and, optionally, the restic daemon set: + + ```bash + # uploader_type value could be restic or kopia + kubectl get deploy -n velero -ojson \ + | sed "s#\"image\"\: \"velero\/velero\:v[0-9]*.[0-9]*.[0-9]\"#\"image\"\: \"velero\/velero\:v1.10.0\"#g" \ + | sed "s#\"server\",#\"server\",\"--uploader-type=$uploader_type\",#g" \ + | sed "s#default-volumes-to-restic#default-volumes-to-fs-backup#g" \ + | sed "s#default-restic-prune-frequency#default-repo-maintain-frequency#g" \ + | sed "s#restic-timeout#fs-backup-timeout#g" \ + | kubectl apply -f - + + # optional, if using the restic daemon set + dsjson=$(kubectl get ds -n velero -ojson) + kubectl delete ds -n velero --all --force --grace-period 0 + echo $dsjson | sed "s#\"image\"\: \"velero\/velero\:v[0-9]*.[0-9]*.[0-9]\"#\"image\"\: \"velero\/velero\:v1.10.0\"#g" \ + | sed "s#\"name\"\: \"restic\"#\"name\"\: \"node-agent\"#g" \ + | sed "s#\[ \"restic\",#\[ \"node-agent\",#g" \ + | kubectl apply -f - + ``` + +1. Confirm that the deployment is up and running with the correct version by running: + + ```bash + velero version + ``` + + You should see the following output: + + ```bash + Client: + Version: v1.10.0 + Git commit: <git SHA> + + Server: + Version: v1.10.0 + ``` +## Notes +If upgraded from v1.9.x, there still remains some resources left over in the cluster and never used in v1.10.x, which could be deleted through kubectl and it is based on your desire: + + - resticrepository CRD and related CRs + - velero-restic-credentials secret in velero install namespace + + +[0]: basic-install.md#install-the-cli +[1]: https://velero.io/docs/v1.5/upgrade-to-1.5 +[2]: https://velero.io/docs/v1.6/upgrade-to-1.6 +[3]: https://velero.io/docs/v1.7/upgrade-to-1.7 +[4]: https://velero.io/docs/v1.8/upgrade-to-1.8 +[5]: https://velero.io/docs/v1.9/upgrade-to-1.9 \ No newline at end of file diff --git a/site/data/docs/main-toc.yml b/site/data/docs/main-toc.yml index 5442c62cc7..f8be3b9782 100644 --- a/site/data/docs/main-toc.yml +++ b/site/data/docs/main-toc.yml @@ -13,8 +13,8 @@ toc: url: /basic-install - page: Customize Installation url: /customize-installation - - page: Upgrade to 1.9 - url: /upgrade-to-1.9 + - page: Upgrade to 1.10 + url: /upgrade-to-1.10 - page: Supported providers url: /supported-providers - page: Evaluation install diff --git a/test/e2e/Makefile b/test/e2e/Makefile index 1ac44ddbdc..2088317c9a 100644 --- a/test/e2e/Makefile +++ b/test/e2e/Makefile @@ -55,7 +55,7 @@ VELERO_VERSION ?= $(VERSION) PLUGINS ?= RESTORE_HELPER_IMAGE ?= #Released version only -UPGRADE_FROM_VELERO_VERSION ?= v1.7.1,v1.8.1 +UPGRADE_FROM_VELERO_VERSION ?= v1.8.1,v1.9.2 # UPGRADE_FROM_VELERO_CLI can has the same format(a list divided by comma) with UPGRADE_FROM_VELERO_VERSION # Upgrade tests will be executed sequently according to the list by UPGRADE_FROM_VELERO_VERSION # So although length of UPGRADE_FROM_VELERO_CLI list is not equal with UPGRADE_FROM_VELERO_VERSION diff --git a/test/e2e/backups/deletion.go b/test/e2e/backups/deletion.go index 274df9d200..db1313c5ad 100644 --- a/test/e2e/backups/deletion.go +++ b/test/e2e/backups/deletion.go @@ -86,7 +86,7 @@ func backup_deletion_test(useVolumeSnapshots bool) { } // runUpgradeTests runs upgrade test on the provider by kibishii. -func runBackupDeletionTests(client TestClient, veleroCfg VerleroConfig, backupName, backupLocation string, +func runBackupDeletionTests(client TestClient, veleroCfg VeleroConfig, backupName, backupLocation string, useVolumeSnapshots bool, kibishiiDirectory string) error { oneHourTimeout, _ := context.WithTimeout(context.Background(), time.Minute*60) veleroCLI := VeleroCfg.VeleroCLI diff --git a/test/e2e/types.go b/test/e2e/types.go index 95376e04a0..c2eb7a9501 100644 --- a/test/e2e/types.go +++ b/test/e2e/types.go @@ -26,9 +26,9 @@ import ( var UUIDgen uuid.UUID -var VeleroCfg VerleroConfig +var VeleroCfg VeleroConfig -type VerleroConfig struct { +type VeleroConfig struct { VeleroCLI string VeleroImage string VeleroVersion string diff --git a/test/e2e/upgrade/upgrade.go b/test/e2e/upgrade/upgrade.go index d91cae4395..ac627fae48 100644 --- a/test/e2e/upgrade/upgrade.go +++ b/test/e2e/upgrade/upgrade.go @@ -29,6 +29,7 @@ import ( . "github.com/vmware-tanzu/velero/test/e2e" . "github.com/vmware-tanzu/velero/test/e2e/util/k8s" . "github.com/vmware-tanzu/velero/test/e2e/util/kibishii" + . "github.com/vmware-tanzu/velero/test/e2e/util/providers" . "github.com/vmware-tanzu/velero/test/e2e/util/velero" ) @@ -91,7 +92,6 @@ func BackupUpgradeRestoreTest(useVolumeSnapshots bool, veleroCLI2Version VeleroC UUIDgen, err = uuid.NewRandom() Expect(err).To(Succeed()) oneHourTimeout, _ := context.WithTimeout(context.Background(), time.Minute*60) - if veleroCLI2Version.VeleroCLI == "" { //Assume tag of velero server image is identical to velero CLI version //Download velero CLI if it's empty according to velero CLI version @@ -200,7 +200,8 @@ func BackupUpgradeRestoreTest(useVolumeSnapshots bool, veleroCLI2Version VeleroC tmpCfg.GCFrequency = "" tmpCfg.UseNodeAgent = !useVolumeSnapshots tmpCfg.UseRestic = false - Expect(VeleroInstall(context.Background(), &tmpCfg, useVolumeSnapshots)).To(Succeed()) + tmpCfg.UploaderType = "restic" + Expect(VeleroUpgrade(context.Background(), tmpCfg)).To(Succeed()) Expect(CheckVeleroVersion(context.Background(), tmpCfg.VeleroCLI, tmpCfg.VeleroVersion)).To(Succeed()) }) diff --git a/test/e2e/util/common/common.go b/test/e2e/util/common/common.go index f7a43fc71b..95aac2f209 100644 --- a/test/e2e/util/common/common.go +++ b/test/e2e/util/common/common.go @@ -13,33 +13,36 @@ type OsCommandLine struct { Args []string } -func GetListBy2Pipes(ctx context.Context, cmdline1, cmdline2, cmdline3 OsCommandLine) ([]string, error) { - var b2 bytes.Buffer - var errVelero, errAwk error - - c1 := exec.CommandContext(ctx, cmdline1.Cmd, cmdline1.Args...) - c2 := exec.Command(cmdline2.Cmd, cmdline2.Args...) - c3 := exec.Command(cmdline3.Cmd, cmdline3.Args...) - fmt.Println(c1) - fmt.Println(c2) - fmt.Println(c3) - c2.Stdin, errVelero = c1.StdoutPipe() - if errVelero != nil { - return nil, errVelero +func GetListByCmdPipes(ctx context.Context, cmdlines []*OsCommandLine) ([]string, error) { + var buf bytes.Buffer + var err error + var cmds []*exec.Cmd + for _, cmdline := range cmdlines { + cmd := exec.Command(cmdline.Cmd, cmdline.Args...) + cmds = append(cmds, cmd) + fmt.Println(cmd) + } + for i := 0; i < len(cmds); i++ { + if i == len(cmds)-1 { + break + } + cmds[i+1].Stdin, err = cmds[i].StdoutPipe() + if err != nil { + return nil, err + } + } + cmds[len(cmds)-1].Stdout = &buf + for i := len(cmds) - 1; i >= 0; i-- { + _ = cmds[i].Start() + if i == 0 { + _ = cmds[i].Run() + } } - c3.Stdin, errAwk = c2.StdoutPipe() - if errAwk != nil { - return nil, errAwk + for i := 1; i < len(cmds); i++ { + _ = cmds[i].Wait() } - c3.Stdout = &b2 - _ = c3.Start() - _ = c2.Start() - _ = c1.Run() - _ = c2.Wait() - _ = c3.Wait() - //fmt.Println(&b2) - scanner := bufio.NewScanner(&b2) + scanner := bufio.NewScanner(&buf) var ret []string for scanner.Scan() { fmt.Printf("line: %s\n", scanner.Text()) diff --git a/test/e2e/util/k8s/common.go b/test/e2e/util/k8s/common.go index 55c3721604..7b2d75edb3 100644 --- a/test/e2e/util/k8s/common.go +++ b/test/e2e/util/k8s/common.go @@ -31,7 +31,7 @@ import ( "github.com/vmware-tanzu/velero/pkg/builder" veleroexec "github.com/vmware-tanzu/velero/pkg/util/exec" - common "github.com/vmware-tanzu/velero/test/e2e/util/common" + "github.com/vmware-tanzu/velero/test/e2e/util/common" ) // ensureClusterExists returns whether or not a kubernetes cluster exists for tests to be run on. @@ -86,42 +86,52 @@ func GetPvcByPodName(ctx context.Context, namespace, podName string) ([]string, // Example: // NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE // kibishii-data-kibishii-deployment-0 Bound pvc-94b9fdf2-c30f-4a7b-87bf-06eadca0d5b6 1Gi RWO kibishii-storage-class 115s - CmdLine1 := &common.OsCommandLine{ + cmds := []*common.OsCommandLine{} + cmd := &common.OsCommandLine{ Cmd: "kubectl", Args: []string{"get", "pvc", "-n", namespace}, } - CmdLine2 := &common.OsCommandLine{ + cmds = append(cmds, cmd) + + cmd = &common.OsCommandLine{ Cmd: "grep", Args: []string{podName}, } - CmdLine3 := &common.OsCommandLine{ + cmds = append(cmds, cmd) + + cmd = &common.OsCommandLine{ Cmd: "awk", Args: []string{"{print $1}"}, } + cmds = append(cmds, cmd) - return common.GetListBy2Pipes(ctx, *CmdLine1, *CmdLine2, *CmdLine3) + return common.GetListByCmdPipes(ctx, cmds) } func GetPvByPvc(ctx context.Context, namespace, pvc string) ([]string, error) { // Example: // NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE // pvc-3f784366-58db-40b2-8fec-77307807e74b 1Gi RWO Delete Bound bsl-deletion/kibishii-data-kibishii-deployment-0 kibishii-storage-class 6h41m - CmdLine1 := &common.OsCommandLine{ + cmds := []*common.OsCommandLine{} + cmd := &common.OsCommandLine{ Cmd: "kubectl", Args: []string{"get", "pv"}, } + cmds = append(cmds, cmd) - CmdLine2 := &common.OsCommandLine{ + cmd = &common.OsCommandLine{ Cmd: "grep", Args: []string{namespace + "/" + pvc}, } + cmds = append(cmds, cmd) - CmdLine3 := &common.OsCommandLine{ + cmd = &common.OsCommandLine{ Cmd: "awk", Args: []string{"{print $1}"}, } + cmds = append(cmds, cmd) - return common.GetListBy2Pipes(ctx, *CmdLine1, *CmdLine2, *CmdLine3) + return common.GetListByCmdPipes(ctx, cmds) } func CRDShouldExist(ctx context.Context, name string) error { @@ -145,22 +155,26 @@ func CRDCountShouldBe(ctx context.Context, name string, count int) error { } func GetCRD(ctx context.Context, name string) ([]string, error) { - CmdLine1 := &common.OsCommandLine{ + cmds := []*common.OsCommandLine{} + cmd := &common.OsCommandLine{ Cmd: "kubectl", Args: []string{"get", "crd"}, } + cmds = append(cmds, cmd) - CmdLine2 := &common.OsCommandLine{ + cmd = &common.OsCommandLine{ Cmd: "grep", Args: []string{name}, } + cmds = append(cmds, cmd) - CmdLine3 := &common.OsCommandLine{ + cmd = &common.OsCommandLine{ Cmd: "awk", Args: []string{"{print $1}"}, } + cmds = append(cmds, cmd) - return common.GetListBy2Pipes(ctx, *CmdLine1, *CmdLine2, *CmdLine3) + return common.GetListByCmdPipes(ctx, cmds) } func AddLabelToPv(ctx context.Context, pv, label string) error { @@ -282,3 +296,34 @@ func ReadFileFromPodVolume(ctx context.Context, namespace, podName, volume, file fmt.Print(stderr) return stdout, err } + +func KubectlGetInfo(cmdName string, arg []string) { + cmd := exec.CommandContext(context.Background(), cmdName, arg...) + fmt.Printf("Kubectl exec cmd =%v\n", cmd) + stdout, stderr, err := veleroexec.RunCommand(cmd) + fmt.Println(stdout) + if err != nil { + fmt.Println(stderr) + fmt.Println(err) + } +} + +func KubectlGetDsJson(veleroNamespace string) (string, error) { + arg := []string{"get", "ds", "-n", veleroNamespace, "-ojson"} + cmd := exec.CommandContext(context.Background(), "kubectl", arg...) + fmt.Printf("Kubectl exec cmd =%v\n", cmd) + stdout, stderr, err := veleroexec.RunCommand(cmd) + fmt.Println(stdout) + if err != nil { + fmt.Println(stderr) + fmt.Println(err) + return "", err + } + return stdout, nil +} + +func DeleteVeleroDs(ctx context.Context) error { + args := []string{"delete", "ds", "-n", "velero", "--all", "--force", "--grace-period", "0"} + fmt.Println(args) + return exec.CommandContext(ctx, "kubectl", args...).Run() +} diff --git a/test/e2e/util/kibishii/kibishii_utils.go b/test/e2e/util/kibishii/kibishii_utils.go index 016fa072de..c09ac7748c 100644 --- a/test/e2e/util/kibishii/kibishii_utils.go +++ b/test/e2e/util/kibishii/kibishii_utils.go @@ -51,7 +51,7 @@ var DefaultKibishiiData = &KibishiiData{2, 10, 10, 1024, 1024, 0, 2} var KibishiiPodNameList = []string{"kibishii-deployment-0", "kibishii-deployment-1"} // RunKibishiiTests runs kibishii tests on the provider. -func RunKibishiiTests(client TestClient, veleroCfg VerleroConfig, backupName, restoreName, backupLocation, kibishiiNamespace string, +func RunKibishiiTests(client TestClient, veleroCfg VeleroConfig, backupName, restoreName, backupLocation, kibishiiNamespace string, useVolumeSnapshots bool) error { oneHourTimeout, _ := context.WithTimeout(context.Background(), time.Minute*60) veleroCLI := VeleroCfg.VeleroCLI @@ -174,7 +174,8 @@ func installKibishii(ctx context.Context, namespace string, cloudPlatform, veler } func generateData(ctx context.Context, namespace string, kibishiiData *KibishiiData) error { - kibishiiGenerateCmd := exec.CommandContext(ctx, "kubectl", "exec", "-n", namespace, "jump-pad", "--", + timeout, _ := context.WithTimeout(context.Background(), time.Minute*10) + kibishiiGenerateCmd := exec.CommandContext(timeout, "kubectl", "exec", "-n", namespace, "jump-pad", "--", "/usr/local/bin/generate.sh", strconv.Itoa(kibishiiData.Levels), strconv.Itoa(kibishiiData.DirsPerLevel), strconv.Itoa(kibishiiData.FilesPerLevel), strconv.Itoa(kibishiiData.FileLength), strconv.Itoa(kibishiiData.BlockSize), strconv.Itoa(kibishiiData.PassNum), strconv.Itoa(kibishiiData.ExpectedNodes)) @@ -189,7 +190,7 @@ func generateData(ctx context.Context, namespace string, kibishiiData *KibishiiD } func verifyData(ctx context.Context, namespace string, kibishiiData *KibishiiData) error { - timeout, _ := context.WithTimeout(context.Background(), time.Minute*5) + timeout, _ := context.WithTimeout(context.Background(), time.Minute*10) kibishiiVerifyCmd := exec.CommandContext(timeout, "kubectl", "exec", "-n", namespace, "jump-pad", "--", "/usr/local/bin/verify.sh", strconv.Itoa(kibishiiData.Levels), strconv.Itoa(kibishiiData.DirsPerLevel), strconv.Itoa(kibishiiData.FilesPerLevel), strconv.Itoa(kibishiiData.FileLength), diff --git a/test/e2e/util/velero/install.go b/test/e2e/util/velero/install.go index 14c6e622b0..2c8938976f 100644 --- a/test/e2e/util/velero/install.go +++ b/test/e2e/util/velero/install.go @@ -49,7 +49,7 @@ type installOptions struct { RestoreHelperImage string } -func VeleroInstall(ctx context.Context, veleroCfg *VerleroConfig, useVolumeSnapshots bool) error { +func VeleroInstall(ctx context.Context, veleroCfg *VeleroConfig, useVolumeSnapshots bool) error { if veleroCfg.CloudProvider != "kind" { if veleroCfg.ObjectStoreProvider != "" { return errors.New("For cloud platforms, object store plugin cannot be overridden") // Can't set an object store provider that is different than your cloud @@ -103,6 +103,7 @@ func VeleroInstall(ctx context.Context, veleroCfg *VerleroConfig, useVolumeSnaps RestoreHelperImage: veleroCfg.RestoreHelperImage, }) if err != nil { + RunDebug(context.Background(), veleroCfg.VeleroCLI, veleroCfg.VeleroNamespace, "", "") return errors.WithMessagef(err, "Failed to install Velero in the cluster") } diff --git a/test/e2e/util/velero/velero_utils.go b/test/e2e/util/velero/velero_utils.go index ded37dd46c..37c49feb76 100644 --- a/test/e2e/util/velero/velero_utils.go +++ b/test/e2e/util/velero/velero_utils.go @@ -96,6 +96,13 @@ var pluginsMatrix = map[string]map[string][]string{ "gcp": {"velero/velero-plugin-for-gcp:v1.5.0"}, "azure-csi": {"velero/velero-plugin-for-microsoft-azure:v1.5.0", "velero/velero-plugin-for-csi:v0.3.0"}, }, + "v1.10": { + "aws": {"velero/velero-plugin-for-aws:v1.6.0"}, + "azure": {"velero/velero-plugin-for-microsoft-azure:v1.6.0"}, + "vsphere": {"velero/velero-plugin-for-aws:v1.6.0", "vsphereveleroplugin/velero-plugin-for-vsphere:v1.4.1"}, + "gcp": {"velero/velero-plugin-for-gcp:v1.6.0"}, + "azure-csi": {"velero/velero-plugin-for-microsoft-azure:v1.6.0", "velero/velero-plugin-for-csi:v0.4.0"}, + }, "main": { "aws": {"velero/velero-plugin-for-aws:main"}, "azure": {"velero/velero-plugin-for-microsoft-azure:main"}, @@ -706,23 +713,30 @@ func CheckVeleroVersion(ctx context.Context, veleroCLI string, expectedVer strin } func InstallVeleroCLI(version string) (string, error) { + var tempVeleroCliDir string name := "velero-" + version + "-" + runtime.GOOS + "-" + runtime.GOARCH postfix := ".tar.gz" tarball := name + postfix - tempFile, err := getVeleroCliTarball("https://github.com/vmware-tanzu/velero/releases/download/" + version + "/" + tarball) - if err != nil { - return "", errors.WithMessagef(err, "failed to get Velero CLI tarball") - } - tempVeleroCliDir, err := ioutil.TempDir("", "velero-test") - if err != nil { - return "", errors.WithMessagef(err, "failed to create temp dir for tarball extraction") - } + err := wait.PollImmediate(time.Second*5, time.Minute*5, func() (bool, error) { + tempFile, err := getVeleroCliTarball("https://github.com/vmware-tanzu/velero/releases/download/" + version + "/" + tarball) + if err != nil { + return false, errors.WithMessagef(err, "failed to get Velero CLI tarball") + } + tempVeleroCliDir, err = ioutil.TempDir("", "velero-test") + if err != nil { + return false, errors.WithMessagef(err, "failed to create temp dir for tarball extraction") + } - cmd := exec.Command("tar", "-xvf", tempFile.Name(), "-C", tempVeleroCliDir) - defer os.Remove(tempFile.Name()) + cmd := exec.Command("tar", "-xvf", tempFile.Name(), "-C", tempVeleroCliDir) + defer os.Remove(tempFile.Name()) - if _, err := cmd.Output(); err != nil { - return "", errors.WithMessagef(err, "failed to extract file from velero CLI tarball") + if _, err := cmd.Output(); err != nil { + return false, errors.WithMessagef(err, "failed to extract file from velero CLI tarball") + } + return true, nil + }) + if err != nil { + return "", errors.WithMessagef(err, "failed to install velero CLI") } return tempVeleroCliDir + "/" + name + "/velero", nil } @@ -866,22 +880,27 @@ func GetBackupsFromBsl(ctx context.Context, veleroCLI, bslName string) ([]string if strings.TrimSpace(bslName) != "" { args1 = append(args1, "-l", "velero.io/storage-location="+bslName) } - CmdLine1 := &common.OsCommandLine{ + cmds := []*common.OsCommandLine{} + + cmd := &common.OsCommandLine{ Cmd: veleroCLI, Args: args1, } + cmds = append(cmds, cmd) - CmdLine2 := &common.OsCommandLine{ + cmd = &common.OsCommandLine{ Cmd: "awk", Args: []string{"{print $1}"}, } + cmds = append(cmds, cmd) - CmdLine3 := &common.OsCommandLine{ + cmd = &common.OsCommandLine{ Cmd: "tail", Args: []string{"-n", "+2"}, } + cmds = append(cmds, cmd) - return common.GetListBy2Pipes(ctx, *CmdLine1, *CmdLine2, *CmdLine3) + return common.GetListByCmdPipes(ctx, cmds) } func GetScheduledBackupsCreationTime(ctx context.Context, veleroCLI, bslName, scheduleName string) ([]string, error) { @@ -903,22 +922,27 @@ func GetBackupsCreationTime(ctx context.Context, veleroCLI, bslName string) ([]s if strings.TrimSpace(bslName) != "" { args1 = append(args1, "-l", "velero.io/storage-location="+bslName) } - CmdLine1 := &common.OsCommandLine{ + cmds := []*common.OsCommandLine{} + + cmd := &common.OsCommandLine{ Cmd: veleroCLI, Args: args1, } + cmds = append(cmds, cmd) - CmdLine2 := &common.OsCommandLine{ + cmd = &common.OsCommandLine{ Cmd: "awk", Args: []string{"{print " + createdTime + "}"}, } + cmds = append(cmds, cmd) - CmdLine3 := &common.OsCommandLine{ + cmd = &common.OsCommandLine{ Cmd: "tail", Args: []string{"-n", "+2"}, } + cmds = append(cmds, cmd) - return common.GetListBy2Pipes(ctx, *CmdLine1, *CmdLine2, *CmdLine3) + return common.GetListByCmdPipes(ctx, cmds) } func GetAllBackups(ctx context.Context, veleroCLI string) ([]string, error) { @@ -982,25 +1006,29 @@ func BackupRepositoriesCountShouldBe(ctx context.Context, veleroNamespace, targe } func GetResticRepositories(ctx context.Context, veleroNamespace, targetNamespace string) ([]string, error) { - CmdLine1 := &common.OsCommandLine{ + cmds := []*common.OsCommandLine{} + cmd := &common.OsCommandLine{ Cmd: "kubectl", Args: []string{"get", "-n", veleroNamespace, "BackupRepositories"}, } + cmds = append(cmds, cmd) - CmdLine2 := &common.OsCommandLine{ + cmd = &common.OsCommandLine{ Cmd: "grep", Args: []string{targetNamespace}, } + cmds = append(cmds, cmd) - CmdLine3 := &common.OsCommandLine{ + cmd = &common.OsCommandLine{ Cmd: "awk", Args: []string{"{print $1}"}, } + cmds = append(cmds, cmd) - return common.GetListBy2Pipes(ctx, *CmdLine1, *CmdLine2, *CmdLine3) + return common.GetListByCmdPipes(ctx, cmds) } -func GetSnapshotCheckPoint(client TestClient, VeleroCfg VerleroConfig, expectCount int, namespaceBackedUp, backupName string, kibishiiPodNameList []string) (SnapshotCheckPoint, error) { +func GetSnapshotCheckPoint(client TestClient, VeleroCfg VeleroConfig, expectCount int, namespaceBackedUp, backupName string, kibishiiPodNameList []string) (SnapshotCheckPoint, error) { var snapshotCheckPoint SnapshotCheckPoint snapshotCheckPoint.ExpectCount = expectCount @@ -1081,3 +1109,143 @@ func GetSchedule(ctx context.Context, veleroNamespace, scheduleName string) (str } return stdout, err } + +func VeleroUpgrade(ctx context.Context, veleroCfg VeleroConfig) error { + crd, err := ApplyCRDs(ctx, veleroCfg.VeleroCLI) + if err != nil { + return errors.Wrap(err, "Fail to Apply CRDs") + } + fmt.Println(crd) + deploy, err := UpdateVeleroDeployment(ctx, veleroCfg) + if err != nil { + return errors.Wrap(err, "Fail to update Velero deployment") + } + fmt.Println(deploy) + if veleroCfg.UseNodeAgent { + dsjson, err := KubectlGetDsJson(veleroCfg.VeleroNamespace) + if err != nil { + return errors.Wrap(err, "Fail to update Velero deployment") + } + + err = DeleteVeleroDs(ctx) + if err != nil { + return errors.Wrap(err, "Fail to delete Velero ds") + } + update, err := UpdateNodeAgent(ctx, veleroCfg, dsjson) + fmt.Println(update) + if err != nil { + return errors.Wrap(err, "Fail to update node agent") + } + } + return waitVeleroReady(ctx, veleroCfg.VeleroNamespace, veleroCfg.UseNodeAgent) +} +func ApplyCRDs(ctx context.Context, veleroCLI string) ([]string, error) { + cmds := []*common.OsCommandLine{} + + cmd := &common.OsCommandLine{ + Cmd: veleroCLI, + Args: []string{"install", "--crds-only", "--dry-run", "-o", "yaml"}, + } + cmds = append(cmds, cmd) + + cmd = &common.OsCommandLine{ + Cmd: "kubectl", + Args: []string{"apply", "-f", "-"}, + } + cmds = append(cmds, cmd) + return common.GetListByCmdPipes(ctx, cmds) +} + +func UpdateVeleroDeployment(ctx context.Context, veleroCfg VeleroConfig) ([]string, error) { + cmds := []*common.OsCommandLine{} + + cmd := &common.OsCommandLine{ + Cmd: "kubectl", + Args: []string{"get", "deploy", "-n", veleroCfg.VeleroNamespace, "-ojson"}, + } + cmds = append(cmds, cmd) + var args string + if veleroCfg.CloudProvider == "vsphere" { + args = fmt.Sprintf("s#\\\"image\\\"\\: \\\"velero\\/velero\\:v[0-9]*.[0-9]*.[0-9]\\\"#\\\"image\\\"\\: \\\"harbor-repo.vmware.com\\/velero_ci\\/velero\\:%s\\\"#g", veleroCfg.VeleroVersion) + } else { + args = fmt.Sprintf("s#\\\"image\\\"\\: \\\"velero\\/velero\\:v[0-9]*.[0-9]*.[0-9]\\\"#\\\"image\\\"\\: \\\"velero\\/velero\\:%s\\\"#g", veleroCfg.VeleroVersion) + } + cmd = &common.OsCommandLine{ + Cmd: "sed", + Args: []string{args}, + } + cmds = append(cmds, cmd) + + cmd = &common.OsCommandLine{ + Cmd: "sed", + Args: []string{fmt.Sprintf("s#\\\"server\\\",#\\\"server\\\",\\\"--uploader-type=%s\\\",#g", veleroCfg.UploaderType)}, + } + cmds = append(cmds, cmd) + + cmd = &common.OsCommandLine{ + Cmd: "sed", + Args: []string{"s#default-volumes-to-restic#default-volumes-to-fs-backup#g"}, + } + cmds = append(cmds, cmd) + + cmd = &common.OsCommandLine{ + Cmd: "sed", + Args: []string{"s#default-restic-prune-frequency#default-repo-maintain-frequency#g"}, + } + cmds = append(cmds, cmd) + + cmd = &common.OsCommandLine{ + Cmd: "sed", + Args: []string{"s#restic-timeout#fs-backup-timeout#g"}, + } + cmds = append(cmds, cmd) + + cmd = &common.OsCommandLine{ + Cmd: "kubectl", + Args: []string{"apply", "-f", "-"}, + } + cmds = append(cmds, cmd) + + return common.GetListByCmdPipes(ctx, cmds) +} + +func UpdateNodeAgent(ctx context.Context, veleroCfg VeleroConfig, dsjson string) ([]string, error) { + cmds := []*common.OsCommandLine{} + + cmd := &common.OsCommandLine{ + Cmd: "echo", + Args: []string{dsjson}, + } + cmds = append(cmds, cmd) + var args string + if veleroCfg.CloudProvider == "vsphere" { + args = fmt.Sprintf("s#\\\"image\\\"\\: \\\"velero\\/velero\\:v[0-9]*.[0-9]*.[0-9]\\\"#\\\"image\\\"\\: \\\"harbor-repo.vmware.com\\/velero_ci\\/velero\\:%s\\\"#g", veleroCfg.VeleroVersion) + } else { + args = fmt.Sprintf("s#\\\"image\\\"\\: \\\"velero\\/velero\\:v[0-9]*.[0-9]*.[0-9]\\\"#\\\"image\\\"\\: \\\"velero\\/velero\\:%s\\\"#g", veleroCfg.VeleroVersion) + } + cmd = &common.OsCommandLine{ + Cmd: "sed", + Args: []string{args}, + } + cmds = append(cmds, cmd) + + cmd = &common.OsCommandLine{ + Cmd: "sed", + Args: []string{"s#\\\"name\\\"\\: \\\"restic\\\"#\\\"name\\\"\\: \\\"node-agent\\\"#g"}, + } + cmds = append(cmds, cmd) + + cmd = &common.OsCommandLine{ + Cmd: "sed", + Args: []string{"s#\\\"restic\\\",#\\\"node-agent\\\",#g"}, + } + cmds = append(cmds, cmd) + + cmd = &common.OsCommandLine{ + Cmd: "kubectl", + Args: []string{"create", "-f", "-"}, + } + cmds = append(cmds, cmd) + + return common.GetListByCmdPipes(ctx, cmds) +}