From fcedcc39c0ec43177feae333274bb22eac66c7f2 Mon Sep 17 00:00:00 2001 From: JGAntunes Date: Fri, 20 Dec 2024 19:43:51 +0000 Subject: [PATCH 1/5] chore(velero): bump velero client to latest 1.15.0 --- go.mod | 12 +-- go.sum | 49 +++--------- pkg/handlers/handlers.go | 1 - pkg/handlers/snapshot_logs.go | 1 - pkg/informers/informers.go | 1 - pkg/kotsadm/minio.go | 1 - pkg/kotsadmsnapshot/backup.go | 29 +++---- pkg/kotsadmsnapshot/backup_test.go | 2 - pkg/kotsadmsnapshot/k8sclient/k8sclient.go | 58 ++++++++++---- pkg/kotsadmsnapshot/restore.go | 1 - pkg/kotsadmsnapshot/snapshot.go | 4 +- .../veleroclient/veleroclient.go | 49 ------------ pkg/reporting/app.go | 1 - pkg/snapshot/backup.go | 36 ++++----- pkg/snapshot/filesystem_lvp.go | 10 +-- pkg/snapshot/restore.go | 45 +++++------ pkg/snapshot/snapshot.go | 1 - pkg/snapshot/store.go | 76 ++++++++----------- pkg/snapshot/store_test.go | 14 ++-- pkg/snapshot/velero.go | 22 +++--- pkg/store/kotsstore/kots_store.go | 1 - pkg/upgradeservice/handlers/handlers.go | 1 - 22 files changed, 152 insertions(+), 263 deletions(-) delete mode 100644 pkg/kotsadmsnapshot/veleroclient/veleroclient.go diff --git a/go.mod b/go.mod index 2dc4e8a792..d411ddaad2 100644 --- a/go.mod +++ b/go.mod @@ -67,7 +67,7 @@ require ( github.com/spf13/viper v1.19.0 github.com/stretchr/testify v1.10.0 github.com/tj/go-spin v1.1.0 - github.com/vmware-tanzu/velero v1.14.1 + github.com/vmware-tanzu/velero v1.15.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.27.0 golang.org/x/crypto v0.31.0 @@ -398,6 +398,7 @@ require ( cloud.google.com/go/auth v0.9.8 // indirect cloud.google.com/go/auth/oauth2adapt v0.2.4 // indirect cloud.google.com/go/monitoring v1.21.1 // indirect + github.com/Azure/go-autorest/autorest/to v0.4.0 // indirect github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.24.1 // indirect github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.48.1 // indirect github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.48.1 // indirect @@ -417,10 +418,10 @@ require ( github.com/go-viper/mapstructure/v2 v2.1.0 // indirect github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect github.com/hashicorp/logutils v1.0.0 // indirect - github.com/kopia/kopia v0.10.7 // indirect - github.com/kubernetes-csi/external-snapshotter/client/v4 v4.2.0 // indirect + github.com/kubernetes-csi/external-snapshotter/client/v7 v7.0.0 // indirect github.com/miekg/dns v1.1.62 // indirect github.com/moby/docker-image-spec v1.3.1 // indirect + github.com/onsi/ginkgo v1.11.0 // indirect github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect github.com/shopspring/decimal v1.4.0 // indirect github.com/tchap/go-patricia/v2 v2.3.1 // indirect @@ -457,8 +458,3 @@ replace ( golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce => github.com/dmacvicar/golang-x-crypto v0.0.0-20220126233154-a96af8f07497 gopkg.in/square/go-jose.v2 => gopkg.in/square/go-jose.v2 v2.2.2 ) - -// This is the only way I could get these two to play nice together -// When getting github.com/replicatedhq/troubleshoot@0.86.0 or later, it pulls in github.com/replicatedhq/velero@v1.13.1 which fails with the following error: -// ../../../../pkg/mod/github.com/vmware-tanzu/velero@v1.13.1/pkg/builder/persistent_volume_claim_builder.go:104:32: cannot use dataSourceRef (variable of type *"k8s.io/api/core/v1".TypedLocalObjectReference) as *"k8s.io/api/core/v1".TypedObjectReference value in assignment -replace github.com/vmware-tanzu/velero => github.com/vmware-tanzu/velero v1.10.3 diff --git a/go.sum b/go.sum index 19d3e579a6..5ca902914b 100644 --- a/go.sum +++ b/go.sum @@ -8,7 +8,6 @@ cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxK cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= -cloud.google.com/go v0.51.0/go.mod h1:hWtGJ6gnXH+KgDv+V0zFGDvpi07n3z8ZNj3T1RW0Gcw= cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= @@ -217,26 +216,22 @@ github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg6 github.com/Azure/go-autorest v14.2.0+incompatible h1:V5VMDjClD3GiElqLWO7mz2MxNAK/vTfRHdAubSIPRgs= github.com/Azure/go-autorest v14.2.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= -github.com/Azure/go-autorest/autorest v0.9.6/go.mod h1:/FALq9T/kS7b5J5qsQ+RSTUdAmGFqi0vUdVNNx8q630= github.com/Azure/go-autorest/autorest v0.11.29 h1:I4+HL/JDvErx2LjyzaVxllw2lRDB5/BT2Bm4g20iqYw= github.com/Azure/go-autorest/autorest v0.11.29/go.mod h1:ZtEzC4Jy2JDrZLxvWs8LrBWEBycl1hbT1eknI8MtfAs= github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= -github.com/Azure/go-autorest/autorest/adal v0.8.2/go.mod h1:ZjhuQClTqx435SRJ2iMlOxPYt3d2C/T/7TiQCVZSn3Q= github.com/Azure/go-autorest/autorest/adal v0.9.22/go.mod h1:XuAbAEUv2Tta//+voMI038TrJBqjKam0me7qR+L8Cmk= github.com/Azure/go-autorest/autorest/adal v0.9.24 h1:BHZfgGsGwdkHDyZdtQRQk1WeUdW0m2WPAwuHZwUi5i4= github.com/Azure/go-autorest/autorest/adal v0.9.24/go.mod h1:7T1+g0PYFmACYW5LlG2fcoPiPlFHjClyRGL7dRlP5c8= github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= -github.com/Azure/go-autorest/autorest/date v0.2.0/go.mod h1:vcORJHLJEh643/Ioh9+vPmf1Ij9AEBM5FuBIXLmIy0g= github.com/Azure/go-autorest/autorest/date v0.3.0 h1:7gUk1U5M/CQbp9WoqinNzJar+8KY+LPI6wiWrP/myHw= github.com/Azure/go-autorest/autorest/date v0.3.0/go.mod h1:BI0uouVdmngYNUzGWeSYnokU+TrmwEsOqdt8Y6sso74= github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= -github.com/Azure/go-autorest/autorest/mocks v0.3.0/go.mod h1:a8FDP3DYzQ4RYfVAxAN3SVSiiO77gL2j2ronKKP0syM= github.com/Azure/go-autorest/autorest/mocks v0.4.1/go.mod h1:LTp+uSrOhSkaKrUy935gNZuuIPPVsHlr9DSOxSayd+k= github.com/Azure/go-autorest/autorest/mocks v0.4.2 h1:PGN4EDXnuQbojHbU0UWoNvmu9AGVwYHG9/fkDYhtAfw= github.com/Azure/go-autorest/autorest/mocks v0.4.2/go.mod h1:Vy7OitM9Kei0i1Oj+LvyAWMXJHeKH1MVlzFugfVrmyU= -github.com/Azure/go-autorest/autorest/to v0.3.0 h1:zebkZaadz7+wIQYgC7GXaz3Wb28yKYfVkkBKwc38VF8= -github.com/Azure/go-autorest/autorest/to v0.3.0/go.mod h1:MgwOyqaIuKdG4TL/2ywSsIWKAfJfgHDo8ObuUk3t5sA= +github.com/Azure/go-autorest/autorest/to v0.4.0 h1:oXVqrxakqqV1UZdSazDOPOLvOIz+XA683u8EctwboHk= +github.com/Azure/go-autorest/autorest/to v0.4.0/go.mod h1:fE8iZBn7LQR7zH/9XU2NcPR4o9jEImooCeWJcYV/zLE= github.com/Azure/go-autorest/autorest/validation v0.3.1 h1:AgyqjAd94fwNAoTjl/WQXg4VvFeRFpO+UhNyRXqF1ac= github.com/Azure/go-autorest/autorest/validation v0.3.1/go.mod h1:yhLgjC0Wda5DYXl6JAsWyUe4KVNffhoDhG0zVzUMo3E= github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= @@ -532,7 +527,6 @@ github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25Kn github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= -github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a h1:mATvB/9r/3gvcejNsXKSkQ6lcIaNec2nyfOdlTBR2lU= github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM= github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= @@ -557,7 +551,6 @@ github.com/envoyproxy/protoc-gen-validate v1.1.0 h1:tntQDh69XqOCOZsDz0lVJQez/2L6 github.com/envoyproxy/protoc-gen-validate v1.1.0/go.mod h1:sXRDRVmzEbkM7CVcM06s9shE/m23dg3wzjl0UWqJ2q4= github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch v4.5.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= -github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch v5.9.0+incompatible h1:fBXyNpNMuTTDdquAq/uisOr2lShz4oaXpDTX2bLe7ls= github.com/evanphx/json-patch v5.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch/v5 v5.9.0 h1:kcBlZQbplgElYIlo/n1hJbls2z/1awpXxpRi0/FOJfg= @@ -577,7 +570,6 @@ github.com/foxcpp/go-mockdns v1.1.0/go.mod h1:IhLeSFGed3mJIAXPH2aiRQB+kqz7oqu8ld github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= 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/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E= @@ -619,7 +611,6 @@ github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= -github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= @@ -731,7 +722,6 @@ github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRx github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= -github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= 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 v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= @@ -845,7 +835,6 @@ github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= @@ -969,6 +958,7 @@ github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO github.com/hasura/go-graphql-client v0.8.1/go.mod h1:NVifIwv+YFIUYGLQ7SM2/vBbzS/9rFP4vmIf/vf/zXM= github.com/heroku/docker-registry-client v0.0.0-20190909225348-afc9e1acc3d5 h1:6ZR6HQ+P9ZUwHlYq+bU7e9wqAImxKUguq8fp2gZSgCo= github.com/heroku/docker-registry-client v0.0.0-20190909225348-afc9e1acc3d5/go.mod h1:Yho0S7KhsnHQRCC5lDraYF1SsLMeWtf/tKdufKu3TJA= +github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huandu/xstrings v1.5.0 h1:2ag3IFq9ZDANvthTwTiqSSZLjDc+BedvHPAp5tJy2TI= github.com/huandu/xstrings v1.5.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= @@ -1096,8 +1086,6 @@ github.com/klauspost/pgzip v1.2.6 h1:8RXeL5crjEUFnR2/Sn6GJNWtSQ3Dk8pq4CL3jvdDyjU github.com/klauspost/pgzip v1.2.6/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kopia/kopia v0.10.7 h1:6s0ZIZW3Ge2ozzefddASy7CIUadp/5tF9yCDKQfAKKI= -github.com/kopia/kopia v0.10.7/go.mod h1:0d9THPD+jwomPcXvPbCdmLyX6phQVP7AqcCcDEajfNA= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= @@ -1109,8 +1097,8 @@ github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/kubernetes-csi/external-snapshotter/client/v4 v4.2.0 h1:nHHjmvjitIiyPlUHk/ofpgvBcNcawJLtf4PYHORLjAA= -github.com/kubernetes-csi/external-snapshotter/client/v4 v4.2.0/go.mod h1:YBCo4DoEeDndqvAn6eeu0vWM7QdXmHEeI9cFWplmBys= +github.com/kubernetes-csi/external-snapshotter/client/v7 v7.0.0 h1:j3YK74myEQRxR/srciTpOrm221SAvz6J5OVWbyfeXFo= +github.com/kubernetes-csi/external-snapshotter/client/v7 v7.0.0/go.mod h1:FlyYFe32mPxKEPaRXKNxfX576d1AoCzstYDoOOnyMA4= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 h1:SOEGU9fKiNWd/HOJuq6+3iTQz8KNCLtVX6idSoTLdUw= @@ -1255,8 +1243,6 @@ github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d/go.mod h1:IuKpRQcYE github.com/nwaples/rardecode v1.1.0/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0= github.com/nwaples/rardecode v1.1.2 h1:Cj0yZY6T1Zx1R7AhTbyGSALm44/Mmq+BAPc4B/p/d3M= github.com/nwaples/rardecode v1.1.2/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0= -github.com/nxadm/tail v1.4.11 h1:8feyoE3OzPrcshW5/MJ4sGESc5cqmGkGCWlco4l0bqY= -github.com/nxadm/tail v1.4.11/go.mod h1:OTaG3NK980DZzxbRq6lEuzgU+mug70nY11sMd4JXXHc= github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= @@ -1265,9 +1251,8 @@ github.com/onsi/ginkgo v1.4.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.11.0 h1:JAKSXpt1YjtLA7YpPiqO9ss6sNXEsPfSGdwN0UHqzrw= github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= -github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/ginkgo/v2 v2.22.0 h1:Yed107/8DjTr0lKCNt7Dn8yQ6ybuDRQoMGrNFKzMfHg= github.com/onsi/ginkgo/v2 v2.22.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo= github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= @@ -1551,8 +1536,8 @@ github.com/vishvananda/netlink v1.3.0/go.mod h1:i6NetklAujEcC6fK0JPjT8qSwWyO0HLn github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM= github.com/vishvananda/netns v0.0.5 h1:DfiHV+j8bA32MFM7bfEunvT8IAqQ/NzSJHtcmW5zdEY= github.com/vishvananda/netns v0.0.5/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM= -github.com/vmware-tanzu/velero v1.10.3 h1:prE24sOog/jhBt7LivY+k6NbKwU+0nl1JAbJWA91mdo= -github.com/vmware-tanzu/velero v1.10.3/go.mod h1:3/m52SOiTP/L+Qp0E6+Gk688niyVxowLCLniQbTkSPA= +github.com/vmware-tanzu/velero v1.15.0 h1:+S/lNSDwQqlROGWfmNuZnnabopGmco978COIt3AP09c= +github.com/vmware-tanzu/velero v1.15.0/go.mod h1:28VhzPJRBo91GBRkgs4Ird0fx2vCpepBWmhF+5Pn/WQ= github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= @@ -1691,7 +1676,6 @@ golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= @@ -1899,7 +1883,6 @@ golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/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-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191105231009-c1f44814a5cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1918,7 +1901,6 @@ golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200622214017-ed371f2e16b4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -2010,7 +1992,6 @@ golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxb 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= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ= golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20170915040203-e531a2a1c15f/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -2071,7 +2052,6 @@ golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWc golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200616133436-c1934b75d054/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= @@ -2344,6 +2324,7 @@ gopkg.in/cheggaaa/pb.v1 v1.0.27/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qS gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/evanphx/json-patch.v4 v4.12.0 h1:n6jtcsulIzXPJaxegRbvFNNrZDjbij7ny3gmSPG+6V4= gopkg.in/evanphx/json-patch.v4 v4.12.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M= +gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo= gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM= @@ -2393,7 +2374,6 @@ honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9 honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= k8s.io/api v0.0.0-20190918155943-95b840bb6a1f/go.mod h1:uWuOHnjmNrtQomJrvEBg0c0HRNyQ+8KTEERVsK0PW48= k8s.io/api v0.17.0/go.mod h1:npsyOePkeP0CPwyGfXDHxvypiYMJxBWAMpQxCaJ4ZxI= -k8s.io/api v0.19.0/go.mod h1:I1K45XlvTrDjmj5LoM5LuP/KYrhWbjUKT/SoPG0qTjw= k8s.io/api v0.31.3 h1:umzm5o8lFbdN/hIXbrK9oRpOproJO62CV1zqxXrLgk8= k8s.io/api v0.31.3/go.mod h1:UJrkIp9pnMOI9K2nlL6vwpxRzzEX5sWgn8kGQe92kCE= k8s.io/apiextensions-apiserver v0.0.0-20190918161926-8f644eb6e783/go.mod h1:xvae1SZB3E17UpV59AWc271W/Ph25N+bjPyR63X6tPY= @@ -2402,7 +2382,6 @@ k8s.io/apiextensions-apiserver v0.31.3 h1:+GFGj2qFiU7rGCsA5o+p/rul1OQIq6oYpQw4+u k8s.io/apiextensions-apiserver v0.31.3/go.mod h1:2DSpFhUZZJmn/cr/RweH1cEVVbzFw9YBu4T+U3mf1e4= k8s.io/apimachinery v0.0.0-20190913080033-27d36303b655/go.mod h1:nL6pwRT8NgfF8TT68DBI8uEePRt89cSvoXUVqbkWHq4= k8s.io/apimachinery v0.17.0/go.mod h1:b9qmWdKlLuU9EBh+06BtLcSf/Mu89rWL33naRxs1uZg= -k8s.io/apimachinery v0.19.0/go.mod h1:DnPGDnARWFvYa3pMHgSxtbZb7gpzzAZ1pTfaUNDVlmA= k8s.io/apimachinery v0.31.3 h1:6l0WhcYgasZ/wk9ktLq5vLaoXJJr5ts6lkaQzgeYPq4= k8s.io/apimachinery v0.31.3/go.mod h1:rsPdaZJfTfLsNJSQzNHQvYoTmxhoOEofxtOsF3rtsMo= k8s.io/apiserver v0.0.0-20190918160949-bfa5e2e684ad/go.mod h1:XPCXEwhjaFN29a8NldXA901ElnKeKLrLtREO9ZhFyhg= @@ -2413,35 +2392,28 @@ k8s.io/cli-runtime v0.31.2 h1:7FQt4C4Xnqx8V1GJqymInK0FFsoC+fAZtbLqgXYVOLQ= k8s.io/cli-runtime v0.31.2/go.mod h1:XROyicf+G7rQ6FQJMbeDV9jqxzkWXTYD6Uxd15noe0Q= k8s.io/client-go v0.0.0-20190918160344-1fbdaa4c8d90/go.mod h1:J69/JveO6XESwVgG53q3Uz5OSfgsv4uxpScmmyYOOlk= k8s.io/client-go v0.17.0/go.mod h1:TYgR6EUHs6k45hb6KWjVD6jFZvJV4gHDikv/It0xz+k= -k8s.io/client-go v0.19.0/go.mod h1:H9E/VT95blcFQnlyShFgnFT9ZnJOAceiUHM3MlRC+mU= k8s.io/client-go v0.31.3 h1:CAlZuM+PH2cm+86LOBemaJI/lQ5linJ6UFxKX/SoG+4= k8s.io/client-go v0.31.3/go.mod h1:2CgjPUTpv3fE5dNygAr2NcM8nhHzXvxB8KL5gYc3kJs= k8s.io/cluster-bootstrap v0.31.2 h1:tnycetMTbbCysYcx6AolV7DvPA/WXMnAYIl/vXIm7kM= k8s.io/cluster-bootstrap v0.31.2/go.mod h1:V4D+Zc7aJ5dcRYualA94kGN95ELRM61xegQpVN2ruY8= k8s.io/code-generator v0.0.0-20190912054826-cd179ad6a269/go.mod h1:V5BD6M4CyaN5m+VthcclXWsVcT1Hu+glwa1bi3MIsyE= k8s.io/code-generator v0.17.0/go.mod h1:DVmfPQgxQENqDIzVR2ddLXMH34qeszkKSdH/N+s+38s= -k8s.io/code-generator v0.19.0/go.mod h1:moqLn7w0t9cMs4+5CQyxnfA/HV8MF6aAVENF+WZZhgk= k8s.io/component-base v0.0.0-20190918160511-547f6c5d7090/go.mod h1:933PBGtQFJky3TEwYx4aEPZ4IxqhWh3R6DCmzqIn1hA= k8s.io/component-base v0.17.0/go.mod h1:rKuRAokNMY2nn2A6LP/MiwpoaMRHpfRnrPaUJJj1Yoc= k8s.io/component-base v0.31.3 h1:DMCXXVx546Rfvhj+3cOm2EUxhS+EyztH423j+8sOwhQ= k8s.io/component-base v0.31.3/go.mod h1:xME6BHfUOafRgT0rGVBGl7TuSg8Z9/deT7qq6w7qjIU= k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/gengo v0.0.0-20190822140433-26a664648505/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= -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/helm v2.17.0+incompatible h1:Bpn6o1wKLYqKM3+Osh8e+1/K2g/GsQJ4F4yNF2+deao= k8s.io/helm v2.17.0+incompatible/go.mod h1:LZzlS4LQBHfciFOurYBFkCMTaZ0D1l+p0teMg7TSULI= k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= k8s.io/klog v0.4.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= -k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE= -k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/kube-openapi v0.0.0-20200805222855-6aeccd4b50c6/go.mod h1:UuqjUnNftUyPE5H64/qeyjQoUZhGpeFDVdxjTeEVN2o= k8s.io/kube-openapi v0.0.0-20240709000822-3c01b740850f h1:2sXuKesAYbRHxL3aE2PN6zX/gcJr22cjrsej+W784Tc= k8s.io/kube-openapi v0.0.0-20240709000822-3c01b740850f/go.mod h1:UxDHUPsUwTOOxSU+oXURfFBcAS6JwiRXTYqYwfuGowc= k8s.io/kubectl v0.31.1 h1:ih4JQJHxsEggFqDJEHSOdJ69ZxZftgeZvYo7M/cpp24= @@ -2452,7 +2424,6 @@ k8s.io/metrics v0.31.2 h1:sQhujR9m3HN/Nu/0fTfTscjnswQl0qkQAodEdGBS0N4= k8s.io/metrics v0.31.2/go.mod h1:QqqyReApEWO1UEgXOSXiHCQod6yTxYctbAAQBWZkboU= k8s.io/utils v0.0.0-20190801114015-581e00157fb1/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= -k8s.io/utils v0.0.0-20200729134348-d5654de09c73/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= k8s.io/utils v0.0.0-20240921022957-49e7df575cb6 h1:MDF6h2H/h4tbzmtIKTuctcwZmY0tY9mD9fNT47QO6HI= k8s.io/utils v0.0.0-20240921022957-49e7df575cb6/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw= @@ -2487,12 +2458,10 @@ sigs.k8s.io/kustomize/kyaml v0.18.1/go.mod h1:C3L2BFVU1jgcddNBE1TxuVLgS46TjObMwW sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/structured-merge-diff v0.0.0-20190817042607-6149e4549fca/go.mod h1:IIgPezJWb76P0hotTxzDbWsMYB8APh18qZnxkomBpxA= sigs.k8s.io/structured-merge-diff v1.0.1-0.20191108220359-b1b620dd3f06/go.mod h1:/ULNhyfzRopfcjskuui0cTITekDduZ7ycKN3oUT9R18= -sigs.k8s.io/structured-merge-diff/v4 v4.0.1/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw= sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= sigs.k8s.io/testing_frameworks v0.1.2/go.mod h1:ToQrwSC3s8Xf/lADdZp3Mktcql9CG0UAmdJG9th5i0w= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= -sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= sourcegraph.com/sqs/pbtypes v0.0.0-20180604144634-d3ebe8f20ae4/go.mod h1:ketZ/q3QxT9HOBeFhu6RdvsftgpsbFHBF5Cas6cDKZ0= diff --git a/pkg/handlers/handlers.go b/pkg/handlers/handlers.go index fe8c9a9bef..74bd8b2ca0 100644 --- a/pkg/handlers/handlers.go +++ b/pkg/handlers/handlers.go @@ -14,7 +14,6 @@ import ( kotsscheme "github.com/replicatedhq/kotskinds/client/kotsclientset/scheme" troubleshootscheme "github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/scheme" yaml "github.com/replicatedhq/yaml/v3" - veleroscheme "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned/scheme" "k8s.io/client-go/kubernetes/scheme" ) diff --git a/pkg/handlers/snapshot_logs.go b/pkg/handlers/snapshot_logs.go index 512688ed4c..c1cac4a8e2 100644 --- a/pkg/handlers/snapshot_logs.go +++ b/pkg/handlers/snapshot_logs.go @@ -12,7 +12,6 @@ import ( kotssnapshot "github.com/replicatedhq/kots/pkg/snapshot" "github.com/replicatedhq/kots/pkg/util" velerov1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v1" - veleroclientv1 "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned/typed/velero/v1" "k8s.io/client-go/kubernetes" ) diff --git a/pkg/informers/informers.go b/pkg/informers/informers.go index d1e72aedea..e5fb11f5c5 100644 --- a/pkg/informers/informers.go +++ b/pkg/informers/informers.go @@ -12,7 +12,6 @@ import ( "github.com/replicatedhq/kots/pkg/supportbundle" "github.com/replicatedhq/kots/pkg/util" velerov1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v1" - veleroclientv1 "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned/typed/velero/v1" kuberneteserrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/watch" diff --git a/pkg/kotsadm/minio.go b/pkg/kotsadm/minio.go index f6e5a4e928..f00536eebe 100644 --- a/pkg/kotsadm/minio.go +++ b/pkg/kotsadm/minio.go @@ -14,7 +14,6 @@ import ( "github.com/replicatedhq/kots/pkg/logger" "github.com/replicatedhq/kots/pkg/snapshot" velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1" - veleroclientv1 "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned/typed/velero/v1" corev1 "k8s.io/api/core/v1" kuberneteserrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/resource" diff --git a/pkg/kotsadmsnapshot/backup.go b/pkg/kotsadmsnapshot/backup.go index 502e43a811..bb0bc3edb4 100644 --- a/pkg/kotsadmsnapshot/backup.go +++ b/pkg/kotsadmsnapshot/backup.go @@ -24,7 +24,6 @@ import ( kotsadmtypes "github.com/replicatedhq/kots/pkg/kotsadm/types" "github.com/replicatedhq/kots/pkg/kotsadmsnapshot/k8sclient" "github.com/replicatedhq/kots/pkg/kotsadmsnapshot/types" - "github.com/replicatedhq/kots/pkg/kotsadmsnapshot/veleroclient" "github.com/replicatedhq/kots/pkg/kotsutil" "github.com/replicatedhq/kots/pkg/kurl" "github.com/replicatedhq/kots/pkg/logger" @@ -33,7 +32,6 @@ import ( "github.com/replicatedhq/kots/pkg/store" "github.com/replicatedhq/kots/pkg/util" velerov1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v1" - veleroclientv1 "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned/typed/velero/v1" velerolabel "github.com/vmware-tanzu/velero/pkg/label" "go.uber.org/zap" corev1 "k8s.io/api/core/v1" @@ -91,9 +89,9 @@ func CreateApplicationBackup(ctx context.Context, a *apptypes.App, isScheduled b return nil, errors.Wrap(err, "failed to create clientset") } - veleroClient, err := veleroclient.GetBuilder().GetVeleroClient(cfg) + veleroClient, err := k8sclient.GetBuilder().GetVeleroKubeClient(ctx) if err != nil { - return nil, errors.Wrap(err, "failed to create velero clientset") + return nil, errors.Wrap(err, "failed to create velero client") } kotsadmNamespace := util.PodNamespace @@ -194,12 +192,12 @@ func CreateApplicationBackup(ctx context.Context, a *apptypes.App, isScheduled b logger.Error(errors.Wrap(err, "failed to exclude shutdown pods from backup")) } - backup, err := veleroClient.Backups(kotsadmVeleroBackendStorageLocation.Namespace).Create(ctx, veleroBackup, metav1.CreateOptions{}) + err = veleroClient.Create(ctx, veleroBackup) if err != nil { return nil, errors.Wrap(err, "failed to create velero backup") } - return backup, nil + return veleroBackup, nil } type instanceBackupMetadata struct { @@ -237,17 +235,12 @@ func CreateInstanceBackup(ctx context.Context, cluster *downstreamtypes.Downstre return "", errors.Wrap(err, "failed to create clientset") } - ctrlClient, err := k8sutil.GetKubeClient(ctx) + ctrlClient, err := k8sutil.GetVeleroKubeClient(ctx) if err != nil { return "", errors.Wrap(err, "failed to get kubeclient") } - veleroClient, err := veleroclient.GetBuilder().GetVeleroClient(cfg) - if err != nil { - return "", errors.Wrap(err, "failed to create velero clientset") - } - - metadata, err := getInstanceBackupMetadata(ctx, k8sClient, ctrlClient, veleroClient, cluster, isScheduled) + metadata, err := getInstanceBackupMetadata(ctx, k8sClient, ctrlClient, cluster, isScheduled) if err != nil { return "", errors.Wrap(err, "failed to get instance backup metadata") } @@ -275,20 +268,20 @@ func CreateInstanceBackup(ctx context.Context, cluster *downstreamtypes.Downstre } logger.Infof("Creating instance backup CR %s", veleroBackup.GenerateName) - backup, err := veleroClient.Backups(metadata.backupStorageLocationNamespace).Create(ctx, veleroBackup, metav1.CreateOptions{}) + err = ctrlClient.Create(ctx, veleroBackup) if err != nil { return "", errors.Wrap(err, "failed to create velero backup") } if appVeleroBackup != nil { logger.Infof("Creating instance app backup CR %s", appVeleroBackup.GenerateName) - _, err := veleroClient.Backups(metadata.backupStorageLocationNamespace).Create(ctx, appVeleroBackup, metav1.CreateOptions{}) + err = ctrlClient.Create(ctx, appVeleroBackup) if err != nil { return "", errors.Wrap(err, "failed to create application velero backup") } } - return backup.Name, nil // TODO(improveddr): return metadata.BackupName + return veleroBackup.Name, nil // TODO(improveddr): return metadata.BackupName } // GetInstanceBackupCount returns the restore CR from the velero backup object annotation. @@ -317,7 +310,7 @@ func encodeRestoreSpec(restore *velerov1.Restore) (string, error) { // getInstanceBackupMetadata returns metadata about the instance backup for use in creating an // instance backup. -func getInstanceBackupMetadata(ctx context.Context, k8sClient kubernetes.Interface, ctrlClient ctrlclient.Client, veleroClient veleroclientv1.VeleroV1Interface, cluster *downstreamtypes.Downstream, isScheduled bool) (instanceBackupMetadata, error) { +func getInstanceBackupMetadata(ctx context.Context, k8sClient kubernetes.Interface, ctrlClient ctrlclient.Client, cluster *downstreamtypes.Downstream, isScheduled bool) (instanceBackupMetadata, error) { metadata := instanceBackupMetadata{ backupName: getBackupNameFromPrefix("instance"), backupReqestedAt: time.Now().UTC(), @@ -334,7 +327,7 @@ func getInstanceBackupMetadata(ctx context.Context, k8sClient kubernetes.Interfa metadata.snapshotTTL = snapshotTTL } - kotsadmVeleroBackendStorageLocation, err := kotssnapshot.FindBackupStoreLocation(ctx, k8sClient, veleroClient, metadata.kotsadmNamespace) + kotsadmVeleroBackendStorageLocation, err := kotssnapshot.FindBackupStoreLocation(ctx, k8sClient, ctrlClient, metadata.kotsadmNamespace) if err != nil { return metadata, errors.Wrap(err, "failed to find backupstoragelocations") } else if kotsadmVeleroBackendStorageLocation == nil { diff --git a/pkg/kotsadmsnapshot/backup_test.go b/pkg/kotsadmsnapshot/backup_test.go index 7e86113bac..8b749464dc 100644 --- a/pkg/kotsadmsnapshot/backup_test.go +++ b/pkg/kotsadmsnapshot/backup_test.go @@ -26,8 +26,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" velerov1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v1" - velerofake "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned/fake" - veleroclientv1 "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned/typed/velero/v1" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" rbacv1 "k8s.io/api/rbac/v1" diff --git a/pkg/kotsadmsnapshot/k8sclient/k8sclient.go b/pkg/kotsadmsnapshot/k8sclient/k8sclient.go index 12ccdcec42..878108e8ea 100644 --- a/pkg/kotsadmsnapshot/k8sclient/k8sclient.go +++ b/pkg/kotsadmsnapshot/k8sclient/k8sclient.go @@ -1,46 +1,74 @@ package k8sclient import ( + "context" + + "github.com/replicatedhq/kots/pkg/k8sutil" "k8s.io/client-go/kubernetes" rest "k8s.io/client-go/rest" + kbclient "sigs.k8s.io/controller-runtime/pkg/client" ) -var _ K8sClientsetBuilder = (*Builder)(nil) -var _ K8sClientsetBuilder = (*MockBuilder)(nil) +var _ K8sClientsBuilder = (*Builder)(nil) +var _ K8sClientsBuilder = (*MockBuilder)(nil) -// K8sClientsetBuilder interface is used as an abstraction to get a k8s clientset. Useful to mock the client in tests. -type K8sClientsetBuilder interface { +// K8sClientsBuilder interface is used as an abstraction to get a kubernetes go client clientset. +// Or a controller runtime client. Useful to mock the client in tests. +type K8sClientsBuilder interface { GetClientset(*rest.Config) (kubernetes.Interface, error) + GetKubeClient(ctx context.Context) (kbclient.Client, error) + GetVeleroKubeClient(ctx context.Context) (kbclient.Client, error) } -// Builder is the default implementation of K8sClientsetBuilder. It returns a regular k8s clientset. +// Builder is the default implementation of K8sClientsetBuilder. It returns a regular go client clientset or a regular controller runtime client. type Builder struct{} -// GetClientset returns a regular k8s client. +// GetClientset returns a regular go client for the given config. func (b *Builder) GetClientset(cfg *rest.Config) (kubernetes.Interface, error) { return kubernetes.NewForConfig(cfg) } -// MockBuilder is a mock implementation of K8sClientsetBuilder. It returns the client that was set in the struct allowing -// you to set a fakeClient for example. +// GetKubeClient returns a regular controller runtime client based on the default cluster config provided. +func (b *Builder) GetKubeClient(ctx context.Context) (kbclient.Client, error) { + return k8sutil.GetKubeClient(ctx) +} + +// GetVeleroKubeClient returns a controller runtime client with the velero API scheme based on the default cluster config provided. +func (b *Builder) GetVeleroKubeClient(ctx context.Context) (kbclient.Client, error) { + return k8sutil.GetVeleroKubeClient(ctx) +} + +// MockBuilder is a mock implementation of K8sClientsetBuilder. It returns the client and clientset that was set in the struct allowing +// you to set a fake clients for example. type MockBuilder struct { - Client kubernetes.Interface - Err error + Clientset kubernetes.Interface + CtrlClient kbclient.Client + Err error } -// GetClientset returns the client that was set in the struct. +// GetClientset returns the clientset that was set in the struct. func (b *MockBuilder) GetClientset(cfg *rest.Config) (kubernetes.Interface, error) { - return b.Client, b.Err + return b.Clientset, b.Err +} + +// GetKubeClient returns the controller runtime client set in the struct. +func (b *MockBuilder) GetKubeClient(ctx context.Context) (kbclient.Client, error) { + return b.CtrlClient, b.Err +} + +// GetVeleroKubeClient returns the controller runtime client set in the struct. +func (b *MockBuilder) GetVeleroKubeClient(ctx context.Context) (kbclient.Client, error) { + return b.CtrlClient, b.Err } -var clientBuilder K8sClientsetBuilder +var clientBuilder K8sClientsBuilder -func GetBuilder() K8sClientsetBuilder { +func GetBuilder() K8sClientsBuilder { return clientBuilder } -func SetBuilder(builder K8sClientsetBuilder) { +func SetBuilder(builder K8sClientsBuilder) { clientBuilder = builder } diff --git a/pkg/kotsadmsnapshot/restore.go b/pkg/kotsadmsnapshot/restore.go index 713a6acbb4..d935f5f758 100644 --- a/pkg/kotsadmsnapshot/restore.go +++ b/pkg/kotsadmsnapshot/restore.go @@ -14,7 +14,6 @@ import ( "github.com/replicatedhq/kots/pkg/logger" kotssnapshot "github.com/replicatedhq/kots/pkg/snapshot" velerov1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v1" - veleroclientv1 "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned/typed/velero/v1" velerolabel "github.com/vmware-tanzu/velero/pkg/label" kuberneteserrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/kotsadmsnapshot/snapshot.go b/pkg/kotsadmsnapshot/snapshot.go index 7886accc54..6849aa8204 100644 --- a/pkg/kotsadmsnapshot/snapshot.go +++ b/pkg/kotsadmsnapshot/snapshot.go @@ -1,10 +1,10 @@ package snapshot import ( - veleroscheme "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned/scheme" + velerov1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v1" "k8s.io/client-go/kubernetes/scheme" ) func init() { - veleroscheme.AddToScheme(scheme.Scheme) + velerov1.AddToScheme(scheme.Scheme) } diff --git a/pkg/kotsadmsnapshot/veleroclient/veleroclient.go b/pkg/kotsadmsnapshot/veleroclient/veleroclient.go deleted file mode 100644 index f7d9fd1eef..0000000000 --- a/pkg/kotsadmsnapshot/veleroclient/veleroclient.go +++ /dev/null @@ -1,49 +0,0 @@ -package veleroclient - -import ( - veleroclientv1 "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned/typed/velero/v1" - rest "k8s.io/client-go/rest" -) - -var _ VeleroClientBuilder = (*Builder)(nil) -var _ VeleroClientBuilder = (*MockBuilder)(nil) - -// VeleroClientBuilder interface is used as an abstraction to get a velero client. Useful to mock the client in tests. -type VeleroClientBuilder interface { - GetVeleroClient(*rest.Config) (veleroclientv1.VeleroV1Interface, error) -} - -// Builder is the default implementation of VeleroClientBuilder. It returns a regular velero v1 client. -type Builder struct{} - -// GetVeleroClient returns a regular velero client. -func (b *Builder) GetVeleroClient(cfg *rest.Config) (veleroclientv1.VeleroV1Interface, error) { - return veleroclientv1.NewForConfig(cfg) -} - -// MockBuilder is a mock implementation of VeleroClientBuilder. It returns the client that was set in the struct allowing -// you to set a fakeClient for example. - -type MockBuilder struct { - Client veleroclientv1.VeleroV1Interface - Err error -} - -// GetVeleroClient returns the client that was set in the struct. -func (b *MockBuilder) GetVeleroClient(cfg *rest.Config) (veleroclientv1.VeleroV1Interface, error) { - return b.Client, b.Err -} - -var clientBuilder VeleroClientBuilder - -func GetBuilder() VeleroClientBuilder { - return clientBuilder -} - -func SetBuilder(builder VeleroClientBuilder) { - clientBuilder = builder -} - -func init() { - SetBuilder(&Builder{}) -} diff --git a/pkg/reporting/app.go b/pkg/reporting/app.go index b2178abd2b..5421c919ca 100644 --- a/pkg/reporting/app.go +++ b/pkg/reporting/app.go @@ -23,7 +23,6 @@ import ( troubleshootpreflight "github.com/replicatedhq/troubleshoot/pkg/preflight" "github.com/segmentio/ksuid" velerov1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v1" - veleroclientv1 "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned/typed/velero/v1" "k8s.io/client-go/kubernetes" ) diff --git a/pkg/snapshot/backup.go b/pkg/snapshot/backup.go index fa93f29acd..1cfa1a34ef 100644 --- a/pkg/snapshot/backup.go +++ b/pkg/snapshot/backup.go @@ -15,9 +15,9 @@ import ( snapshottypes "github.com/replicatedhq/kots/pkg/kotsadmsnapshot/types" "github.com/replicatedhq/kots/pkg/logger" velerov1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v1" - veleroclientv1 "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned/typed/velero/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + k8stypes "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes" + kbclient "sigs.k8s.io/controller-runtime/pkg/client" ) type CreateInstanceBackupOptions struct { @@ -192,7 +192,7 @@ func ListInstanceBackups(ctx context.Context, options ListInstanceBackupsOptions func ListAllBackups(ctx context.Context, options ListInstanceBackupsOptions) ([]velerov1.Backup, error) { clientset, err := k8sutil.GetClientset() if err != nil { - return nil, errors.Wrap(err, "failed to get k8s clientset") + return nil, errors.Wrap(err, "failed to get k8s client") } veleroNamespace, err := DetectVeleroNamespace(ctx, clientset, options.Namespace) if err != nil { @@ -202,23 +202,19 @@ func ListAllBackups(ctx context.Context, options ListInstanceBackupsOptions) ([] return nil, errors.New("velero not found") } - cfg, err := k8sutil.GetClusterConfig() - if err != nil { - return nil, errors.Wrap(err, "failed to get cluster config") - } - - veleroClient, err := veleroclientv1.NewForConfig(cfg) + veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) if err != nil { return nil, errors.Wrap(err, "failed to create clientset") } - b, err := veleroClient.Backups(veleroNamespace).List(ctx, metav1.ListOptions{}) + var backupList velerov1.BackupList + err = veleroClient.List(ctx, &backupList, kbclient.InNamespace(veleroNamespace)) if err != nil { return nil, errors.Wrap(err, "failed to list backups") } backups := []velerov1.Backup{} - backups = append(backups, b.Items...) + backups = append(backups, backupList.Items...) return backups, nil } @@ -232,29 +228,25 @@ func waitForVeleroBackupCompleted(ctx context.Context, clientset kubernetes.Inte return nil, errors.New("velero not found") } - cfg, err := k8sutil.GetClusterConfig() + veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) if err != nil { - return nil, errors.Wrap(err, "failed to get cluster config") - } - - veleroClient, err := veleroclientv1.NewForConfig(cfg) - if err != nil { - return nil, errors.Wrap(err, "failed to create clientset") + return nil, errors.Wrap(err, "failed to create client") } for { - backup, err := veleroClient.Backups(veleroNamespace).Get(ctx, backupName, metav1.GetOptions{}) + var backup velerov1.Backup + err := veleroClient.Get(ctx, k8stypes.NamespacedName{Namespace: veleroNamespace, Name: backupName}, &backup) if err != nil { return nil, errors.Wrap(err, "failed to get backup") } switch backup.Status.Phase { case velerov1.BackupPhaseCompleted: - return backup, nil + return &backup, nil case velerov1.BackupPhaseFailed: - return backup, errors.New("backup failed") + return &backup, errors.New("backup failed") case velerov1.BackupPhasePartiallyFailed: - return backup, errors.New("backup partially failed") + return &backup, errors.New("backup partially failed") default: // in progress } diff --git a/pkg/snapshot/filesystem_lvp.go b/pkg/snapshot/filesystem_lvp.go index 55ff0e179e..53cd748c07 100644 --- a/pkg/snapshot/filesystem_lvp.go +++ b/pkg/snapshot/filesystem_lvp.go @@ -11,11 +11,11 @@ import ( kotsadmtypes "github.com/replicatedhq/kots/pkg/kotsadm/types" types "github.com/replicatedhq/kots/pkg/snapshot/types" velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1" - veleroclientv1 "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned/typed/velero/v1" corev1 "k8s.io/api/core/v1" kuberneteserrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" + kbclient "sigs.k8s.io/controller-runtime/pkg/client" ) const ( @@ -56,9 +56,9 @@ func GetCurrentLvpFileSystemConfig(ctx context.Context, namespace string) (*type return nil, errors.Wrap(err, "failed to create clientset") } - veleroClient, err := veleroclientv1.NewForConfig(cfg) + veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) if err != nil { - return nil, errors.Wrap(err, "failed to create velero clientset") + return nil, errors.Wrap(err, "failed to create velero client") } bsl, err := FindBackupStoreLocation(ctx, clientset, veleroClient, namespace) @@ -114,8 +114,8 @@ func GetCurrentLvpFileSystemConfig(ctx context.Context, namespace string) (*type // RevertToMinioFS will apply the spec of the previous BSL to the current one and then update. // Used for recovery during a failed migration from Minio to LVP. -func RevertToMinioFS(ctx context.Context, clientset kubernetes.Interface, veleroClient veleroclientv1.VeleroV1Interface, kotsadmNamespace, veleroNamespace string, previousBsl *velerov1api.BackupStorageLocation) error { - bsl, err := FindBackupStoreLocation(context.TODO(), clientset, veleroClient, kotsadmNamespace) +func RevertToMinioFS(ctx context.Context, clientset kubernetes.Interface, ctrlclient kbclient.Client, kotsadmNamespace, veleroNamespace string, previousBsl *velerov1api.BackupStorageLocation) error { + bsl, err := FindBackupStoreLocation(context.TODO(), clientset, ctrlclient, kotsadmNamespace) if err != nil { return errors.Wrap(err, "failed to find backupstoragelocations") } diff --git a/pkg/snapshot/restore.go b/pkg/snapshot/restore.go index 54aa411a3c..6eb5e48a6e 100644 --- a/pkg/snapshot/restore.go +++ b/pkg/snapshot/restore.go @@ -19,9 +19,10 @@ import ( "github.com/replicatedhq/kots/pkg/kurl" "github.com/replicatedhq/kots/pkg/logger" velerov1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v1" - veleroclientv1 "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned/typed/velero/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + k8stypes "k8s.io/apimachinery/pkg/types" "k8s.io/utils/pointer" + kbclient "sigs.k8s.io/controller-runtime/pkg/client" ) type RestoreInstanceBackupOptions struct { @@ -56,17 +57,13 @@ func RestoreInstanceBackup(ctx context.Context, options RestoreInstanceBackupOpt } // get the backup - cfg, err := k8sutil.GetClusterConfig() + veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) if err != nil { - return errors.Wrap(err, "failed to get cluster config") + return errors.Wrap(err, "failed to create velero client") } - veleroClient, err := veleroclientv1.NewForConfig(cfg) - if err != nil { - return errors.Wrap(err, "failed to create velero clientset") - } - - backup, err := veleroClient.Backups(veleroNamespace).Get(ctx, options.BackupName, metav1.GetOptions{}) + var backup velerov1.Backup + err = veleroClient.Get(ctx, k8stypes.NamespacedName{Namespace: veleroNamespace, Name: options.BackupName}, &backup) if err != nil { return errors.Wrap(err, "failed to find backup") } @@ -147,14 +144,14 @@ func RestoreInstanceBackup(ctx context.Context, options RestoreInstanceBackupOpt } // delete existing restore object (if exists) - err = veleroClient.Restores(veleroNamespace).Delete(ctx, restore.ObjectMeta.Name, metav1.DeleteOptions{}) + err = veleroClient.Delete(ctx, restore) if err != nil && !strings.Contains(err.Error(), "not found") { log.FinishSpinnerWithError() return errors.Wrapf(err, "failed to delete restore %s", restore.ObjectMeta.Name) } // create new restore object - restore, err = veleroClient.Restores(veleroNamespace).Create(ctx, restore, metav1.CreateOptions{}) + err = veleroClient.Create(ctx, restore) if err != nil { log.FinishSpinnerWithError() return errors.Wrap(err, "failed to create restore") @@ -268,24 +265,20 @@ func ListInstanceRestores(ctx context.Context, options ListInstanceRestoresOptio return nil, errors.New("velero not found") } - cfg, err := k8sutil.GetClusterConfig() + veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) if err != nil { - return nil, errors.Wrap(err, "failed to get cluster config") + return nil, errors.Wrap(err, "failed to create client") } - veleroClient, err := veleroclientv1.NewForConfig(cfg) - if err != nil { - return nil, errors.Wrap(err, "failed to create clientset") - } - - r, err := veleroClient.Restores(veleroNamespace).List(ctx, metav1.ListOptions{}) + var restoreList velerov1.RestoreList + err = veleroClient.List(ctx, &restoreList, kbclient.InNamespace(veleroNamespace)) if err != nil { return nil, errors.Wrap(err, "failed to list restores") } restores := []velerov1.Restore{} - for _, restore := range r.Items { + for _, restore := range restoreList.Items { if restore.Annotations[snapshottypes.InstanceBackupAnnotation] != "true" { continue } @@ -301,18 +294,14 @@ func ListInstanceRestores(ctx context.Context, options ListInstanceRestoresOptio } func waitForVeleroRestoreCompleted(ctx context.Context, veleroNamespace string, restoreName string) (*velerov1.Restore, error) { - cfg, err := k8sutil.GetClusterConfig() - if err != nil { - return nil, errors.Wrap(err, "failed to get cluster config") - } - - veleroClient, err := veleroclientv1.NewForConfig(cfg) + veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) if err != nil { - return nil, errors.Wrap(err, "failed to create clientset") + return nil, errors.Wrap(err, "failed to create client") } for { - restore, err := veleroClient.Restores(veleroNamespace).Get(ctx, restoreName, metav1.GetOptions{}) + var restore velerov1.Restore + err := veleroClient.Get(ctx, k8stypes.NamespacedName{Namespace: veleroNamespace, Name: restoreName}, &restore) if err != nil { return nil, errors.Wrap(err, "failed to get restore") } diff --git a/pkg/snapshot/snapshot.go b/pkg/snapshot/snapshot.go index 7886accc54..afd3e43915 100644 --- a/pkg/snapshot/snapshot.go +++ b/pkg/snapshot/snapshot.go @@ -1,7 +1,6 @@ package snapshot import ( - veleroscheme "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned/scheme" "k8s.io/client-go/kubernetes/scheme" ) diff --git a/pkg/snapshot/store.go b/pkg/snapshot/store.go index af13c7b17e..f758b695a3 100644 --- a/pkg/snapshot/store.go +++ b/pkg/snapshot/store.go @@ -37,14 +37,16 @@ import ( "github.com/replicatedhq/kots/pkg/snapshot/types" "github.com/replicatedhq/kots/pkg/util" velerov1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v1" - veleroclientv1 "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned/typed/velero/v1" "google.golang.org/api/option" "gopkg.in/ini.v1" corev1 "k8s.io/api/core/v1" kuberneteserrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime/schema" + k8stypes "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes" + kbclient "sigs.k8s.io/controller-runtime/pkg/client" ) const ( @@ -428,9 +430,9 @@ func upsertGlobalStore(ctx context.Context, store *types.Store, kotsadmNamespace return nil, errors.Wrap(err, "failed to create clientset") } - veleroClient, err := veleroclientv1.NewForConfig(cfg) + veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) if err != nil { - return nil, errors.Wrap(err, "failed to create velero clientset") + return nil, errors.Wrap(err, "failed to create velero client") } bsl, err := FindBackupStoreLocation(ctx, clientset, veleroClient, kotsadmNamespace) @@ -792,31 +794,25 @@ func cloudCredentialsEnvVars() []corev1.EnvVar { } func upsertBackupStorageLocation(ctx context.Context, bsl *velerov1.BackupStorageLocation) (*velerov1.BackupStorageLocation, error) { - cfg, err := k8sutil.GetClusterConfig() - if err != nil { - return nil, errors.Wrap(err, "failed to get cluster config") - } - - veleroClient, err := veleroclientv1.NewForConfig(cfg) + veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) if err != nil { - return nil, errors.Wrap(err, "failed to create velero clientset") + return nil, errors.Wrap(err, "failed to create velero client") } - _, err = veleroClient.BackupStorageLocations(bsl.Namespace).Get(ctx, bsl.Name, metav1.GetOptions{}) - if err == nil { - updated, err := veleroClient.BackupStorageLocations(bsl.Namespace).Update(ctx, bsl, metav1.UpdateOptions{}) + if err = veleroClient.Get(ctx, k8stypes.NamespacedName{Namespace: bsl.Namespace, Name: bsl.Name}, bsl); err == nil { + err := veleroClient.Update(ctx, bsl) if err != nil { return nil, errors.Wrap(err, "failed to update backup storage location") } - return updated, nil + return bsl, nil } if kuberneteserrors.IsNotFound(err) { - created, err := veleroClient.BackupStorageLocations(bsl.Namespace).Create(ctx, bsl, metav1.CreateOptions{}) + err := veleroClient.Create(ctx, bsl) if err != nil { return nil, errors.Wrap(err, "failed to create backup storage location") } - return created, nil + return bsl, nil } return nil, errors.Wrap(err, "failed to get backup storage location") @@ -883,9 +879,9 @@ func GetGlobalStore(ctx context.Context, kotsadmNamespace string, bsl *velerov1. return nil, errors.Wrap(err, "failed to create clientset") } - veleroClient, err := veleroclientv1.NewForConfig(cfg) + veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) if err != nil { - return nil, errors.Wrap(err, "failed to create velero clientset") + return nil, errors.Wrap(err, "failed to create velero client") } if bsl == nil { @@ -1076,7 +1072,7 @@ func mapAWSBackupStorageLocationToStore(kotsadmVeleroBackendStorageLocation *vel // FindBackupStoreLocation will find the backup storage location used by velero // kotsadmNamespace is only required in minimal rbac installations. if empty, cluster scope privileges will be needed to detect and validate velero -func FindBackupStoreLocation(ctx context.Context, clientset kubernetes.Interface, veleroClient veleroclientv1.VeleroV1Interface, kotsadmNamespace string) (*velerov1.BackupStorageLocation, error) { +func FindBackupStoreLocation(ctx context.Context, clientset kubernetes.Interface, ctrlClient kbclient.Client, kotsadmNamespace string) (*velerov1.BackupStorageLocation, error) { veleroNamespace, err := DetectVeleroNamespace(ctx, clientset, kotsadmNamespace) if err != nil { return nil, errors.Wrap(err, "failed to detect velero namespace") @@ -1086,7 +1082,8 @@ func FindBackupStoreLocation(ctx context.Context, clientset kubernetes.Interface return nil, nil } - backupStorageLocations, err := veleroClient.BackupStorageLocations(veleroNamespace).List(ctx, metav1.ListOptions{}) + var backupStorageLocations velerov1.BackupStorageLocationList + err = ctrlClient.List(ctx, &backupStorageLocations, kbclient.InNamespace(veleroNamespace)) if err != nil { if kuberneteserrors.IsNotFound(err) { return nil, nil @@ -1105,17 +1102,12 @@ func FindBackupStoreLocation(ctx context.Context, clientset kubernetes.Interface // UpdateBackupStorageLocation applies an updated Velero backup storage location resource to the cluster func UpdateBackupStorageLocation(ctx context.Context, veleroNamespace string, bsl *velerov1.BackupStorageLocation) error { - cfg, err := k8sutil.GetClusterConfig() - if err != nil { - return errors.Wrap(err, "failed to get cluster config") - } - - veleroClient, err := veleroclientv1.NewForConfig(cfg) + veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) if err != nil { - return errors.Wrap(err, "failed to create velero clientset") + return errors.Wrap(err, "failed to create velero client") } - _, err = veleroClient.BackupStorageLocations(veleroNamespace).Update(ctx, bsl, metav1.UpdateOptions{}) + err = veleroClient.Update(ctx, bsl) if err != nil { return errors.Wrap(err, "failed to update backupstoragelocation") } @@ -1632,18 +1624,14 @@ func resetRepositories(ctx context.Context, veleroNamespace string) error { func resetBackupRepositories(ctx context.Context, veleroNamespace string) error { // BackupRepositories store the previous snapshot location which breaks volume backup when location changes. - cfg, err := k8sutil.GetClusterConfig() - if err != nil { - return errors.Wrap(err, "failed to get cluster config") - } - - veleroClient, err := veleroclientv1.NewForConfig(cfg) + veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) if err != nil { - return errors.Wrap(err, "failed to create clientset") + return errors.Wrap(err, "failed to create velero client") } - repos, err := veleroClient.BackupRepositories(veleroNamespace).List(ctx, metav1.ListOptions{ - LabelSelector: "velero.io/storage-location=default", + var repos velerov1.BackupRepositoryList + err = veleroClient.List(ctx, &repos, kbclient.InNamespace(veleroNamespace), &kbclient.ListOptions{ + LabelSelector: labels.SelectorFromSet(labels.Set{"velero.io/storage-location": "default"}), }) if err != nil && !kuberneteserrors.IsNotFound(err) { return errors.Wrap(err, "failed to list backuprepositories") @@ -1653,7 +1641,7 @@ func resetBackupRepositories(ctx context.Context, veleroNamespace string) error } for _, repo := range repos.Items { - err := veleroClient.BackupRepositories(veleroNamespace).Delete(ctx, repo.Name, metav1.DeleteOptions{}) + err := veleroClient.Delete(ctx, &repo) if err != nil { return errors.Wrapf(err, "failed to delete backuprepository %s", repo.Name) } @@ -1719,14 +1707,9 @@ func GetLvpBucket(fsConfig *types.FileSystemConfig) (string, error) { func WaitForDefaultBslAvailableAndSynced(ctx context.Context, veleroNamespace string, start metav1.Time) error { timeout := time.After(5 * time.Minute) - cfg, err := k8sutil.GetClusterConfig() - if err != nil { - return errors.Wrap(err, "failed to get cluster config") - } - - veleroClient, err := veleroclientv1.NewForConfig(cfg) + veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) if err != nil { - return errors.Wrap(err, "failed to create clientset") + return errors.Wrap(err, "failed to create velero client") } for { @@ -1734,7 +1717,8 @@ func WaitForDefaultBslAvailableAndSynced(ctx context.Context, veleroNamespace st case <-timeout: return errors.New("timed out waiting for default backup storage location to be available") default: - bsl, err := veleroClient.BackupStorageLocations(veleroNamespace).Get(ctx, DefaultBackupStorageLocationName, metav1.GetOptions{}) + var bsl velerov1.BackupStorageLocation + err := veleroClient.Get(ctx, k8stypes.NamespacedName{Namespace: veleroNamespace, Name: DefaultBackupStorageLocationName}, &bsl) if err != nil { return errors.Wrap(err, "failed to get default backup storage location") } diff --git a/pkg/snapshot/store_test.go b/pkg/snapshot/store_test.go index 84a000b520..2f026df32d 100644 --- a/pkg/snapshot/store_test.go +++ b/pkg/snapshot/store_test.go @@ -8,8 +8,6 @@ import ( "github.com/replicatedhq/kots/pkg/snapshot/types" "github.com/stretchr/testify/require" velerov1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v1" - velerofake "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned/fake" - veleroclientv1 "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned/typed/velero/v1" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -17,6 +15,8 @@ import ( "k8s.io/client-go/kubernetes/fake" testclient "k8s.io/client-go/kubernetes/fake" "k8s.io/utils/pointer" + kbclient "sigs.k8s.io/controller-runtime/pkg/client" + kbclientfake "sigs.k8s.io/controller-runtime/pkg/client/fake" ) func Test_updateExistingStore(t *testing.T) { @@ -547,7 +547,7 @@ func TestFindBackupStoreLocation(t *testing.T) { type args struct { clientset kubernetes.Interface - veleroClient veleroclientv1.VeleroV1Interface + ctrlclient kbclient.Client kotsadmNamespace string } tests := []struct { @@ -560,7 +560,7 @@ func TestFindBackupStoreLocation(t *testing.T) { name: "backup store location found", args: args{ clientset: fake.NewSimpleClientset(veleroNamespaceConfigmap, veleroDeployment), - veleroClient: velerofake.NewSimpleClientset(testBsl).VeleroV1(), + ctrlclient: kbclientfake.NewFakeClient(testBsl), kotsadmNamespace: "default", }, want: testBsl, @@ -569,7 +569,7 @@ func TestFindBackupStoreLocation(t *testing.T) { name: "return nil if no backup store location found", args: args{ clientset: fake.NewSimpleClientset(veleroNamespaceConfigmap, veleroDeployment), - veleroClient: velerofake.NewSimpleClientset().VeleroV1(), + ctrlclient: kbclientfake.NewFakeClient(), kotsadmNamespace: "default", }, want: nil, @@ -578,7 +578,7 @@ func TestFindBackupStoreLocation(t *testing.T) { name: "return nil if no velero deployment found", args: args{ clientset: fake.NewSimpleClientset(veleroNamespaceConfigmap), - veleroClient: velerofake.NewSimpleClientset(testBsl).VeleroV1(), + ctrlclient: kbclientfake.NewFakeClient(testBsl), kotsadmNamespace: "default", }, want: nil, @@ -587,7 +587,7 @@ func TestFindBackupStoreLocation(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { ctx := context.Background() - got, err := FindBackupStoreLocation(ctx, tt.args.clientset, tt.args.veleroClient, tt.args.kotsadmNamespace) + got, err := FindBackupStoreLocation(ctx, tt.args.clientset, tt.args.ctrlclient, tt.args.kotsadmNamespace) if (err != nil) != tt.wantErr { t.Errorf("FindBackupStoreLocation() error = %v, wantErr %v", err, tt.wantErr) return diff --git a/pkg/snapshot/velero.go b/pkg/snapshot/velero.go index 1b8f38b99c..6291c154bb 100644 --- a/pkg/snapshot/velero.go +++ b/pkg/snapshot/velero.go @@ -13,8 +13,8 @@ import ( kotsadmresources "github.com/replicatedhq/kots/pkg/kotsadm/resources" kotsadmtypes "github.com/replicatedhq/kots/pkg/kotsadm/types" "github.com/replicatedhq/kots/pkg/util" + velerov1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v1" "github.com/vmware-tanzu/velero/pkg/cmd/cli/serverstatus" - veleroclientv1 "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned/typed/velero/v1" v1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" kuberneteserrors "k8s.io/apimachinery/pkg/api/errors" @@ -22,6 +22,7 @@ import ( "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/selection" "k8s.io/client-go/kubernetes" + kbclient "sigs.k8s.io/controller-runtime/pkg/client" ) var ( @@ -99,13 +100,14 @@ func CheckKotsadmVeleroAccess(ctx context.Context, kotsadmNamespace string) (req return } - veleroClient, err := veleroclientv1.NewForConfig(cfg) + veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) if err != nil { - finalErr = errors.Wrap(err, "failed to create velero clientset") + finalErr = errors.Wrap(err, "failed to create velero client") return } - backupStorageLocations, err := veleroClient.BackupStorageLocations(veleroNamespace).List(ctx, metav1.ListOptions{}) + var backupStorageLocations velerov1.BackupStorageLocationList + err = veleroClient.List(ctx, &backupStorageLocations, kbclient.InNamespace(veleroNamespace)) if kuberneteserrors.IsForbidden(err) { requiresAccess = true return @@ -145,17 +147,13 @@ func CheckKotsadmVeleroAccess(ctx context.Context, kotsadmNamespace string) (req } func EnsureVeleroPermissions(ctx context.Context, clientset kubernetes.Interface, veleroNamespace string, kotsadmNamespace string) error { - cfg, err := k8sutil.GetClusterConfig() - if err != nil { - return errors.Wrap(err, "failed to get cluster config") - } - - veleroClient, err := veleroclientv1.NewForConfig(cfg) + veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) if err != nil { - return errors.Wrap(err, "failed to create velero clientset") + return errors.Wrap(err, "failed to create velero client") } - backupStorageLocations, err := veleroClient.BackupStorageLocations(veleroNamespace).List(ctx, metav1.ListOptions{}) + var backupStorageLocations velerov1.BackupStorageLocationList + err = veleroClient.List(ctx, &backupStorageLocations, kbclient.InNamespace(veleroNamespace)) if err != nil { return errors.Wrapf(err, "failed to list backupstoragelocations in '%s' namespace", veleroNamespace) } diff --git a/pkg/store/kotsstore/kots_store.go b/pkg/store/kotsstore/kots_store.go index d0a8c95abb..53c6bbc193 100644 --- a/pkg/store/kotsstore/kots_store.go +++ b/pkg/store/kotsstore/kots_store.go @@ -18,7 +18,6 @@ import ( "github.com/replicatedhq/kots/pkg/util" kotsscheme "github.com/replicatedhq/kotskinds/client/kotsclientset/scheme" troubleshootscheme "github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/scheme" - veleroscheme "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned/scheme" corev1 "k8s.io/api/core/v1" kuberneteserrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/upgradeservice/handlers/handlers.go b/pkg/upgradeservice/handlers/handlers.go index 305e99b996..67cd478ac8 100644 --- a/pkg/upgradeservice/handlers/handlers.go +++ b/pkg/upgradeservice/handlers/handlers.go @@ -8,7 +8,6 @@ import ( "github.com/replicatedhq/kots/pkg/logger" kotsscheme "github.com/replicatedhq/kotskinds/client/kotsclientset/scheme" troubleshootscheme "github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/scheme" - veleroscheme "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned/scheme" "k8s.io/client-go/kubernetes/scheme" ) From b4e81eede0acca203f12bbd695befdd74d32a07a Mon Sep 17 00:00:00 2001 From: JGAntunes Date: Mon, 23 Dec 2024 14:05:37 +0000 Subject: [PATCH 2/5] chore: should be building now --- pkg/handlers/handlers.go | 3 +- pkg/handlers/snapshot_logs.go | 4 +- pkg/informers/informers.go | 23 ++++---- pkg/k8sutil/clientset.go | 4 +- pkg/kotsadm/minio.go | 4 +- pkg/kotsadmsnapshot/backup.go | 70 ++++++++++++++----------- pkg/kotsadmsnapshot/restore.go | 56 ++++++++++++-------- pkg/reporting/app.go | 2 +- pkg/snapshot/restore.go | 10 ++-- pkg/snapshot/snapshot.go | 3 +- pkg/snapshot/store.go | 5 +- pkg/store/kotsstore/kots_store.go | 3 +- pkg/upgradeservice/handlers/handlers.go | 3 +- 13 files changed, 104 insertions(+), 86 deletions(-) diff --git a/pkg/handlers/handlers.go b/pkg/handlers/handlers.go index 74bd8b2ca0..0ca21bab5e 100644 --- a/pkg/handlers/handlers.go +++ b/pkg/handlers/handlers.go @@ -14,6 +14,7 @@ import ( kotsscheme "github.com/replicatedhq/kotskinds/client/kotsclientset/scheme" troubleshootscheme "github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/scheme" yaml "github.com/replicatedhq/yaml/v3" + velerov1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v1" "k8s.io/client-go/kubernetes/scheme" ) @@ -34,7 +35,7 @@ func NewHandler() *Handler { func init() { kotsscheme.AddToScheme(scheme.Scheme) troubleshootscheme.AddToScheme(scheme.Scheme) - veleroscheme.AddToScheme(scheme.Scheme) + velerov1.AddToScheme(scheme.Scheme) } func RegisterSessionAuthRoutes(r *mux.Router, kotsStore store.Store, handler KOTSHandler, middleware *policy.Middleware) { diff --git a/pkg/handlers/snapshot_logs.go b/pkg/handlers/snapshot_logs.go index c1cac4a8e2..1ae839b695 100644 --- a/pkg/handlers/snapshot_logs.go +++ b/pkg/handlers/snapshot_logs.go @@ -34,9 +34,9 @@ func (h *Handler) DownloadSnapshotLogs(w http.ResponseWriter, r *http.Request) { return } - veleroClient, err := veleroclientv1.NewForConfig(cfg) + veleroClient, err := k8sutil.GetVeleroKubeClient(r.Context()) if err != nil { - err = errors.Wrap(err, "failed to create velero clientset") + err = errors.Wrap(err, "failed to create velero client") logger.Error(err) w.WriteHeader(http.StatusInternalServerError) return diff --git a/pkg/informers/informers.go b/pkg/informers/informers.go index e5fb11f5c5..32b0510a72 100644 --- a/pkg/informers/informers.go +++ b/pkg/informers/informers.go @@ -16,6 +16,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/kubernetes" + kbclient "sigs.k8s.io/controller-runtime/pkg/client" ) // Start will start the kots informers @@ -38,12 +39,15 @@ func Start() error { return errors.Wrap(err, "failed to detect velero namespace") } - veleroClient, err := veleroclientv1.NewForConfig(cfg) + veleroClient, err := k8sutil.GetVeleroKubeClient(context.TODO()) if err != nil { - return errors.Wrap(err, "failed to create velero clientset") + return errors.Wrap(err, "failed to create velero client") } - backupWatch, err := veleroClient.Backups(veleroNamespace).Watch(context.TODO(), metav1.ListOptions{ResourceVersion: "0"}) + var backupList velerov1.BackupList + backupWatch, err := veleroClient.Watch(context.TODO(), &backupList, kbclient.InNamespace(veleroNamespace), &kbclient.ListOptions{ + Raw: &metav1.ListOptions{ResourceVersion: "0"}, + }) if err != nil { if kuberneteserrors.IsNotFound(err) { return nil @@ -85,7 +89,8 @@ func Start() error { backup.Annotations["kots.io/support-bundle-requested"] = time.Now().UTC().Format(time.RFC3339) - if _, err := veleroClient.Backups(backup.Namespace).Update(context.TODO(), backup, metav1.UpdateOptions{}); err != nil { + var backup velerov1.Backup + if err := veleroClient.Update(context.TODO(), &backup); err != nil { logger.Error(err) continue } @@ -96,14 +101,8 @@ func Start() error { continue } - updatedBackup, err := veleroClient.Backups(backup.Namespace).Get(context.TODO(), backup.Name, metav1.GetOptions{}) - if err != nil { - logger.Error(err) - continue - } - - updatedBackup.Annotations["kots.io/support-bundle-id"] = supportBundleID - if _, err := veleroClient.Backups(backup.Namespace).Update(context.TODO(), updatedBackup, metav1.UpdateOptions{}); err != nil { + backup.Annotations["kots.io/support-bundle-id"] = supportBundleID + if err := veleroClient.Update(context.TODO(), &backup); err != nil { logger.Error(err) continue } diff --git a/pkg/k8sutil/clientset.go b/pkg/k8sutil/clientset.go index 33a00e69df..0d0c7e7d7f 100644 --- a/pkg/k8sutil/clientset.go +++ b/pkg/k8sutil/clientset.go @@ -170,7 +170,7 @@ func GetKubeClient(ctx context.Context) (kbclient.Client, error) { return kcli, nil } -func GetVeleroKubeClient(ctx context.Context) (kbclient.Client, error) { +func GetVeleroKubeClient(ctx context.Context) (kbclient.WithWatch, error) { k8slogger := zap.New(func(o *zap.Options) { o.DestWriter = io.Discard }) @@ -181,7 +181,7 @@ func GetVeleroKubeClient(ctx context.Context) (kbclient.Client, error) { } scheme := runtime.NewScheme() velerov1.AddToScheme(scheme) - kcli, err := kbclient.New(cfg, kbclient.Options{ + kcli, err := kbclient.NewWithWatch(cfg, kbclient.Options{ Scheme: scheme, }) if err != nil { diff --git a/pkg/kotsadm/minio.go b/pkg/kotsadm/minio.go index f00536eebe..d16216a7dd 100644 --- a/pkg/kotsadm/minio.go +++ b/pkg/kotsadm/minio.go @@ -192,9 +192,9 @@ func MigrateExistingMinioFilesystemDeployments(log *logger.CLILogger, deployOpti return errors.Wrap(err, "failed to create clientset") } - veleroClient, err := veleroclientv1.NewForConfig(cfg) + veleroClient, err := k8sutil.GetVeleroKubeClient(context.TODO()) if err != nil { - return errors.Wrap(err, "failed to create velero clientset") + return errors.Wrap(err, "failed to create velero client") } bsl, err := snapshot.FindBackupStoreLocation(context.TODO(), clientset, veleroClient, deployOptions.Namespace) diff --git a/pkg/kotsadmsnapshot/backup.go b/pkg/kotsadmsnapshot/backup.go index bb0bc3edb4..87393eea5a 100644 --- a/pkg/kotsadmsnapshot/backup.go +++ b/pkg/kotsadmsnapshot/backup.go @@ -39,6 +39,7 @@ import ( "k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/labels" serializer "k8s.io/apimachinery/pkg/runtime/serializer/json" + k8stypes "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/validation" "k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes/scheme" @@ -712,9 +713,9 @@ func ListBackupsForApp(ctx context.Context, kotsadmNamespace string, appID strin return nil, errors.Wrap(err, "failed to create clientset") } - veleroClient, err := veleroclient.GetBuilder().GetVeleroClient(cfg) + veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) if err != nil { - return nil, errors.Wrap(err, "failed to create velero clientset") + return nil, errors.Wrap(err, "failed to create velero client") } backendStorageLocation, err := kotssnapshot.FindBackupStoreLocation(ctx, clientset, veleroClient, kotsadmNamespace) @@ -726,7 +727,8 @@ func ListBackupsForApp(ctx context.Context, kotsadmNamespace string, appID strin return nil, errors.New("no backup store location found") } - veleroBackups, err := veleroClient.Backups(backendStorageLocation.Namespace).List(ctx, metav1.ListOptions{}) + var veleroBackups velerov1.BackupList + err = veleroClient.List(ctx, &veleroBackups, ctrlclient.InNamespace(backendStorageLocation.Namespace)) if err != nil { return nil, errors.Wrap(err, "failed to list velero backups") } @@ -805,7 +807,7 @@ func ListInstanceBackups(ctx context.Context, kotsadmNamespace string) ([]*types return nil, errors.Wrap(err, "failed to create clientset") } - veleroClient, err := veleroclient.GetBuilder().GetVeleroClient(cfg) + veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) if err != nil { return nil, errors.Wrap(err, "failed to create velero clientset") } @@ -819,7 +821,8 @@ func ListInstanceBackups(ctx context.Context, kotsadmNamespace string) ([]*types return nil, errors.New("no backup store location found") } - veleroBackups, err := veleroClient.Backups(backendStorageLocation.Namespace).List(ctx, metav1.ListOptions{}) + var veleroBackups velerov1.BackupList + err = veleroClient.List(ctx, &veleroBackups, ctrlclient.InNamespace(backendStorageLocation.Namespace)) if err != nil { return nil, errors.Wrap(err, "failed to list velero backups") } @@ -934,18 +937,14 @@ func getAppsFromAppSequences(veleroBackup velerov1.Backup) ([]types.App, error) } func getSnapshotVolumeSummary(ctx context.Context, veleroBackup *velerov1.Backup) (*types.VolumeSummary, error) { - cfg, err := k8sutil.GetClusterConfig() - if err != nil { - return nil, errors.Wrap(err, "failed to get cluster config") - } - - veleroClient, err := veleroclient.GetBuilder().GetVeleroClient(cfg) + veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) if err != nil { - return nil, errors.Wrap(err, "failed to create clientset") + return nil, errors.Wrap(err, "failed to create client") } - veleroPodBackupVolumes, err := veleroClient.PodVolumeBackups(veleroBackup.Namespace).List(ctx, metav1.ListOptions{ - LabelSelector: fmt.Sprintf("velero.io/backup-name=%s", velerolabel.GetValidName(veleroBackup.Name)), + var veleroPodBackupVolumes velerov1.PodVolumeBackupList + err = veleroClient.List(ctx, &veleroPodBackupVolumes, ctrlclient.InNamespace(veleroBackup.Namespace), ctrlclient.MatchingLabels{ + "velero.io/backup-name": velerolabel.GetValidName(veleroBackup.Name), }) if err != nil { return nil, errors.Wrap(err, "failed to list pod back up volumes") @@ -985,7 +984,7 @@ func GetBackup(ctx context.Context, kotsadmNamespace string, backupID string) (* return nil, errors.Wrap(err, "failed to create clientset") } - veleroClient, err := veleroclient.GetBuilder().GetVeleroClient(cfg) + veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) if err != nil { return nil, errors.Wrap(err, "failed to create velero clientset") } @@ -1000,12 +999,13 @@ func GetBackup(ctx context.Context, kotsadmNamespace string, backupID string) (* veleroNamespace := bsl.Namespace - backup, err := veleroClient.Backups(veleroNamespace).Get(ctx, backupID, metav1.GetOptions{}) + var backup velerov1.Backup + err = veleroClient.Get(ctx, k8stypes.NamespacedName{Namespace: veleroNamespace, Name: backupID}, &backup) if err != nil { return nil, errors.Wrap(err, "failed to get backup") } - return backup, nil + return &backup, nil } func getBackupNameFromPrefix(appSlug string) string { @@ -1031,9 +1031,9 @@ func DeleteBackup(ctx context.Context, kotsadmNamespace string, backupID string) return errors.Wrap(err, "failed to create clientset") } - veleroClient, err := veleroclient.GetBuilder().GetVeleroClient(cfg) + veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) if err != nil { - return errors.Wrap(err, "failed to create velero clientset") + return errors.Wrap(err, "failed to create velero client") } bsl, err := kotssnapshot.FindBackupStoreLocation(ctx, clientset, veleroClient, kotsadmNamespace) @@ -1048,8 +1048,10 @@ func DeleteBackup(ctx context.Context, kotsadmNamespace string, backupID string) // Default legacy behaviour is to delete the backup whose name matches the backupID backupsToDelete := []string{backupID} - listOptions := metav1.ListOptions{LabelSelector: fmt.Sprintf("%s=%s", types.InstanceBackupNameLabel, backupID)} - veleroBackups, err := veleroClient.Backups(veleroNamespace).List(ctx, listOptions) + var veleroBackups velerov1.BackupList + err = veleroClient.List(ctx, &veleroBackups, ctrlclient.InNamespace(veleroNamespace), ctrlclient.MatchingLabels{ + types.InstanceBackupNameLabel: backupID, + }) if err != nil { return errors.Wrap(err, "failed to list velero backups for deletion") } @@ -1073,7 +1075,7 @@ func DeleteBackup(ctx context.Context, kotsadmNamespace string, backupID string) }, } - _, err = veleroClient.DeleteBackupRequests(veleroNamespace).Create(ctx, veleroDeleteBackupRequest, metav1.CreateOptions{}) + err = veleroClient.Create(ctx, veleroDeleteBackupRequest) if err != nil { return errors.Wrap(err, fmt.Sprintf("failed to create delete backup request for backup %s", backupToDelete)) } @@ -1123,9 +1125,9 @@ func GetBackupDetail(ctx context.Context, kotsadmNamespace string, backupName st return nil, errors.Wrap(err, "failed to create clientset") } - veleroClient, err := veleroclient.GetBuilder().GetVeleroClient(cfg) + veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) if err != nil { - return nil, errors.Wrap(err, "failed to create velero clientset") + return nil, errors.Wrap(err, "failed to create velero client") } backendStorageLocation, err := kotssnapshot.FindBackupStoreLocation(ctx, clientset, veleroClient, kotsadmNamespace) @@ -1157,10 +1159,11 @@ func GetBackupDetail(ctx context.Context, kotsadmNamespace string, backupName st // listBackupsByName returns a list of backups for the specified backup name. First it tries to get // the backup by the replicated.com/backup-name label, and if that fails, it tries to get the // backup by the metadata name. -func listBackupsByName(ctx context.Context, veleroClient veleroclientv1.VeleroV1Interface, veleroNamespace string, backupName string) ([]velerov1.Backup, error) { +func listBackupsByName(ctx context.Context, ctrlClient ctrlclient.Client, veleroNamespace string, backupName string) ([]velerov1.Backup, error) { // first try to get the backup from the backup-name label - backupList, err := veleroClient.Backups(veleroNamespace).List(ctx, metav1.ListOptions{ - LabelSelector: fmt.Sprintf("%s=%s", types.InstanceBackupNameLabel, velerolabel.GetValidName(backupName)), + var backupList velerov1.BackupList + err := ctrlClient.List(ctx, &backupList, ctrlclient.InNamespace(veleroNamespace), ctrlclient.MatchingLabels{ + types.InstanceBackupNameLabel: velerolabel.GetValidName(backupName), }) if err != nil { return nil, fmt.Errorf("failed to list backups by label: %w", err) @@ -1168,18 +1171,21 @@ func listBackupsByName(ctx context.Context, veleroClient veleroclientv1.VeleroV1 if len(backupList.Items) > 0 { return backupList.Items, nil } - backup, err := veleroClient.Backups(veleroNamespace).Get(ctx, backupName, metav1.GetOptions{}) + + var backup velerov1.Backup + err = ctrlClient.Get(ctx, k8stypes.NamespacedName{Namespace: veleroNamespace, Name: backupName}, &backup) if err != nil { return nil, fmt.Errorf("failed to get backup by name: %w", err) } - return []velerov1.Backup{*backup}, nil + return []velerov1.Backup{backup}, nil } // getBackupDetailForBackup returns a BackupDetail object for the specified backup. -func getBackupDetailForBackup(ctx context.Context, veleroClient veleroclientv1.VeleroV1Interface, veleroNamespace string, backup velerov1.Backup) (*types.BackupDetail, error) { - backupVolumes, err := veleroClient.PodVolumeBackups(veleroNamespace).List(ctx, metav1.ListOptions{ - LabelSelector: fmt.Sprintf("velero.io/backup-name=%s", velerolabel.GetValidName(backup.Name)), +func getBackupDetailForBackup(ctx context.Context, ctrlClient ctrlclient.Client, veleroNamespace string, backup velerov1.Backup) (*types.BackupDetail, error) { + backupVolumes := velerov1.PodVolumeBackupList{} + err := ctrlClient.List(ctx, &backupVolumes, ctrlclient.InNamespace(veleroNamespace), ctrlclient.MatchingLabels{ + "velero.io/backup-name": velerolabel.GetValidName(backup.Name), }) if err != nil { return nil, errors.Wrap(err, "failed to list volumes") diff --git a/pkg/kotsadmsnapshot/restore.go b/pkg/kotsadmsnapshot/restore.go index d935f5f758..d46025d03c 100644 --- a/pkg/kotsadmsnapshot/restore.go +++ b/pkg/kotsadmsnapshot/restore.go @@ -10,6 +10,7 @@ import ( units "github.com/docker/go-units" "github.com/pkg/errors" "github.com/replicatedhq/kots/pkg/k8sutil" + "github.com/replicatedhq/kots/pkg/kotsadmsnapshot/k8sclient" "github.com/replicatedhq/kots/pkg/kotsadmsnapshot/types" "github.com/replicatedhq/kots/pkg/logger" kotssnapshot "github.com/replicatedhq/kots/pkg/snapshot" @@ -17,8 +18,10 @@ import ( velerolabel "github.com/vmware-tanzu/velero/pkg/label" kuberneteserrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + k8stypes "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes" "k8s.io/utils/pointer" + kbclient "sigs.k8s.io/controller-runtime/pkg/client" ) func GetRestore(ctx context.Context, kotsadmNamespace string, restoreID string) (*velerov1.Restore, error) { @@ -32,9 +35,9 @@ func GetRestore(ctx context.Context, kotsadmNamespace string, restoreID string) return nil, errors.Wrap(err, "failed to create clientset") } - veleroClient, err := veleroclientv1.NewForConfig(cfg) + veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) if err != nil { - return nil, errors.Wrap(err, "failed to create velero clientset") + return nil, errors.Wrap(err, "failed to create velero client") } bsl, err := kotssnapshot.FindBackupStoreLocation(ctx, clientset, veleroClient, kotsadmNamespace) @@ -45,9 +48,9 @@ func GetRestore(ctx context.Context, kotsadmNamespace string, restoreID string) return nil, errors.New("no backup store location found") } + var restore velerov1.Restore veleroNamespace := bsl.Namespace - - restore, err := veleroClient.Restores(veleroNamespace).Get(ctx, restoreID, metav1.GetOptions{}) + err = veleroClient.Get(ctx, k8stypes.NamespacedName{Namespace: veleroNamespace, Name: restoreID}, &restore) if err != nil { if kuberneteserrors.IsNotFound(err) { return nil, nil @@ -55,7 +58,7 @@ func GetRestore(ctx context.Context, kotsadmNamespace string, restoreID string) return nil, errors.Wrap(err, "failed to get restore") } - return restore, nil + return &restore, nil } func CreateApplicationRestore(ctx context.Context, kotsadmNamespace string, backupID string, appSlug string) error { @@ -73,9 +76,9 @@ func CreateApplicationRestore(ctx context.Context, kotsadmNamespace string, back return errors.Wrap(err, "failed to create clientset") } - veleroClient, err := veleroclientv1.NewForConfig(cfg) + veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) if err != nil { - return errors.Wrap(err, "failed to create velero clientset") + return errors.Wrap(err, "failed to create velero client") } bsl, err := kotssnapshot.FindBackupStoreLocation(ctx, clientset, veleroClient, kotsadmNamespace) @@ -86,10 +89,11 @@ func CreateApplicationRestore(ctx context.Context, kotsadmNamespace string, back return errors.New("no backup store location found") } + var backup velerov1.Backup veleroNamespace := bsl.Namespace // get the backup - backup, err := veleroClient.Backups(veleroNamespace).Get(ctx, backupID, metav1.GetOptions{}) + err = veleroClient.Get(ctx, k8stypes.NamespacedName{Namespace: veleroNamespace, Name: backupID}, &backup) if err != nil { return errors.Wrap(err, "failed to find backup") } @@ -106,8 +110,8 @@ func CreateApplicationRestore(ctx context.Context, kotsadmNamespace string, back }, } - if types.IsInstanceBackup(*backup) { - if types.GetInstanceBackupType(*backup) != types.InstanceBackupTypeLegacy { + if types.IsInstanceBackup(backup) { + if types.GetInstanceBackupType(backup) != types.InstanceBackupTypeLegacy { return errors.New("only legacy type instance backups are restorable") } @@ -123,7 +127,7 @@ func CreateApplicationRestore(ctx context.Context, kotsadmNamespace string, back } } - _, err = veleroClient.Restores(veleroNamespace).Create(ctx, restore, metav1.CreateOptions{}) + err = veleroClient.Create(ctx, restore) if err != nil { return errors.Wrap(err, "failed to create restore") } @@ -142,9 +146,9 @@ func DeleteRestore(ctx context.Context, kotsadmNamespace string, restoreID strin return errors.Wrap(err, "failed to create clientset") } - veleroClient, err := veleroclientv1.NewForConfig(cfg) + veleroClient, err := k8sclient.GetBuilder().GetVeleroKubeClient(ctx) if err != nil { - return errors.Wrap(err, "failed to create velero clientset") + return errors.Wrap(err, "failed to create velero client") } bsl, err := kotssnapshot.FindBackupStoreLocation(ctx, clientset, veleroClient, kotsadmNamespace) @@ -153,10 +157,15 @@ func DeleteRestore(ctx context.Context, kotsadmNamespace string, restoreID strin } veleroNamespace := bsl.Namespace - - err = veleroClient.Restores(veleroNamespace).Delete(ctx, restoreID, metav1.DeleteOptions{}) + restore := velerov1.Restore{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: veleroNamespace, + Name: restoreID, + }, + } + err = veleroClient.Delete(ctx, &restore) if err != nil && !strings.Contains(err.Error(), "not found") { - return errors.Wrapf(err, "failed to delete restore %s", restoreID) + return errors.Wrapf(err, "failed to delete restore %s from namespace %s", restoreID, veleroNamespace) } return nil @@ -173,9 +182,9 @@ func GetRestoreDetails(ctx context.Context, kotsadmNamespace string, restoreID s return nil, errors.Wrap(err, "failed to create clientset") } - veleroClient, err := veleroclientv1.NewForConfig(cfg) + veleroClient, err := k8sclient.GetBuilder().GetVeleroKubeClient(ctx) if err != nil { - return nil, errors.Wrap(err, "failed to create velero clientset") + return nil, errors.Wrap(err, "failed to create velero client") } backendStorageLocation, err := kotssnapshot.FindBackupStoreLocation(ctx, clientset, veleroClient, kotsadmNamespace) @@ -187,14 +196,15 @@ func GetRestoreDetails(ctx context.Context, kotsadmNamespace string, restoreID s } veleroNamespace := backendStorageLocation.Namespace - - restore, err := veleroClient.Restores(veleroNamespace).Get(ctx, restoreID, metav1.GetOptions{}) + var restore velerov1.Restore + err = veleroClient.Get(ctx, k8stypes.NamespacedName{Namespace: veleroNamespace, Name: restoreID}, &restore) if err != nil { return nil, errors.Wrap(err, "failed to get restore") } - restoreVolumes, err := veleroClient.PodVolumeRestores(veleroNamespace).List(ctx, metav1.ListOptions{ - LabelSelector: fmt.Sprintf("velero.io/restore-name=%s", velerolabel.GetValidName(restore.Name)), + var restoreVolumes velerov1.PodVolumeRestoreList + err = veleroClient.List(ctx, &restoreVolumes, kbclient.MatchingLabels{ + "velero.io/restore-name": velerolabel.GetValidName(restore.Name), }) if err != nil { return nil, errors.Wrap(err, "failed to list volumes") @@ -217,7 +227,7 @@ func GetRestoreDetails(ctx context.Context, kotsadmNamespace string, restoreID s result.Errors = errs - filtered, err := filterWarnings(restore, warnings, &filterGetter{}) + filtered, err := filterWarnings(&restore, warnings, &filterGetter{}) if err != nil { logger.Infof("failed to filter warnings: %v", err) result.Warnings = warnings diff --git a/pkg/reporting/app.go b/pkg/reporting/app.go index 5421c919ca..b6661ab2a9 100644 --- a/pkg/reporting/app.go +++ b/pkg/reporting/app.go @@ -178,7 +178,7 @@ func GetReportingInfo(appID string) *types.ReportingInfo { r.IsGitOpsEnabled, r.GitOpsProvider = getGitOpsReport(clientset, appID, r.ClusterID) - veleroClient, err := veleroclientv1.NewForConfig(cfg) + veleroClient, err := k8sutil.GetVeleroKubeClient(context.TODO()) if err != nil { logger.Debugf("failed to get velero client: %v", err.Error()) } diff --git a/pkg/snapshot/restore.go b/pkg/snapshot/restore.go index 6eb5e48a6e..3214702ff8 100644 --- a/pkg/snapshot/restore.go +++ b/pkg/snapshot/restore.go @@ -69,11 +69,11 @@ func RestoreInstanceBackup(ctx context.Context, options RestoreInstanceBackupOpt } // make sure this is an instance backup - if !snapshottypes.IsInstanceBackup(*backup) { + if !snapshottypes.IsInstanceBackup(backup) { return errors.Wrap(err, "backup provided is not an instance backup") } - if snapshottypes.GetInstanceBackupType(*backup) != snapshottypes.InstanceBackupTypeLegacy { + if snapshottypes.GetInstanceBackupType(backup) != snapshottypes.InstanceBackupTypeLegacy { return errors.New("only legacy type instance backups are restorable") } @@ -308,11 +308,11 @@ func waitForVeleroRestoreCompleted(ctx context.Context, veleroNamespace string, switch restore.Status.Phase { case velerov1.RestorePhaseCompleted: - return restore, nil + return &restore, nil case velerov1.RestorePhaseFailed: - return restore, errors.New("restore failed") + return &restore, errors.New("restore failed") case velerov1.RestorePhasePartiallyFailed: - return restore, errors.New("restore partially failed") + return &restore, errors.New("restore partially failed") default: // in progress } diff --git a/pkg/snapshot/snapshot.go b/pkg/snapshot/snapshot.go index afd3e43915..6849aa8204 100644 --- a/pkg/snapshot/snapshot.go +++ b/pkg/snapshot/snapshot.go @@ -1,9 +1,10 @@ package snapshot import ( + velerov1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v1" "k8s.io/client-go/kubernetes/scheme" ) func init() { - veleroscheme.AddToScheme(scheme.Scheme) + velerov1.AddToScheme(scheme.Scheme) } diff --git a/pkg/snapshot/store.go b/pkg/snapshot/store.go index f758b695a3..f8babe29c1 100644 --- a/pkg/snapshot/store.go +++ b/pkg/snapshot/store.go @@ -42,7 +42,6 @@ import ( corev1 "k8s.io/api/core/v1" kuberneteserrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime/schema" k8stypes "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes" @@ -1630,8 +1629,8 @@ func resetBackupRepositories(ctx context.Context, veleroNamespace string) error } var repos velerov1.BackupRepositoryList - err = veleroClient.List(ctx, &repos, kbclient.InNamespace(veleroNamespace), &kbclient.ListOptions{ - LabelSelector: labels.SelectorFromSet(labels.Set{"velero.io/storage-location": "default"}), + err = veleroClient.List(ctx, &repos, kbclient.InNamespace(veleroNamespace), &kbclient.MatchingLabels{ + "velero.io/storage-location": "default", }) if err != nil && !kuberneteserrors.IsNotFound(err) { return errors.Wrap(err, "failed to list backuprepositories") diff --git a/pkg/store/kotsstore/kots_store.go b/pkg/store/kotsstore/kots_store.go index 53c6bbc193..e055c5a116 100644 --- a/pkg/store/kotsstore/kots_store.go +++ b/pkg/store/kotsstore/kots_store.go @@ -18,6 +18,7 @@ import ( "github.com/replicatedhq/kots/pkg/util" kotsscheme "github.com/replicatedhq/kotskinds/client/kotsclientset/scheme" troubleshootscheme "github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/scheme" + velerov1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v1" corev1 "k8s.io/api/core/v1" kuberneteserrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -37,7 +38,7 @@ type KOTSStore struct { func init() { kotsscheme.AddToScheme(scheme.Scheme) - veleroscheme.AddToScheme(scheme.Scheme) + velerov1.AddToScheme(scheme.Scheme) troubleshootscheme.AddToScheme(scheme.Scheme) } diff --git a/pkg/upgradeservice/handlers/handlers.go b/pkg/upgradeservice/handlers/handlers.go index 67cd478ac8..aefacae090 100644 --- a/pkg/upgradeservice/handlers/handlers.go +++ b/pkg/upgradeservice/handlers/handlers.go @@ -8,6 +8,7 @@ import ( "github.com/replicatedhq/kots/pkg/logger" kotsscheme "github.com/replicatedhq/kotskinds/client/kotsclientset/scheme" troubleshootscheme "github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/scheme" + velerov1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v1" "k8s.io/client-go/kubernetes/scheme" ) @@ -19,7 +20,7 @@ type Handler struct { func init() { kotsscheme.AddToScheme(scheme.Scheme) troubleshootscheme.AddToScheme(scheme.Scheme) - veleroscheme.AddToScheme(scheme.Scheme) + velerov1.AddToScheme(scheme.Scheme) } func RegisterAPIRoutes(r *mux.Router, handler UpgradeServiceHandler) { From 74ecee57a00d3b5fe94dcd80850e1ff401e7b8fc Mon Sep 17 00:00:00 2001 From: JGAntunes Date: Mon, 23 Dec 2024 20:23:21 +0000 Subject: [PATCH 3/5] chore: timestamp tests are driving me nuts --- pkg/kotsadmsnapshot/backup.go | 14 +- pkg/kotsadmsnapshot/backup_test.go | 339 +++++++++++------------------ pkg/snapshot/filesystem_lvp.go | 2 +- 3 files changed, 130 insertions(+), 225 deletions(-) diff --git a/pkg/kotsadmsnapshot/backup.go b/pkg/kotsadmsnapshot/backup.go index 87393eea5a..8aaa379ff3 100644 --- a/pkg/kotsadmsnapshot/backup.go +++ b/pkg/kotsadmsnapshot/backup.go @@ -236,7 +236,7 @@ func CreateInstanceBackup(ctx context.Context, cluster *downstreamtypes.Downstre return "", errors.Wrap(err, "failed to create clientset") } - ctrlClient, err := k8sutil.GetVeleroKubeClient(ctx) + ctrlClient, err := k8sclient.GetBuilder().GetVeleroKubeClient(ctx) if err != nil { return "", errors.Wrap(err, "failed to get kubeclient") } @@ -713,7 +713,7 @@ func ListBackupsForApp(ctx context.Context, kotsadmNamespace string, appID strin return nil, errors.Wrap(err, "failed to create clientset") } - veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) + veleroClient, err := k8sclient.GetBuilder().GetVeleroKubeClient(ctx) if err != nil { return nil, errors.Wrap(err, "failed to create velero client") } @@ -807,7 +807,7 @@ func ListInstanceBackups(ctx context.Context, kotsadmNamespace string) ([]*types return nil, errors.Wrap(err, "failed to create clientset") } - veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) + veleroClient, err := k8sclient.GetBuilder().GetVeleroKubeClient(ctx) if err != nil { return nil, errors.Wrap(err, "failed to create velero clientset") } @@ -937,7 +937,7 @@ func getAppsFromAppSequences(veleroBackup velerov1.Backup) ([]types.App, error) } func getSnapshotVolumeSummary(ctx context.Context, veleroBackup *velerov1.Backup) (*types.VolumeSummary, error) { - veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) + veleroClient, err := k8sclient.GetBuilder().GetVeleroKubeClient(ctx) if err != nil { return nil, errors.Wrap(err, "failed to create client") } @@ -984,7 +984,7 @@ func GetBackup(ctx context.Context, kotsadmNamespace string, backupID string) (* return nil, errors.Wrap(err, "failed to create clientset") } - veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) + veleroClient, err := k8sclient.GetBuilder().GetVeleroKubeClient(ctx) if err != nil { return nil, errors.Wrap(err, "failed to create velero clientset") } @@ -1031,7 +1031,7 @@ func DeleteBackup(ctx context.Context, kotsadmNamespace string, backupID string) return errors.Wrap(err, "failed to create clientset") } - veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) + veleroClient, err := k8sclient.GetBuilder().GetVeleroKubeClient(ctx) if err != nil { return errors.Wrap(err, "failed to create velero client") } @@ -1125,7 +1125,7 @@ func GetBackupDetail(ctx context.Context, kotsadmNamespace string, backupName st return nil, errors.Wrap(err, "failed to create clientset") } - veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) + veleroClient, err := k8sclient.GetBuilder().GetVeleroKubeClient(ctx) if err != nil { return nil, errors.Wrap(err, "failed to create velero client") } diff --git a/pkg/kotsadmsnapshot/backup_test.go b/pkg/kotsadmsnapshot/backup_test.go index 8b749464dc..ff4ac73d02 100644 --- a/pkg/kotsadmsnapshot/backup_test.go +++ b/pkg/kotsadmsnapshot/backup_test.go @@ -16,7 +16,6 @@ import ( kotsadmtypes "github.com/replicatedhq/kots/pkg/kotsadm/types" "github.com/replicatedhq/kots/pkg/kotsadmsnapshot/k8sclient" "github.com/replicatedhq/kots/pkg/kotsadmsnapshot/types" - "github.com/replicatedhq/kots/pkg/kotsadmsnapshot/veleroclient" "github.com/replicatedhq/kots/pkg/kotsutil" registrytypes "github.com/replicatedhq/kots/pkg/registry/types" "github.com/replicatedhq/kots/pkg/store" @@ -25,6 +24,7 @@ import ( kotsv1beta1 "github.com/replicatedhq/kotskinds/apis/kots/v1beta1" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + velerov1shrd "github.com/vmware-tanzu/velero/pkg/apis/velero/shared" velerov1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v1" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -2635,6 +2635,7 @@ func Test_getInstanceBackupMetadata(t *testing.T) { scheme := runtime.NewScheme() corev1.AddToScheme(scheme) embeddedclusterv1beta1.AddToScheme(scheme) + velerov1.AddToScheme(scheme) testBsl := &velerov1.BackupStorageLocation{ ObjectMeta: metav1.ObjectMeta{ @@ -2681,11 +2682,10 @@ func Test_getInstanceBackupMetadata(t *testing.T) { } type args struct { - k8sClient kubernetes.Interface - ctrlClient ctrlclient.Client - veleroClient veleroclientv1.VeleroV1Interface - cluster *downstreamtypes.Downstream - isScheduled bool + k8sClient kubernetes.Interface + ctrlClient ctrlclient.Client + cluster *downstreamtypes.Downstream + isScheduled bool } tests := []struct { name string @@ -2756,9 +2756,8 @@ spec: }) }, args: args{ - k8sClient: fake.NewSimpleClientset(veleroNamespaceConfigmap, veleroDeployment), - ctrlClient: ctrlclientfake.NewClientBuilder().WithScheme(scheme).WithObjects().Build(), - veleroClient: velerofake.NewSimpleClientset(testBsl).VeleroV1(), + k8sClient: fake.NewSimpleClientset(veleroNamespaceConfigmap, veleroDeployment), + ctrlClient: ctrlclientfake.NewClientBuilder().WithScheme(scheme).WithObjects(testBsl).Build(), cluster: &downstreamtypes.Downstream{ SnapshotTTL: "24h", }, @@ -2882,8 +2881,8 @@ spec: ctrlClient: ctrlclientfake.NewClientBuilder().WithScheme(scheme).WithObjects( &installation, seaweedFSS3Service, + testBsl, ).Build(), - veleroClient: velerofake.NewSimpleClientset(testBsl).VeleroV1(), cluster: &downstreamtypes.Downstream{ SnapshotTTL: "24h", }, @@ -2950,7 +2949,7 @@ spec: tt.setup(t, mockStore) } - got, err := getInstanceBackupMetadata(context.Background(), tt.args.k8sClient, tt.args.ctrlClient, tt.args.veleroClient, tt.args.cluster, tt.args.isScheduled) + got, err := getInstanceBackupMetadata(context.Background(), tt.args.k8sClient, tt.args.ctrlClient, tt.args.cluster, tt.args.isScheduled) if tt.wantErr { require.Error(t, err) } else { @@ -3017,11 +3016,12 @@ func TestListBackupsForApp(t *testing.T) { scheme := runtime.NewScheme() corev1.AddToScheme(scheme) embeddedclusterv1beta1.AddToScheme(scheme) + velerov1.AddToScheme(scheme) // setup timestamps - startTs := time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC) - completionTs := time.Date(2024, 1, 2, 0, 0, 0, 0, time.UTC) - expirationTs := time.Date(2025, 1, 2, 0, 0, 0, 0, time.UTC) + startTs := metav1.Date(2024, 1, 1, 0, 0, 0, 0, time.Local) + completionTs := metav1.Date(2024, 1, 2, 0, 0, 0, 0, time.Local) + expirationTs := metav1.Date(2025, 1, 2, 0, 0, 0, 0, time.Local) // setup common mock objects kotsadmNamespace := "kotsadm-test" @@ -3052,45 +3052,28 @@ func TestListBackupsForApp(t *testing.T) { } tests := []struct { - name string - appID string - veleroClientBuilder veleroclient.VeleroClientBuilder - k8sClientBuilder k8sclient.K8sClientsetBuilder - expectedBackups []*types.Backup - wantErr string + name string + appID string + k8sClientBuilder k8sclient.K8sClientsBuilder + expectedBackups []*types.Backup + wantErr string }{ { name: "fails to create k8s clientset", appID: "app-1", k8sClientBuilder: &k8sclient.MockBuilder{ - Client: nil, - Err: fmt.Errorf("error creating k8s clientset"), - }, - veleroClientBuilder: &veleroclient.MockBuilder{ - Client: velerofake.NewSimpleClientset().VeleroV1(), + Clientset: nil, + CtrlClient: ctrlclientfake.NewClientBuilder().WithScheme(scheme).Build(), + Err: fmt.Errorf("error creating k8s clientset"), }, wantErr: "failed to create clientset", }, - { - name: "fails to create velero client", - appID: "app-1", - k8sClientBuilder: &k8sclient.MockBuilder{ - Client: fake.NewSimpleClientset(), - }, - veleroClientBuilder: &veleroclient.MockBuilder{ - Client: nil, - Err: fmt.Errorf("error creating velero client"), - }, - wantErr: "failed to create velero clientset", - }, { name: "fails to find backup storage location", appID: "app-1", k8sClientBuilder: &k8sclient.MockBuilder{ - Client: fake.NewSimpleClientset(), - }, - veleroClientBuilder: &veleroclient.MockBuilder{ - Client: velerofake.NewSimpleClientset().VeleroV1(), + Clientset: fake.NewSimpleClientset(), + CtrlClient: ctrlclientfake.NewClientBuilder().WithScheme(scheme).Build(), }, wantErr: "no backup store location found", }, @@ -3098,15 +3081,11 @@ func TestListBackupsForApp(t *testing.T) { name: "empty backup list", appID: "app-1", k8sClientBuilder: &k8sclient.MockBuilder{ - Client: fake.NewSimpleClientset( + Clientset: fake.NewSimpleClientset( veleroNamespaceConfigmap, veleroDeployment, ), - }, - veleroClientBuilder: &veleroclient.MockBuilder{ - Client: velerofake.NewSimpleClientset( - testBsl, - ).VeleroV1(), + CtrlClient: ctrlclientfake.NewClientBuilder().WithScheme(scheme).WithObjects(testBsl).Build(), }, expectedBackups: []*types.Backup{}, }, @@ -3114,13 +3093,11 @@ func TestListBackupsForApp(t *testing.T) { name: "backups not matching the app id are excluded", appID: "app-1", k8sClientBuilder: &k8sclient.MockBuilder{ - Client: fake.NewSimpleClientset( + Clientset: fake.NewSimpleClientset( veleroNamespaceConfigmap, veleroDeployment, ), - }, - veleroClientBuilder: &veleroclient.MockBuilder{ - Client: velerofake.NewSimpleClientset( + CtrlClient: ctrlclientfake.NewClientBuilder().WithScheme(scheme).WithObjects( testBsl, &velerov1.Backup{ ObjectMeta: metav1.ObjectMeta{ @@ -3158,7 +3135,7 @@ func TestListBackupsForApp(t *testing.T) { Phase: velerov1.BackupPhaseCompleted, }, }, - ).VeleroV1(), + ).Build(), }, expectedBackups: []*types.Backup{ { @@ -3175,13 +3152,11 @@ func TestListBackupsForApp(t *testing.T) { name: "timestamps are populated", appID: "app-1", k8sClientBuilder: &k8sclient.MockBuilder{ - Client: fake.NewSimpleClientset( + Clientset: fake.NewSimpleClientset( veleroNamespaceConfigmap, veleroDeployment, ), - }, - veleroClientBuilder: &veleroclient.MockBuilder{ - Client: velerofake.NewSimpleClientset( + CtrlClient: ctrlclientfake.NewClientBuilder().WithScheme(scheme).WithObjects( testBsl, &velerov1.Backup{ ObjectMeta: metav1.ObjectMeta{ @@ -3193,21 +3168,21 @@ func TestListBackupsForApp(t *testing.T) { }, Status: velerov1.BackupStatus{ Phase: velerov1.BackupPhaseCompleted, - StartTimestamp: &metav1.Time{Time: startTs}, - CompletionTimestamp: &metav1.Time{Time: completionTs}, - Expiration: &metav1.Time{Time: expirationTs}, + StartTimestamp: &startTs, + CompletionTimestamp: &completionTs, + Expiration: &expirationTs, }, }, - ).VeleroV1(), + ).Build(), }, expectedBackups: []*types.Backup{ { AppID: "app-1", Name: "app-backup-app-1", Status: "Completed", - StartedAt: &startTs, - FinishedAt: &completionTs, - ExpiresAt: &expirationTs, + StartedAt: &startTs.Time, + FinishedAt: &completionTs.Time, + ExpiresAt: &expirationTs.Time, VolumeSummary: types.VolumeSummary{ VolumeSizeHuman: "0B", }, @@ -3218,13 +3193,11 @@ func TestListBackupsForApp(t *testing.T) { name: "volume info is populated from pod volume backups", appID: "app-1", k8sClientBuilder: &k8sclient.MockBuilder{ - Client: fake.NewSimpleClientset( + Clientset: fake.NewSimpleClientset( veleroNamespaceConfigmap, veleroDeployment, ), - }, - veleroClientBuilder: &veleroclient.MockBuilder{ - Client: velerofake.NewSimpleClientset( + CtrlClient: ctrlclientfake.NewClientBuilder().WithScheme(scheme).WithObjects( testBsl, &velerov1.Backup{ ObjectMeta: metav1.ObjectMeta{ @@ -3249,12 +3222,12 @@ func TestListBackupsForApp(t *testing.T) { }, Status: velerov1.PodVolumeBackupStatus{ Phase: velerov1.PodVolumeBackupPhaseCompleted, - Progress: velerov1.PodVolumeOperationProgress{ + Progress: velerov1shrd.DataMoveOperationProgress{ BytesDone: 2000, }, }, }, - ).VeleroV1(), + ).Build(), }, expectedBackups: []*types.Backup{ { @@ -3278,7 +3251,6 @@ func TestListBackupsForApp(t *testing.T) { asrt := assert.New(t) // setup mock clients k8sclient.SetBuilder(test.k8sClientBuilder) - veleroclient.SetBuilder(test.veleroClientBuilder) backups, err := ListBackupsForApp(context.Background(), kotsadmNamespace, test.appID) @@ -3297,6 +3269,7 @@ func TestListInstanceBackups(t *testing.T) { scheme := runtime.NewScheme() corev1.AddToScheme(scheme) embeddedclusterv1beta1.AddToScheme(scheme) + velerov1.AddToScheme(scheme) // setup timestamps startTs := time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC) @@ -3332,70 +3305,46 @@ func TestListInstanceBackups(t *testing.T) { } tests := []struct { - name string - setup func(mockStore *mock_store.MockStore) - veleroClientBuilder veleroclient.VeleroClientBuilder - k8sClientBuilder k8sclient.K8sClientsetBuilder - expectedBackups []*types.Backup - wantErr string + name string + setup func(mockStore *mock_store.MockStore) + k8sClientBuilder k8sclient.K8sClientsBuilder + expectedBackups []*types.Backup + wantErr string }{ { name: "fails to create k8s clientset", k8sClientBuilder: &k8sclient.MockBuilder{ - Client: nil, - Err: fmt.Errorf("error creating k8s clientset"), - }, - veleroClientBuilder: &veleroclient.MockBuilder{ - Client: velerofake.NewSimpleClientset().VeleroV1(), + Err: fmt.Errorf("error creating k8s clientset"), }, wantErr: "failed to create clientset", }, - { - name: "fails to create velero client", - k8sClientBuilder: &k8sclient.MockBuilder{ - Client: fake.NewSimpleClientset(), - }, - veleroClientBuilder: &veleroclient.MockBuilder{ - Client: nil, - Err: fmt.Errorf("error creating velero client"), - }, - wantErr: "failed to create velero clientset", - }, { name: "fails to find backup storage location", k8sClientBuilder: &k8sclient.MockBuilder{ - Client: fake.NewSimpleClientset(), - }, - veleroClientBuilder: &veleroclient.MockBuilder{ - Client: velerofake.NewSimpleClientset().VeleroV1(), + Clientset: fake.NewSimpleClientset(), + CtrlClient: ctrlclientfake.NewClientBuilder().WithScheme(scheme).Build(), }, wantErr: "no backup store location found", }, { name: "empty backup list", k8sClientBuilder: &k8sclient.MockBuilder{ - Client: fake.NewSimpleClientset( + Clientset: fake.NewSimpleClientset( veleroNamespaceConfigmap, veleroDeployment, ), - }, - veleroClientBuilder: &veleroclient.MockBuilder{ - Client: velerofake.NewSimpleClientset( - testBsl, - ).VeleroV1(), + CtrlClient: ctrlclientfake.NewClientBuilder().WithScheme(scheme).WithObjects(testBsl).Build(), }, expectedBackups: []*types.Backup{}, }, { name: "non instance backups are excluded", k8sClientBuilder: &k8sclient.MockBuilder{ - Client: fake.NewSimpleClientset( + Clientset: fake.NewSimpleClientset( veleroNamespaceConfigmap, veleroDeployment, ), - }, - veleroClientBuilder: &veleroclient.MockBuilder{ - Client: velerofake.NewSimpleClientset( + CtrlClient: ctrlclientfake.NewClientBuilder().WithScheme(scheme).WithObjects( testBsl, &velerov1.Backup{ ObjectMeta: metav1.ObjectMeta{ @@ -3418,7 +3367,7 @@ func TestListInstanceBackups(t *testing.T) { Phase: velerov1.BackupPhaseCompleted, }, }, - ).VeleroV1(), + ).Build(), }, expectedBackups: []*types.Backup{ { @@ -3436,13 +3385,11 @@ func TestListInstanceBackups(t *testing.T) { { name: "new improved dr backups are part of the same replicated backup", k8sClientBuilder: &k8sclient.MockBuilder{ - Client: fake.NewSimpleClientset( + Clientset: fake.NewSimpleClientset( veleroNamespaceConfigmap, veleroDeployment, ), - }, - veleroClientBuilder: &veleroclient.MockBuilder{ - Client: velerofake.NewSimpleClientset( + CtrlClient: ctrlclientfake.NewClientBuilder().WithScheme(scheme).WithObjects( testBsl, &velerov1.Backup{ ObjectMeta: metav1.ObjectMeta{ @@ -3480,7 +3427,7 @@ func TestListInstanceBackups(t *testing.T) { Phase: velerov1.BackupPhaseCompleted, }, }, - ).VeleroV1(), + ).Build(), }, expectedBackups: []*types.Backup{ { @@ -3506,13 +3453,11 @@ func TestListInstanceBackups(t *testing.T) { }, nil) }, k8sClientBuilder: &k8sclient.MockBuilder{ - Client: fake.NewSimpleClientset( + Clientset: fake.NewSimpleClientset( veleroNamespaceConfigmap, veleroDeployment, ), - }, - veleroClientBuilder: &veleroclient.MockBuilder{ - Client: velerofake.NewSimpleClientset( + CtrlClient: ctrlclientfake.NewClientBuilder().WithScheme(scheme).WithObjects( testBsl, &velerov1.Backup{ ObjectMeta: metav1.ObjectMeta{ @@ -3527,7 +3472,7 @@ func TestListInstanceBackups(t *testing.T) { Phase: velerov1.BackupPhaseCompleted, }, }, - ).VeleroV1(), + ).Build(), }, expectedBackups: []*types.Backup{ { @@ -3566,13 +3511,11 @@ func TestListInstanceBackups(t *testing.T) { }, nil) }, k8sClientBuilder: &k8sclient.MockBuilder{ - Client: fake.NewSimpleClientset( + Clientset: fake.NewSimpleClientset( veleroNamespaceConfigmap, veleroDeployment, ), - }, - veleroClientBuilder: &veleroclient.MockBuilder{ - Client: velerofake.NewSimpleClientset( + CtrlClient: ctrlclientfake.NewClientBuilder().WithScheme(scheme).WithObjects( testBsl, &velerov1.Backup{ ObjectMeta: metav1.ObjectMeta{ @@ -3612,7 +3555,7 @@ func TestListInstanceBackups(t *testing.T) { Phase: velerov1.BackupPhaseCompleted, }, }, - ).VeleroV1(), + ).Build(), }, expectedBackups: []*types.Backup{ { @@ -3643,13 +3586,11 @@ func TestListInstanceBackups(t *testing.T) { { name: "timestamps are populated", k8sClientBuilder: &k8sclient.MockBuilder{ - Client: fake.NewSimpleClientset( + Clientset: fake.NewSimpleClientset( veleroNamespaceConfigmap, veleroDeployment, ), - }, - veleroClientBuilder: &veleroclient.MockBuilder{ - Client: velerofake.NewSimpleClientset( + CtrlClient: ctrlclientfake.NewClientBuilder().WithScheme(scheme).WithObjects( testBsl, &velerov1.Backup{ ObjectMeta: metav1.ObjectMeta{ @@ -3666,7 +3607,7 @@ func TestListInstanceBackups(t *testing.T) { Expiration: &metav1.Time{Time: expirationTs}, }, }, - ).VeleroV1(), + ).Build(), }, expectedBackups: []*types.Backup{ { @@ -3687,13 +3628,11 @@ func TestListInstanceBackups(t *testing.T) { { name: "if improved dr, timestamps are populated based on the timestamps of the included backups", k8sClientBuilder: &k8sclient.MockBuilder{ - Client: fake.NewSimpleClientset( + Clientset: fake.NewSimpleClientset( veleroNamespaceConfigmap, veleroDeployment, ), - }, - veleroClientBuilder: &veleroclient.MockBuilder{ - Client: velerofake.NewSimpleClientset( + CtrlClient: ctrlclientfake.NewClientBuilder().WithScheme(scheme).WithObjects( testBsl, &velerov1.Backup{ ObjectMeta: metav1.ObjectMeta{ @@ -3712,8 +3651,8 @@ func TestListInstanceBackups(t *testing.T) { Status: velerov1.BackupStatus{ Phase: velerov1.BackupPhaseCompleted, StartTimestamp: &metav1.Time{Time: startTs}, - CompletionTimestamp: &metav1.Time{Time: completionTs.Add(-1 * time.Minute)}, - Expiration: &metav1.Time{Time: expirationTs.Add(1 * time.Minute)}, + CompletionTimestamp: &metav1.Time{Time: completionTs.Add(-1 * time.Minute).UTC()}, + Expiration: &metav1.Time{Time: expirationTs.Add(1 * time.Minute).UTC()}, }, }, &velerov1.Backup{ @@ -3732,12 +3671,12 @@ func TestListInstanceBackups(t *testing.T) { }, Status: velerov1.BackupStatus{ Phase: velerov1.BackupPhaseCompleted, - StartTimestamp: &metav1.Time{Time: startTs.Add(1 * time.Minute)}, + StartTimestamp: &metav1.Time{Time: startTs.Add(1 * time.Minute).UTC()}, CompletionTimestamp: &metav1.Time{Time: completionTs}, Expiration: &metav1.Time{Time: expirationTs}, }, }, - ).VeleroV1(), + ).Build(), }, expectedBackups: []*types.Backup{ { @@ -3758,13 +3697,11 @@ func TestListInstanceBackups(t *testing.T) { { name: "volume info is populated from pod volume backups", k8sClientBuilder: &k8sclient.MockBuilder{ - Client: fake.NewSimpleClientset( + Clientset: fake.NewSimpleClientset( veleroNamespaceConfigmap, veleroDeployment, ), - }, - veleroClientBuilder: &veleroclient.MockBuilder{ - Client: velerofake.NewSimpleClientset( + CtrlClient: ctrlclientfake.NewClientBuilder().WithScheme(scheme).WithObjects( testBsl, &velerov1.Backup{ ObjectMeta: metav1.ObjectMeta{ @@ -3789,12 +3726,12 @@ func TestListInstanceBackups(t *testing.T) { }, Status: velerov1.PodVolumeBackupStatus{ Phase: velerov1.PodVolumeBackupPhaseCompleted, - Progress: velerov1.PodVolumeOperationProgress{ + Progress: velerov1shrd.DataMoveOperationProgress{ BytesDone: 2000, }, }, }, - ).VeleroV1(), + ).Build(), }, expectedBackups: []*types.Backup{ { @@ -3816,13 +3753,11 @@ func TestListInstanceBackups(t *testing.T) { { name: "if improved dr, volume info is populated from pod volume backups from both backups", k8sClientBuilder: &k8sclient.MockBuilder{ - Client: fake.NewSimpleClientset( + Clientset: fake.NewSimpleClientset( veleroNamespaceConfigmap, veleroDeployment, ), - }, - veleroClientBuilder: &veleroclient.MockBuilder{ - Client: velerofake.NewSimpleClientset( + CtrlClient: ctrlclientfake.NewClientBuilder().WithScheme(scheme).WithObjects( testBsl, &velerov1.Backup{ ObjectMeta: metav1.ObjectMeta{ @@ -3870,7 +3805,7 @@ func TestListInstanceBackups(t *testing.T) { }, Status: velerov1.PodVolumeBackupStatus{ Phase: velerov1.PodVolumeBackupPhaseCompleted, - Progress: velerov1.PodVolumeOperationProgress{ + Progress: velerov1shrd.DataMoveOperationProgress{ BytesDone: 2000, }, }, @@ -3885,12 +3820,12 @@ func TestListInstanceBackups(t *testing.T) { }, Status: velerov1.PodVolumeBackupStatus{ Phase: velerov1.PodVolumeBackupPhaseCompleted, - Progress: velerov1.PodVolumeOperationProgress{ + Progress: velerov1shrd.DataMoveOperationProgress{ BytesDone: 3000, }, }, }, - ).VeleroV1(), + ).Build(), }, expectedBackups: []*types.Backup{ { @@ -3911,13 +3846,11 @@ func TestListInstanceBackups(t *testing.T) { { name: "if expected backup count is not equal to actual backup count, it is marked as failed", k8sClientBuilder: &k8sclient.MockBuilder{ - Client: fake.NewSimpleClientset( + Clientset: fake.NewSimpleClientset( veleroNamespaceConfigmap, veleroDeployment, ), - }, - veleroClientBuilder: &veleroclient.MockBuilder{ - Client: velerofake.NewSimpleClientset( + CtrlClient: ctrlclientfake.NewClientBuilder().WithScheme(scheme).WithObjects( testBsl, &velerov1.Backup{ ObjectMeta: metav1.ObjectMeta{ @@ -3937,7 +3870,7 @@ func TestListInstanceBackups(t *testing.T) { Phase: velerov1.BackupPhaseCompleted, }, }, - ).VeleroV1(), + ).Build(), }, expectedBackups: []*types.Backup{ { @@ -3955,13 +3888,11 @@ func TestListInstanceBackups(t *testing.T) { { name: "status is in progress if any of the backups are in progress", k8sClientBuilder: &k8sclient.MockBuilder{ - Client: fake.NewSimpleClientset( + Clientset: fake.NewSimpleClientset( veleroNamespaceConfigmap, veleroDeployment, ), - }, - veleroClientBuilder: &veleroclient.MockBuilder{ - Client: velerofake.NewSimpleClientset( + CtrlClient: ctrlclientfake.NewClientBuilder().WithScheme(scheme).WithObjects( testBsl, &velerov1.Backup{ ObjectMeta: metav1.ObjectMeta{ @@ -3999,7 +3930,7 @@ func TestListInstanceBackups(t *testing.T) { Phase: velerov1.BackupPhaseInProgress, }, }, - ).VeleroV1(), + ).Build(), }, expectedBackups: []*types.Backup{ { @@ -4017,13 +3948,11 @@ func TestListInstanceBackups(t *testing.T) { { name: "status is deleting if any of the backups are deleting and none is in progress", k8sClientBuilder: &k8sclient.MockBuilder{ - Client: fake.NewSimpleClientset( + Clientset: fake.NewSimpleClientset( veleroNamespaceConfigmap, veleroDeployment, ), - }, - veleroClientBuilder: &veleroclient.MockBuilder{ - Client: velerofake.NewSimpleClientset( + CtrlClient: ctrlclientfake.NewClientBuilder().WithScheme(scheme).WithObjects( testBsl, &velerov1.Backup{ ObjectMeta: metav1.ObjectMeta{ @@ -4061,7 +3990,7 @@ func TestListInstanceBackups(t *testing.T) { Phase: velerov1.BackupPhaseDeleting, }, }, - ).VeleroV1(), + ).Build(), }, expectedBackups: []*types.Backup{ { @@ -4079,13 +4008,11 @@ func TestListInstanceBackups(t *testing.T) { { name: "status is failed if one backup is failed and the other completed", k8sClientBuilder: &k8sclient.MockBuilder{ - Client: fake.NewSimpleClientset( + Clientset: fake.NewSimpleClientset( veleroNamespaceConfigmap, veleroDeployment, ), - }, - veleroClientBuilder: &veleroclient.MockBuilder{ - Client: velerofake.NewSimpleClientset( + CtrlClient: ctrlclientfake.NewClientBuilder().WithScheme(scheme).WithObjects( testBsl, &velerov1.Backup{ ObjectMeta: metav1.ObjectMeta{ @@ -4123,7 +4050,7 @@ func TestListInstanceBackups(t *testing.T) { Phase: velerov1.BackupPhaseFailed, }, }, - ).VeleroV1(), + ).Build(), }, expectedBackups: []*types.Backup{ { @@ -4145,7 +4072,6 @@ func TestListInstanceBackups(t *testing.T) { asrt := assert.New(t) // setup mock clients k8sclient.SetBuilder(test.k8sClientBuilder) - veleroclient.SetBuilder(test.veleroClientBuilder) // setup mock store ctrl := gomock.NewController(t) defer ctrl.Finish() @@ -4240,6 +4166,7 @@ func TestDeleteBackup(t *testing.T) { scheme := runtime.NewScheme() corev1.AddToScheme(scheme) embeddedclusterv1beta1.AddToScheme(scheme) + velerov1.AddToScheme(scheme) // setup common mock objects kotsadmNamespace := "kotsadm-test" @@ -4272,40 +4199,23 @@ func TestDeleteBackup(t *testing.T) { tests := []struct { name string backupToDelete string - veleroClientBuilder veleroclient.VeleroClientBuilder - k8sClientBuilder k8sclient.K8sClientsetBuilder + k8sClientBuilder k8sclient.K8sClientsBuilder expectedDeleteBackupRequests []velerov1.DeleteBackupRequest wantErr string }{ { name: "fails to create k8s clientset", k8sClientBuilder: &k8sclient.MockBuilder{ - Client: nil, - Err: fmt.Errorf("error creating k8s clientset"), - }, - veleroClientBuilder: &veleroclient.MockBuilder{ - Client: velerofake.NewSimpleClientset().VeleroV1(), + Clientset: nil, + Err: fmt.Errorf("error creating k8s clientset"), }, wantErr: "failed to create clientset", }, - { - name: "fails to create velero client", - k8sClientBuilder: &k8sclient.MockBuilder{ - Client: fake.NewSimpleClientset(), - }, - veleroClientBuilder: &veleroclient.MockBuilder{ - Client: nil, - Err: fmt.Errorf("error creating velero client"), - }, - wantErr: "failed to create velero clientset", - }, { name: "fails to find backup storage location", k8sClientBuilder: &k8sclient.MockBuilder{ - Client: fake.NewSimpleClientset(), - }, - veleroClientBuilder: &veleroclient.MockBuilder{ - Client: velerofake.NewSimpleClientset().VeleroV1(), + Clientset: fake.NewSimpleClientset(), + CtrlClient: ctrlclientfake.NewClientBuilder().WithScheme(scheme).Build(), }, wantErr: "no backup store location found", }, @@ -4313,21 +4223,18 @@ func TestDeleteBackup(t *testing.T) { name: "should issue a single delete backup request for the provided id if no backups with label name exist", backupToDelete: "test-backup", k8sClientBuilder: &k8sclient.MockBuilder{ - Client: fake.NewSimpleClientset( + Clientset: fake.NewSimpleClientset( veleroNamespaceConfigmap, veleroDeployment, ), - }, - veleroClientBuilder: &veleroclient.MockBuilder{ - Client: velerofake.NewSimpleClientset( - testBsl, - ).VeleroV1(), + CtrlClient: ctrlclientfake.NewClientBuilder().WithScheme(scheme).WithObjects(testBsl).Build(), }, expectedDeleteBackupRequests: []velerov1.DeleteBackupRequest{ { ObjectMeta: metav1.ObjectMeta{ - Name: "test-backup", - Namespace: "velero", + Name: "test-backup", + Namespace: "velero", + ResourceVersion: "1", }, Spec: velerov1.DeleteBackupRequestSpec{ BackupName: "test-backup", @@ -4339,13 +4246,11 @@ func TestDeleteBackup(t *testing.T) { name: "should issue two delete backup requests for the provided id if two backups with label name exist", backupToDelete: "aggregated-repl-backup", k8sClientBuilder: &k8sclient.MockBuilder{ - Client: fake.NewSimpleClientset( + Clientset: fake.NewSimpleClientset( veleroNamespaceConfigmap, veleroDeployment, ), - }, - veleroClientBuilder: &veleroclient.MockBuilder{ - Client: velerofake.NewSimpleClientset( + CtrlClient: ctrlclientfake.NewClientBuilder().WithScheme(scheme).WithObjects( testBsl, &velerov1.Backup{ ObjectMeta: metav1.ObjectMeta{ @@ -4381,13 +4286,14 @@ func TestDeleteBackup(t *testing.T) { Phase: velerov1.BackupPhaseCompleted, }, }, - ).VeleroV1(), + ).Build(), }, expectedDeleteBackupRequests: []velerov1.DeleteBackupRequest{ { ObjectMeta: metav1.ObjectMeta{ - Name: "app-backup", - Namespace: "velero", + Name: "app-backup", + Namespace: "velero", + ResourceVersion: "1", }, Spec: velerov1.DeleteBackupRequestSpec{ BackupName: "app-backup", @@ -4395,8 +4301,9 @@ func TestDeleteBackup(t *testing.T) { }, { ObjectMeta: metav1.ObjectMeta{ - Name: "infra-backup", - Namespace: "velero", + Name: "infra-backup", + Namespace: "velero", + ResourceVersion: "1", }, Spec: velerov1.DeleteBackupRequestSpec{ BackupName: "infra-backup", @@ -4412,7 +4319,6 @@ func TestDeleteBackup(t *testing.T) { req := require.New(t) // setup mock clients k8sclient.SetBuilder(test.k8sClientBuilder) - veleroclient.SetBuilder(test.veleroClientBuilder) err := DeleteBackup(context.Background(), kotsadmNamespace, test.backupToDelete) @@ -4425,12 +4331,13 @@ func TestDeleteBackup(t *testing.T) { if test.expectedDeleteBackupRequests != nil { // verify delete backup requests - veleroClient, err := test.veleroClientBuilder.GetVeleroClient(nil) + veleroClient, err := test.k8sClientBuilder.GetVeleroKubeClient(context.Background()) req.NoError(err) - requests, err := veleroClient.DeleteBackupRequests("velero").List(context.Background(), metav1.ListOptions{}) + var deleteBackupRequests velerov1.DeleteBackupRequestList + err = veleroClient.List(context.Background(), &deleteBackupRequests, ctrlclient.InNamespace("velero")) req.NoError(err) - asrt.Equal(test.expectedDeleteBackupRequests, requests.Items) + asrt.Equal(test.expectedDeleteBackupRequests, deleteBackupRequests.Items) } }) } @@ -4458,7 +4365,7 @@ func TestGetBackupDetail(t *testing.T) { }, } - veleroObjects := []runtime.Object{ + veleroObjects := []ctrlclient.Object{ &velerov1.BackupStorageLocation{ ObjectMeta: metav1.ObjectMeta{ Name: "default", @@ -4608,10 +4515,8 @@ func TestGetBackupDetail(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { k8sclient.SetBuilder(&k8sclient.MockBuilder{ - Client: fake.NewSimpleClientset(objects...), - }) - veleroclient.SetBuilder(&veleroclient.MockBuilder{ - Client: velerofake.NewSimpleClientset(veleroObjects...).VeleroV1(), + Clientset: fake.NewSimpleClientset(objects...), + CtrlClient: ctrlclientfake.NewClientBuilder().WithScheme(scheme).WithObjects(veleroObjects...).Build(), }) got, err := GetBackupDetail(context.Background(), "velero", tt.args.backupName) if tt.wantErr { diff --git a/pkg/snapshot/filesystem_lvp.go b/pkg/snapshot/filesystem_lvp.go index 53cd748c07..b1e76adb21 100644 --- a/pkg/snapshot/filesystem_lvp.go +++ b/pkg/snapshot/filesystem_lvp.go @@ -115,7 +115,7 @@ func GetCurrentLvpFileSystemConfig(ctx context.Context, namespace string) (*type // RevertToMinioFS will apply the spec of the previous BSL to the current one and then update. // Used for recovery during a failed migration from Minio to LVP. func RevertToMinioFS(ctx context.Context, clientset kubernetes.Interface, ctrlclient kbclient.Client, kotsadmNamespace, veleroNamespace string, previousBsl *velerov1api.BackupStorageLocation) error { - bsl, err := FindBackupStoreLocation(context.TODO(), clientset, ctrlclient, kotsadmNamespace) + bsl, err := FindBackupStoreLocation(ctx, clientset, ctrlclient, kotsadmNamespace) if err != nil { return errors.Wrap(err, "failed to find backupstoragelocations") } From 7af9f230c888d8d76cbfaa940d9769e4636241fd Mon Sep 17 00:00:00 2001 From: JGAntunes Date: Tue, 24 Dec 2024 11:43:18 +0000 Subject: [PATCH 4/5] chore: fixup more tests --- pkg/kotsadmsnapshot/backup.go | 30 +++++++++++++++++++----------- pkg/kotsadmsnapshot/backup_test.go | 20 ++++++++++---------- pkg/kotsutil/kots_test.go | 2 ++ 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/pkg/kotsadmsnapshot/backup.go b/pkg/kotsadmsnapshot/backup.go index 8aaa379ff3..4f10da1aa0 100644 --- a/pkg/kotsadmsnapshot/backup.go +++ b/pkg/kotsadmsnapshot/backup.go @@ -747,13 +747,16 @@ func ListBackupsForApp(ctx context.Context, kotsadmNamespace string, appID strin } if veleroBackup.Status.StartTimestamp != nil { - backup.StartedAt = &veleroBackup.Status.StartTimestamp.Time + startedAt := veleroBackup.Status.StartTimestamp.Time.UTC() + backup.StartedAt = &startedAt } if veleroBackup.Status.CompletionTimestamp != nil { - backup.FinishedAt = &veleroBackup.Status.CompletionTimestamp.Time + finishedAt := veleroBackup.Status.CompletionTimestamp.Time.UTC() + backup.FinishedAt = &finishedAt } if veleroBackup.Status.Expiration != nil { - backup.ExpiresAt = &veleroBackup.Status.Expiration.Time + expiresAt := veleroBackup.Status.Expiration.Time.UTC() + backup.ExpiresAt = &expiresAt } sequence, ok := veleroBackup.Annotations["kots.io/app-sequence"] if ok { @@ -855,22 +858,25 @@ func getBackupsFromVeleroBackups(ctx context.Context, veleroBackups []velerov1.B backup.BackupCount++ // backup uses the oldest velero backup start time as its start time if veleroStatus.StartTimestamp != nil { - if backup.StartedAt == nil || veleroStatus.StartTimestamp.Time.Before(*backup.StartedAt) { - backup.StartedAt = &veleroStatus.StartTimestamp.Time + startedAt := veleroStatus.StartTimestamp.Time.UTC() + if backup.StartedAt == nil || startedAt.Before(*backup.StartedAt) { + backup.StartedAt = &startedAt } } // backup uses the first expiration date as its expiration timestamp if veleroStatus.Expiration != nil { - if backup.ExpiresAt == nil || veleroStatus.Expiration.Time.Before(*backup.ExpiresAt) { - backup.ExpiresAt = &veleroStatus.Expiration.Time + expiresAt := veleroStatus.Expiration.Time.UTC() + if backup.ExpiresAt == nil || expiresAt.Before(*backup.ExpiresAt) { + backup.ExpiresAt = &expiresAt } } // backup uses the most recent completion date as its completion timestamp if veleroStatus.CompletionTimestamp != nil { - if backup.FinishedAt == nil || veleroStatus.CompletionTimestamp.Time.After(*backup.FinishedAt) { - backup.FinishedAt = &veleroStatus.CompletionTimestamp.Time + finishedAt := veleroStatus.CompletionTimestamp.Time.UTC() + if backup.FinishedAt == nil || finishedAt.After(*backup.FinishedAt) { + backup.FinishedAt = &finishedAt } } @@ -1237,7 +1243,8 @@ func listBackupVolumes(backupVolumes []velerov1.PodVolumeBackup) []types.Snapsho } if backupVolume.Status.StartTimestamp != nil { - v.StartedAt = &backupVolume.Status.StartTimestamp.Time + startedAt := backupVolume.Status.StartTimestamp.Time.UTC() + v.StartedAt = &startedAt if backupVolume.Status.Progress.TotalBytes > 0 { bytesPerSecond := float64(backupVolume.Status.Progress.BytesDone) / time.Now().Sub(*v.StartedAt).Seconds() @@ -1246,7 +1253,8 @@ func listBackupVolumes(backupVolumes []velerov1.PodVolumeBackup) []types.Snapsho } } if backupVolume.Status.CompletionTimestamp != nil { - v.FinishedAt = &backupVolume.Status.CompletionTimestamp.Time + finishedAt := backupVolume.Status.CompletionTimestamp.Time.UTC() + v.FinishedAt = &finishedAt } volumes = append(volumes, v) diff --git a/pkg/kotsadmsnapshot/backup_test.go b/pkg/kotsadmsnapshot/backup_test.go index ff4ac73d02..e326666e65 100644 --- a/pkg/kotsadmsnapshot/backup_test.go +++ b/pkg/kotsadmsnapshot/backup_test.go @@ -1885,7 +1885,7 @@ func Test_getAppInstanceBackupSpec(t *testing.T) { assert.Equal(t, "2", got.Annotations[types.InstanceBackupCountAnnotation]) } if assert.Contains(t, got.Annotations, types.InstanceBackupRestoreSpecAnnotation) { - assert.Equal(t, `{"kind":"Restore","apiVersion":"velero.io/v1","metadata":{"name":"test-restore","creationTimestamp":null},"spec":{"backupName":"test-backup","hooks":{}},"status":{}}`, got.Annotations[types.InstanceBackupRestoreSpecAnnotation]) + assert.Equal(t, `{"kind":"Restore","apiVersion":"velero.io/v1","metadata":{"name":"test-restore","creationTimestamp":null},"spec":{"backupName":"test-backup","hooks":{},"itemOperationTimeout":"0s"},"status":{}}`, got.Annotations[types.InstanceBackupRestoreSpecAnnotation]) } }, }, @@ -3019,9 +3019,9 @@ func TestListBackupsForApp(t *testing.T) { velerov1.AddToScheme(scheme) // setup timestamps - startTs := metav1.Date(2024, 1, 1, 0, 0, 0, 0, time.Local) - completionTs := metav1.Date(2024, 1, 2, 0, 0, 0, 0, time.Local) - expirationTs := metav1.Date(2025, 1, 2, 0, 0, 0, 0, time.Local) + startTs := time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC) + completionTs := time.Date(2024, 1, 2, 0, 0, 0, 0, time.UTC) + expirationTs := time.Date(2025, 1, 2, 0, 0, 0, 0, time.UTC) // setup common mock objects kotsadmNamespace := "kotsadm-test" @@ -3168,9 +3168,9 @@ func TestListBackupsForApp(t *testing.T) { }, Status: velerov1.BackupStatus{ Phase: velerov1.BackupPhaseCompleted, - StartTimestamp: &startTs, - CompletionTimestamp: &completionTs, - Expiration: &expirationTs, + StartTimestamp: &metav1.Time{Time: startTs}, + CompletionTimestamp: &metav1.Time{Time: completionTs}, + Expiration: &metav1.Time{Time: expirationTs}, }, }, ).Build(), @@ -3180,9 +3180,9 @@ func TestListBackupsForApp(t *testing.T) { AppID: "app-1", Name: "app-backup-app-1", Status: "Completed", - StartedAt: &startTs.Time, - FinishedAt: &completionTs.Time, - ExpiresAt: &expirationTs.Time, + StartedAt: &startTs, + FinishedAt: &completionTs, + ExpiresAt: &expirationTs, VolumeSummary: types.VolumeSummary{ VolumeSizeHuman: "0B", }, diff --git a/pkg/kotsutil/kots_test.go b/pkg/kotsutil/kots_test.go index 44e5fe512e..af0fb1f2b4 100644 --- a/pkg/kotsutil/kots_test.go +++ b/pkg/kotsutil/kots_test.go @@ -1024,6 +1024,7 @@ metadata: spec: csiSnapshotTimeout: 0s hooks: {} + itemOperationTimeout: 0s metadata: {} ttl: 0s status: {} @@ -1080,6 +1081,7 @@ metadata: spec: csiSnapshotTimeout: 0s hooks: {} + itemOperationTimeout: 0s metadata: {} ttl: 0s status: {} From 58f9f868d0b83337e99da3665b1089a9e02d5d55 Mon Sep 17 00:00:00 2001 From: JGAntunes Date: Tue, 24 Dec 2024 12:52:13 +0000 Subject: [PATCH 5/5] chore: make k8sutil use a single client --- pkg/handlers/snapshot_logs.go | 2 +- pkg/informers/informers.go | 2 +- pkg/k8sutil/clientset.go | 26 +++------------------- pkg/kotsadm/minio.go | 2 +- pkg/kotsadmsnapshot/backup.go | 23 ++++++++++--------- pkg/kotsadmsnapshot/backup_test.go | 4 ++-- pkg/kotsadmsnapshot/download.go | 2 +- pkg/kotsadmsnapshot/k8sclient/k8sclient.go | 19 ++++------------ pkg/kotsadmsnapshot/restore.go | 8 +++---- pkg/reporting/app.go | 2 +- pkg/snapshot/backup.go | 4 ++-- pkg/snapshot/filesystem_lvp.go | 2 +- pkg/snapshot/restore.go | 6 ++--- pkg/snapshot/store.go | 15 ++++++------- pkg/snapshot/velero.go | 6 ++--- 15 files changed, 47 insertions(+), 76 deletions(-) diff --git a/pkg/handlers/snapshot_logs.go b/pkg/handlers/snapshot_logs.go index 1ae839b695..9a27b54d0d 100644 --- a/pkg/handlers/snapshot_logs.go +++ b/pkg/handlers/snapshot_logs.go @@ -34,7 +34,7 @@ func (h *Handler) DownloadSnapshotLogs(w http.ResponseWriter, r *http.Request) { return } - veleroClient, err := k8sutil.GetVeleroKubeClient(r.Context()) + veleroClient, err := k8sutil.GetKubeClient(r.Context()) if err != nil { err = errors.Wrap(err, "failed to create velero client") logger.Error(err) diff --git a/pkg/informers/informers.go b/pkg/informers/informers.go index 32b0510a72..12a6fa4403 100644 --- a/pkg/informers/informers.go +++ b/pkg/informers/informers.go @@ -39,7 +39,7 @@ func Start() error { return errors.Wrap(err, "failed to detect velero namespace") } - veleroClient, err := k8sutil.GetVeleroKubeClient(context.TODO()) + veleroClient, err := k8sutil.GetKubeClient(context.TODO()) if err != nil { return errors.Wrap(err, "failed to create velero client") } diff --git a/pkg/k8sutil/clientset.go b/pkg/k8sutil/clientset.go index 0d0c7e7d7f..d317f57757 100644 --- a/pkg/k8sutil/clientset.go +++ b/pkg/k8sutil/clientset.go @@ -11,7 +11,6 @@ import ( flag "github.com/spf13/pflag" velerov1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v1" "k8s.io/apimachinery/pkg/api/meta" - "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/cli-runtime/pkg/genericclioptions" "k8s.io/client-go/discovery" @@ -37,6 +36,7 @@ var kubernetesConfigFlags *genericclioptions.ConfigFlags func init() { kubernetesConfigFlags = genericclioptions.NewConfigFlags(false) embeddedclusterv1beta1.AddToScheme(scheme.Scheme) + velerov1.AddToScheme(scheme.Scheme) } func AddFlags(flags *flag.FlagSet) { @@ -154,7 +154,7 @@ func GetDynamicResourceInterface(gvk *schema.GroupVersionKind, namespace string) return dr, nil } -func GetKubeClient(ctx context.Context) (kbclient.Client, error) { +func GetKubeClient(ctx context.Context) (kbclient.WithWatch, error) { k8slogger := zap.New(func(o *zap.Options) { o.DestWriter = io.Discard }) @@ -163,27 +163,7 @@ func GetKubeClient(ctx context.Context) (kbclient.Client, error) { if err != nil { return nil, errors.Wrap(err, "failed to get cluster config") } - kcli, err := kbclient.New(cfg, kbclient.Options{}) - if err != nil { - return nil, errors.Wrap(err, "failed to create kubebuilder client") - } - return kcli, nil -} - -func GetVeleroKubeClient(ctx context.Context) (kbclient.WithWatch, error) { - k8slogger := zap.New(func(o *zap.Options) { - o.DestWriter = io.Discard - }) - log.SetLogger(k8slogger) - cfg, err := GetClusterConfig() - if err != nil { - return nil, errors.Wrap(err, "failed to get cluster config") - } - scheme := runtime.NewScheme() - velerov1.AddToScheme(scheme) - kcli, err := kbclient.NewWithWatch(cfg, kbclient.Options{ - Scheme: scheme, - }) + kcli, err := kbclient.NewWithWatch(cfg, kbclient.Options{}) if err != nil { return nil, errors.Wrap(err, "failed to create kubebuilder client") } diff --git a/pkg/kotsadm/minio.go b/pkg/kotsadm/minio.go index d16216a7dd..c91db4aacb 100644 --- a/pkg/kotsadm/minio.go +++ b/pkg/kotsadm/minio.go @@ -192,7 +192,7 @@ func MigrateExistingMinioFilesystemDeployments(log *logger.CLILogger, deployOpti return errors.Wrap(err, "failed to create clientset") } - veleroClient, err := k8sutil.GetVeleroKubeClient(context.TODO()) + veleroClient, err := k8sutil.GetKubeClient(context.TODO()) if err != nil { return errors.Wrap(err, "failed to create velero client") } diff --git a/pkg/kotsadmsnapshot/backup.go b/pkg/kotsadmsnapshot/backup.go index 4f10da1aa0..a98d625d95 100644 --- a/pkg/kotsadmsnapshot/backup.go +++ b/pkg/kotsadmsnapshot/backup.go @@ -90,7 +90,7 @@ func CreateApplicationBackup(ctx context.Context, a *apptypes.App, isScheduled b return nil, errors.Wrap(err, "failed to create clientset") } - veleroClient, err := k8sclient.GetBuilder().GetVeleroKubeClient(ctx) + veleroClient, err := k8sclient.GetBuilder().GetKubeClient(ctx) if err != nil { return nil, errors.Wrap(err, "failed to create velero client") } @@ -236,7 +236,7 @@ func CreateInstanceBackup(ctx context.Context, cluster *downstreamtypes.Downstre return "", errors.Wrap(err, "failed to create clientset") } - ctrlClient, err := k8sclient.GetBuilder().GetVeleroKubeClient(ctx) + ctrlClient, err := k8sclient.GetBuilder().GetKubeClient(ctx) if err != nil { return "", errors.Wrap(err, "failed to get kubeclient") } @@ -432,6 +432,7 @@ func getInfrastructureInstanceBackupSpec(ctx context.Context, k8sClient kubernet veleroBackup := &velerov1.Backup{ ObjectMeta: metav1.ObjectMeta{ Name: "", + Namespace: metadata.backupStorageLocationNamespace, GenerateName: "instance-", Annotations: map[string]string{}, }, @@ -537,8 +538,10 @@ func getAppInstanceBackupSpec(k8sClient kubernetes.Interface, metadata instanceB appVeleroBackup = appMeta.kotsKinds.Backup.DeepCopy() restore = appMeta.kotsKinds.Restore.DeepCopy() + restore.Namespace = metadata.backupStorageLocationNamespace appVeleroBackup.Name = "" + appVeleroBackup.Namespace = metadata.backupStorageLocationNamespace appVeleroBackup.GenerateName = "application-" break @@ -713,7 +716,7 @@ func ListBackupsForApp(ctx context.Context, kotsadmNamespace string, appID strin return nil, errors.Wrap(err, "failed to create clientset") } - veleroClient, err := k8sclient.GetBuilder().GetVeleroKubeClient(ctx) + veleroClient, err := k8sclient.GetBuilder().GetKubeClient(ctx) if err != nil { return nil, errors.Wrap(err, "failed to create velero client") } @@ -810,9 +813,9 @@ func ListInstanceBackups(ctx context.Context, kotsadmNamespace string) ([]*types return nil, errors.Wrap(err, "failed to create clientset") } - veleroClient, err := k8sclient.GetBuilder().GetVeleroKubeClient(ctx) + veleroClient, err := k8sclient.GetBuilder().GetKubeClient(ctx) if err != nil { - return nil, errors.Wrap(err, "failed to create velero clientset") + return nil, errors.Wrap(err, "failed to create velero client") } backendStorageLocation, err := kotssnapshot.FindBackupStoreLocation(ctx, clientset, veleroClient, kotsadmNamespace) @@ -943,7 +946,7 @@ func getAppsFromAppSequences(veleroBackup velerov1.Backup) ([]types.App, error) } func getSnapshotVolumeSummary(ctx context.Context, veleroBackup *velerov1.Backup) (*types.VolumeSummary, error) { - veleroClient, err := k8sclient.GetBuilder().GetVeleroKubeClient(ctx) + veleroClient, err := k8sclient.GetBuilder().GetKubeClient(ctx) if err != nil { return nil, errors.Wrap(err, "failed to create client") } @@ -990,9 +993,9 @@ func GetBackup(ctx context.Context, kotsadmNamespace string, backupID string) (* return nil, errors.Wrap(err, "failed to create clientset") } - veleroClient, err := k8sclient.GetBuilder().GetVeleroKubeClient(ctx) + veleroClient, err := k8sclient.GetBuilder().GetKubeClient(ctx) if err != nil { - return nil, errors.Wrap(err, "failed to create velero clientset") + return nil, errors.Wrap(err, "failed to create velero client") } bsl, err := kotssnapshot.FindBackupStoreLocation(ctx, clientset, veleroClient, kotsadmNamespace) @@ -1037,7 +1040,7 @@ func DeleteBackup(ctx context.Context, kotsadmNamespace string, backupID string) return errors.Wrap(err, "failed to create clientset") } - veleroClient, err := k8sclient.GetBuilder().GetVeleroKubeClient(ctx) + veleroClient, err := k8sclient.GetBuilder().GetKubeClient(ctx) if err != nil { return errors.Wrap(err, "failed to create velero client") } @@ -1131,7 +1134,7 @@ func GetBackupDetail(ctx context.Context, kotsadmNamespace string, backupName st return nil, errors.Wrap(err, "failed to create clientset") } - veleroClient, err := k8sclient.GetBuilder().GetVeleroKubeClient(ctx) + veleroClient, err := k8sclient.GetBuilder().GetKubeClient(ctx) if err != nil { return nil, errors.Wrap(err, "failed to create velero client") } diff --git a/pkg/kotsadmsnapshot/backup_test.go b/pkg/kotsadmsnapshot/backup_test.go index e326666e65..836f58e0a7 100644 --- a/pkg/kotsadmsnapshot/backup_test.go +++ b/pkg/kotsadmsnapshot/backup_test.go @@ -1885,7 +1885,7 @@ func Test_getAppInstanceBackupSpec(t *testing.T) { assert.Equal(t, "2", got.Annotations[types.InstanceBackupCountAnnotation]) } if assert.Contains(t, got.Annotations, types.InstanceBackupRestoreSpecAnnotation) { - assert.Equal(t, `{"kind":"Restore","apiVersion":"velero.io/v1","metadata":{"name":"test-restore","creationTimestamp":null},"spec":{"backupName":"test-backup","hooks":{},"itemOperationTimeout":"0s"},"status":{}}`, got.Annotations[types.InstanceBackupRestoreSpecAnnotation]) + assert.Equal(t, `{"kind":"Restore","apiVersion":"velero.io/v1","metadata":{"name":"test-restore","namespace":"kotsadm-backups","creationTimestamp":null},"spec":{"backupName":"test-backup","hooks":{},"itemOperationTimeout":"0s"},"status":{}}`, got.Annotations[types.InstanceBackupRestoreSpecAnnotation]) } }, }, @@ -4331,7 +4331,7 @@ func TestDeleteBackup(t *testing.T) { if test.expectedDeleteBackupRequests != nil { // verify delete backup requests - veleroClient, err := test.k8sClientBuilder.GetVeleroKubeClient(context.Background()) + veleroClient, err := test.k8sClientBuilder.GetKubeClient(context.Background()) req.NoError(err) var deleteBackupRequests velerov1.DeleteBackupRequestList diff --git a/pkg/kotsadmsnapshot/download.go b/pkg/kotsadmsnapshot/download.go index 1dad933120..ebfa660351 100644 --- a/pkg/kotsadmsnapshot/download.go +++ b/pkg/kotsadmsnapshot/download.go @@ -81,7 +81,7 @@ func DownloadRestoreResults(ctx context.Context, veleroNamespace, restoreName st } func DownloadRequest(ctx context.Context, veleroNamespace string, kind velerov1.DownloadTargetKind, name string) (io.ReadCloser, error) { - kbClient, err := k8sutil.GetVeleroKubeClient(ctx) + kbClient, err := k8sutil.GetKubeClient(ctx) if err != nil { return nil, errors.Wrap(err, "failed to get velero kube client") } diff --git a/pkg/kotsadmsnapshot/k8sclient/k8sclient.go b/pkg/kotsadmsnapshot/k8sclient/k8sclient.go index 878108e8ea..c72b4aee50 100644 --- a/pkg/kotsadmsnapshot/k8sclient/k8sclient.go +++ b/pkg/kotsadmsnapshot/k8sclient/k8sclient.go @@ -16,8 +16,7 @@ var _ K8sClientsBuilder = (*MockBuilder)(nil) // Or a controller runtime client. Useful to mock the client in tests. type K8sClientsBuilder interface { GetClientset(*rest.Config) (kubernetes.Interface, error) - GetKubeClient(ctx context.Context) (kbclient.Client, error) - GetVeleroKubeClient(ctx context.Context) (kbclient.Client, error) + GetKubeClient(ctx context.Context) (kbclient.WithWatch, error) } // Builder is the default implementation of K8sClientsetBuilder. It returns a regular go client clientset or a regular controller runtime client. @@ -29,21 +28,16 @@ func (b *Builder) GetClientset(cfg *rest.Config) (kubernetes.Interface, error) { } // GetKubeClient returns a regular controller runtime client based on the default cluster config provided. -func (b *Builder) GetKubeClient(ctx context.Context) (kbclient.Client, error) { +func (b *Builder) GetKubeClient(ctx context.Context) (kbclient.WithWatch, error) { return k8sutil.GetKubeClient(ctx) } -// GetVeleroKubeClient returns a controller runtime client with the velero API scheme based on the default cluster config provided. -func (b *Builder) GetVeleroKubeClient(ctx context.Context) (kbclient.Client, error) { - return k8sutil.GetVeleroKubeClient(ctx) -} - // MockBuilder is a mock implementation of K8sClientsetBuilder. It returns the client and clientset that was set in the struct allowing // you to set a fake clients for example. type MockBuilder struct { Clientset kubernetes.Interface - CtrlClient kbclient.Client + CtrlClient kbclient.WithWatch Err error } @@ -53,12 +47,7 @@ func (b *MockBuilder) GetClientset(cfg *rest.Config) (kubernetes.Interface, erro } // GetKubeClient returns the controller runtime client set in the struct. -func (b *MockBuilder) GetKubeClient(ctx context.Context) (kbclient.Client, error) { - return b.CtrlClient, b.Err -} - -// GetVeleroKubeClient returns the controller runtime client set in the struct. -func (b *MockBuilder) GetVeleroKubeClient(ctx context.Context) (kbclient.Client, error) { +func (b *MockBuilder) GetKubeClient(ctx context.Context) (kbclient.WithWatch, error) { return b.CtrlClient, b.Err } diff --git a/pkg/kotsadmsnapshot/restore.go b/pkg/kotsadmsnapshot/restore.go index d46025d03c..9032d86ed9 100644 --- a/pkg/kotsadmsnapshot/restore.go +++ b/pkg/kotsadmsnapshot/restore.go @@ -35,7 +35,7 @@ func GetRestore(ctx context.Context, kotsadmNamespace string, restoreID string) return nil, errors.Wrap(err, "failed to create clientset") } - veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) + veleroClient, err := k8sutil.GetKubeClient(ctx) if err != nil { return nil, errors.Wrap(err, "failed to create velero client") } @@ -76,7 +76,7 @@ func CreateApplicationRestore(ctx context.Context, kotsadmNamespace string, back return errors.Wrap(err, "failed to create clientset") } - veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) + veleroClient, err := k8sutil.GetKubeClient(ctx) if err != nil { return errors.Wrap(err, "failed to create velero client") } @@ -146,7 +146,7 @@ func DeleteRestore(ctx context.Context, kotsadmNamespace string, restoreID strin return errors.Wrap(err, "failed to create clientset") } - veleroClient, err := k8sclient.GetBuilder().GetVeleroKubeClient(ctx) + veleroClient, err := k8sclient.GetBuilder().GetKubeClient(ctx) if err != nil { return errors.Wrap(err, "failed to create velero client") } @@ -182,7 +182,7 @@ func GetRestoreDetails(ctx context.Context, kotsadmNamespace string, restoreID s return nil, errors.Wrap(err, "failed to create clientset") } - veleroClient, err := k8sclient.GetBuilder().GetVeleroKubeClient(ctx) + veleroClient, err := k8sclient.GetBuilder().GetKubeClient(ctx) if err != nil { return nil, errors.Wrap(err, "failed to create velero client") } diff --git a/pkg/reporting/app.go b/pkg/reporting/app.go index b6661ab2a9..7fb5527b88 100644 --- a/pkg/reporting/app.go +++ b/pkg/reporting/app.go @@ -178,7 +178,7 @@ func GetReportingInfo(appID string) *types.ReportingInfo { r.IsGitOpsEnabled, r.GitOpsProvider = getGitOpsReport(clientset, appID, r.ClusterID) - veleroClient, err := k8sutil.GetVeleroKubeClient(context.TODO()) + veleroClient, err := k8sutil.GetKubeClient(context.TODO()) if err != nil { logger.Debugf("failed to get velero client: %v", err.Error()) } diff --git a/pkg/snapshot/backup.go b/pkg/snapshot/backup.go index 1cfa1a34ef..050090b9dd 100644 --- a/pkg/snapshot/backup.go +++ b/pkg/snapshot/backup.go @@ -202,7 +202,7 @@ func ListAllBackups(ctx context.Context, options ListInstanceBackupsOptions) ([] return nil, errors.New("velero not found") } - veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) + veleroClient, err := k8sutil.GetKubeClient(ctx) if err != nil { return nil, errors.Wrap(err, "failed to create clientset") } @@ -228,7 +228,7 @@ func waitForVeleroBackupCompleted(ctx context.Context, clientset kubernetes.Inte return nil, errors.New("velero not found") } - veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) + veleroClient, err := k8sutil.GetKubeClient(ctx) if err != nil { return nil, errors.Wrap(err, "failed to create client") } diff --git a/pkg/snapshot/filesystem_lvp.go b/pkg/snapshot/filesystem_lvp.go index b1e76adb21..fd99b0cc4b 100644 --- a/pkg/snapshot/filesystem_lvp.go +++ b/pkg/snapshot/filesystem_lvp.go @@ -56,7 +56,7 @@ func GetCurrentLvpFileSystemConfig(ctx context.Context, namespace string) (*type return nil, errors.Wrap(err, "failed to create clientset") } - veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) + veleroClient, err := k8sutil.GetKubeClient(ctx) if err != nil { return nil, errors.Wrap(err, "failed to create velero client") } diff --git a/pkg/snapshot/restore.go b/pkg/snapshot/restore.go index 3214702ff8..b3d888a855 100644 --- a/pkg/snapshot/restore.go +++ b/pkg/snapshot/restore.go @@ -57,7 +57,7 @@ func RestoreInstanceBackup(ctx context.Context, options RestoreInstanceBackupOpt } // get the backup - veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) + veleroClient, err := k8sutil.GetKubeClient(ctx) if err != nil { return errors.Wrap(err, "failed to create velero client") } @@ -265,7 +265,7 @@ func ListInstanceRestores(ctx context.Context, options ListInstanceRestoresOptio return nil, errors.New("velero not found") } - veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) + veleroClient, err := k8sutil.GetKubeClient(ctx) if err != nil { return nil, errors.Wrap(err, "failed to create client") } @@ -294,7 +294,7 @@ func ListInstanceRestores(ctx context.Context, options ListInstanceRestoresOptio } func waitForVeleroRestoreCompleted(ctx context.Context, veleroNamespace string, restoreName string) (*velerov1.Restore, error) { - veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) + veleroClient, err := k8sutil.GetKubeClient(ctx) if err != nil { return nil, errors.Wrap(err, "failed to create client") } diff --git a/pkg/snapshot/store.go b/pkg/snapshot/store.go index f8babe29c1..74d6e78cae 100644 --- a/pkg/snapshot/store.go +++ b/pkg/snapshot/store.go @@ -429,7 +429,7 @@ func upsertGlobalStore(ctx context.Context, store *types.Store, kotsadmNamespace return nil, errors.Wrap(err, "failed to create clientset") } - veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) + veleroClient, err := k8sutil.GetKubeClient(ctx) if err != nil { return nil, errors.Wrap(err, "failed to create velero client") } @@ -793,13 +793,12 @@ func cloudCredentialsEnvVars() []corev1.EnvVar { } func upsertBackupStorageLocation(ctx context.Context, bsl *velerov1.BackupStorageLocation) (*velerov1.BackupStorageLocation, error) { - veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) + veleroClient, err := k8sutil.GetKubeClient(ctx) if err != nil { return nil, errors.Wrap(err, "failed to create velero client") } - if err = veleroClient.Get(ctx, k8stypes.NamespacedName{Namespace: bsl.Namespace, Name: bsl.Name}, bsl); err == nil { - err := veleroClient.Update(ctx, bsl) + if err := veleroClient.Update(ctx, bsl); err == nil { if err != nil { return nil, errors.Wrap(err, "failed to update backup storage location") } @@ -878,7 +877,7 @@ func GetGlobalStore(ctx context.Context, kotsadmNamespace string, bsl *velerov1. return nil, errors.Wrap(err, "failed to create clientset") } - veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) + veleroClient, err := k8sutil.GetKubeClient(ctx) if err != nil { return nil, errors.Wrap(err, "failed to create velero client") } @@ -1101,7 +1100,7 @@ func FindBackupStoreLocation(ctx context.Context, clientset kubernetes.Interface // UpdateBackupStorageLocation applies an updated Velero backup storage location resource to the cluster func UpdateBackupStorageLocation(ctx context.Context, veleroNamespace string, bsl *velerov1.BackupStorageLocation) error { - veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) + veleroClient, err := k8sutil.GetKubeClient(ctx) if err != nil { return errors.Wrap(err, "failed to create velero client") } @@ -1623,7 +1622,7 @@ func resetRepositories(ctx context.Context, veleroNamespace string) error { func resetBackupRepositories(ctx context.Context, veleroNamespace string) error { // BackupRepositories store the previous snapshot location which breaks volume backup when location changes. - veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) + veleroClient, err := k8sutil.GetKubeClient(ctx) if err != nil { return errors.Wrap(err, "failed to create velero client") } @@ -1706,7 +1705,7 @@ func GetLvpBucket(fsConfig *types.FileSystemConfig) (string, error) { func WaitForDefaultBslAvailableAndSynced(ctx context.Context, veleroNamespace string, start metav1.Time) error { timeout := time.After(5 * time.Minute) - veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) + veleroClient, err := k8sutil.GetKubeClient(ctx) if err != nil { return errors.Wrap(err, "failed to create velero client") } diff --git a/pkg/snapshot/velero.go b/pkg/snapshot/velero.go index 6291c154bb..728b6e9d49 100644 --- a/pkg/snapshot/velero.go +++ b/pkg/snapshot/velero.go @@ -100,7 +100,7 @@ func CheckKotsadmVeleroAccess(ctx context.Context, kotsadmNamespace string) (req return } - veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) + veleroClient, err := k8sutil.GetKubeClient(ctx) if err != nil { finalErr = errors.Wrap(err, "failed to create velero client") return @@ -147,7 +147,7 @@ func CheckKotsadmVeleroAccess(ctx context.Context, kotsadmNamespace string) (req } func EnsureVeleroPermissions(ctx context.Context, clientset kubernetes.Interface, veleroNamespace string, kotsadmNamespace string) error { - veleroClient, err := k8sutil.GetVeleroKubeClient(ctx) + veleroClient, err := k8sutil.GetKubeClient(ctx) if err != nil { return errors.Wrap(err, "failed to create velero client") } @@ -353,7 +353,7 @@ NodeAgentFound: } func getVersion(ctx context.Context, namespace string) (string, error) { - kbClient, err := k8sutil.GetVeleroKubeClient(ctx) + kbClient, err := k8sutil.GetKubeClient(ctx) if err != nil { return "", errors.Wrap(err, "failed to get velero kube client") }