diff --git a/go.mod b/go.mod index 87b951fda..c23c7fd13 100644 --- a/go.mod +++ b/go.mod @@ -3,42 +3,20 @@ module stash.appscode.dev/elasticsearch go 1.15 require ( - github.com/evanphx/json-patch v4.12.0+incompatible // indirect - github.com/go-openapi/jsonpointer v0.19.5 // indirect - github.com/go-openapi/jsonreference v0.19.5 // indirect - github.com/go-openapi/spec v0.19.8 // indirect - github.com/go-openapi/swag v0.19.14 // indirect - github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/google/gofuzz v1.2.0 // indirect - github.com/mailru/easyjson v0.7.7 // indirect - github.com/onsi/ginkgo v1.16.5 // indirect - github.com/onsi/gomega v1.17.0 // indirect - github.com/prometheus/common v0.28.0 // indirect github.com/spf13/cobra v1.2.1 go.bytebuilders.dev/license-verifier/kubernetes v0.9.7 - go.uber.org/zap v1.19.1 // indirect - golang.org/x/net v0.0.0-20211209124913-491a49abca63 // indirect - golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect - golang.org/x/sys v0.0.0-20211029165221-6e7872819dc8 // indirect - golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b // indirect gomodules.xyz/flags v0.1.3 gomodules.xyz/go-sh v0.1.0 gomodules.xyz/logs v0.0.6 gomodules.xyz/x v0.0.13 - google.golang.org/protobuf v1.27.1 // indirect k8s.io/api v0.21.1 k8s.io/apimachinery v0.21.1 k8s.io/client-go v0.21.1 k8s.io/klog/v2 v2.9.0 - k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65 // indirect - k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b // indirect kmodules.xyz/client-go v0.0.0-20220317213815-2a6d5a5784f2 kmodules.xyz/custom-resources v0.0.0-20220317220154-7beb809b1f5e - kmodules.xyz/objectstore-api v0.0.0-20220317220441-f1d593d0a778 // indirect - kmodules.xyz/offshoot-api v0.0.0-20220323112402-3b0fd2ea77d6 - sigs.k8s.io/structured-merge-diff/v4 v4.2.0 // indirect - sigs.k8s.io/yaml v1.3.0 // indirect - stash.appscode.dev/apimachinery v0.18.0 + kmodules.xyz/offshoot-api v0.0.0-20220329041708-c076b2bcb0f8 + stash.appscode.dev/apimachinery v0.19.0 ) replace bitbucket.org/ww/goautoneg => gomodules.xyz/goautoneg v0.0.0-20120707110453-a547fc61f48d diff --git a/go.sum b/go.sum index 8611c08d2..24a7a3c89 100644 --- a/go.sum +++ b/go.sum @@ -676,7 +676,6 @@ github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1 github.com/yvasiyarov/go-metrics v0.0.0-20140926110328-57bccd1ccd43/go.mod h1:aX5oPXxHm3bOH+xeAttToC8pqch2ScQN/JoXYupl6xs= github.com/yvasiyarov/gorelic v0.0.0-20141212073537-a9bba5b9ab50/go.mod h1:NUSPSUX/bi6SeDMUh6brw0nXpxHnc96TguQh0+r/ssA= github.com/yvasiyarov/newrelic_platform_go v0.0.0-20140908184405-b21fdbd4370f/go.mod h1:GlGEuHIJweS1mbCqG+7vt2nvWLzLLnRHbXz5JKd/Qbg= -go.bytebuilders.dev/license-verifier v0.9.3/go.mod h1:GpIW0o8O0wpiBVt7IIz4z7bcPuG8nza8/bCDkaupDn8= go.bytebuilders.dev/license-verifier v0.9.7 h1:m7Z3cuVJYUUctCfTK6qT0IKtPVZurxq1b1bKzWjqwsE= go.bytebuilders.dev/license-verifier v0.9.7/go.mod h1:GpIW0o8O0wpiBVt7IIz4z7bcPuG8nza8/bCDkaupDn8= go.bytebuilders.dev/license-verifier/kubernetes v0.9.7 h1:TN9N9FmmxrPTQoAPJsQnHRgY00liNZgiTUyZ2QNtqyg= @@ -972,7 +971,6 @@ gomodules.xyz/pointer v0.1.0 h1:sG2UKrYVSo6E3r4itAjXfPfe4fuXMi0KdyTHpR3vGCg= gomodules.xyz/pointer v0.1.0/go.mod h1:sPLsC0+yLTRecUiC5yVlyvXhZ6LAGojNCRWNNqoplvo= gomodules.xyz/runtime v0.2.0/go.mod h1:/R/Dw906YIUHKJ5cfKUaJgJrojFjpRU+n0s3Wjn1tqs= gomodules.xyz/sets v0.0.0-20200930152147-4f4543544799/go.mod h1:jKgNp01/iDs+svOWXaPk5cKP3VXy0mWUoTF/ore+aMc= -gomodules.xyz/sets v0.1.0/go.mod h1:jKgNp01/iDs+svOWXaPk5cKP3VXy0mWUoTF/ore+aMc= gomodules.xyz/sets v0.2.0/go.mod h1:jKgNp01/iDs+svOWXaPk5cKP3VXy0mWUoTF/ore+aMc= gomodules.xyz/sets v0.2.1 h1:vK3oUWoGVrZKLDKO/bzEo/ucHFdCE7+DxWPeWxK72KQ= gomodules.xyz/sets v0.2.1/go.mod h1:jKgNp01/iDs+svOWXaPk5cKP3VXy0mWUoTF/ore+aMc= @@ -980,7 +978,6 @@ gomodules.xyz/stow v0.2.4/go.mod h1:aAgUEHyZ+4nKznyVupMMkP0JX9MXW1ZRrbRGaclp3E0= gomodules.xyz/wait v0.2.0 h1:HnRIh+cvIrrKIFaXoYznCVVirv2/2xu3KzjSzsQmYAY= gomodules.xyz/wait v0.2.0/go.mod h1:g/epKzZQuCqgvhzhaoG4cSBNGHqnOrhFR4Q7szDJ1JM= gomodules.xyz/x v0.0.5/go.mod h1:EGy7cB7ifSuOcbNFc0U1zUPTf5yY8RtXVJlAlhGS9OE= -gomodules.xyz/x v0.0.7/go.mod h1:CMXe28rpApV30pPw9cxdyEmvoC+aa5LiAqzks9dlxag= gomodules.xyz/x v0.0.8/go.mod h1:YnL5CAnLrEtAV/NQGn5sKJe6u08/vDlRyJddXIuD9mc= gomodules.xyz/x v0.0.10/go.mod h1:AgHPywNbRKtogAdk08vCqsfwjtXtXX1/FUPyG7OWdOs= gomodules.xyz/x v0.0.13 h1:k4ABA8dVGUTxqiNYOHPAs5sZbmgLxYcL9WuBT/kDOiM= @@ -1097,28 +1094,22 @@ k8s.io/system-validators v1.4.0/go.mod h1:bPldcLgkIUK22ALflnsXk8pvkTEndYdNuaHH6g k8s.io/utils v0.0.0-20201110183641-67b214c5f920 h1:CbnUZsM497iRC5QMVkHwyl8s2tB3g7yaSHkYPkpgelw= k8s.io/utils v0.0.0-20201110183641-67b214c5f920/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= kmodules.xyz/client-go v0.0.0-20210617233340-13d22e91512b/go.mod h1:A6GAK6xP5zBuWK6A/vUkkjKzcuywkms7fIxRf5wblO4= -kmodules.xyz/client-go v0.0.0-20211013093146-1fbfd52e78c9/go.mod h1:0gkPeALtYjB27OHt4rd6+ZmMgoVTHVLtEJQeU23/gtA= kmodules.xyz/client-go v0.0.0-20211107190155-5bb4090d2728/go.mod h1:ENUu8pPK19xzBkVpAJHoGCI2QRvb1SqffWRt0K2sV5I= -kmodules.xyz/client-go v0.0.0-20220104114408-2a3a05dbe89f/go.mod h1:xxl1ve1Obe4xaW+XjXsNHyLTni4QPIvHn9TfnYEoQRo= -kmodules.xyz/client-go v0.0.0-20220203031013-1de48437aaf3/go.mod h1:aOwnhdxO0uh54ds1wQYRlKVtYlzLyakaesmMQeupVek= kmodules.xyz/client-go v0.0.0-20220215012708-9963581d69a7/go.mod h1:sOq5P3AkZdv6D/skvUPwEG15NDYy5olwBllH/JXfhGI= kmodules.xyz/client-go v0.0.0-20220317213815-2a6d5a5784f2 h1:s6MK8BVV6GHJhS6V4+5IJeV6W1GHcC4fqILencMdRkw= kmodules.xyz/client-go v0.0.0-20220317213815-2a6d5a5784f2/go.mod h1:7pExIHGzUdu8ZGveYvAaXEhS4GdczoOy8z+hq6x6K9A= kmodules.xyz/constants v0.0.0-20210218100002-2c304bfda278/go.mod h1:DbiFk1bJ1KEO94t1SlAn7tzc+Zz95rSXgyUKa2nzPmY= kmodules.xyz/crd-schema-fuzz v0.0.0-20210618002152-fae23aef5fb4/go.mod h1:IIkUctlfoptoci0BOrsUf8ya+MOG5uaeh1PE4uzaIbA= -kmodules.xyz/custom-resources v0.0.0-20220208103158-61b298634e43/go.mod h1:/XjDeILFV2wBota5kHo21DMvOt08nSAk1vm6buCuwt4= +kmodules.xyz/crd-schema-fuzz v0.0.0-20211025154117-6edb24ef11bc/go.mod h1:yLOBJKasPhnCodKSZGFZ6OGFFrp0tq3ALS9rDnYFjkg= kmodules.xyz/custom-resources v0.0.0-20220317220154-7beb809b1f5e h1:JpfwsPxcNXSDfyErTikfQOwr/RmQsHLm1/3NfUElsys= kmodules.xyz/custom-resources v0.0.0-20220317220154-7beb809b1f5e/go.mod h1:OCLmlMhRowPtBPP1bu4xreNLj8/TYu/4lY477+eAzUM= -kmodules.xyz/objectstore-api v0.0.0-20211207131029-3271069de43e/go.mod h1:IICnDdPFOEeGXdaPVHOGYfdwD1cyh/p1I/TWMkyNTIE= kmodules.xyz/objectstore-api v0.0.0-20220317220441-f1d593d0a778 h1:1biCLf6zjBzg9YI9xDjrH6RrKtizpKVB7iuo/5NWOo0= kmodules.xyz/objectstore-api v0.0.0-20220317220441-f1d593d0a778/go.mod h1:rJ3QmHvS0CCJAhhdbXh+O2nlEY5gEmgYdpo3vA4nAm4= kmodules.xyz/offshoot-api v0.0.0-20210829122105-6f4d481b0c61/go.mod h1:3LECbAL3FgbyK80NP3V3Pmiuo/a3hFWg/PR6SPFhTns= -kmodules.xyz/offshoot-api v0.0.0-20211207130839-cc7187e020cf/go.mod h1:sJYyxf84ZvbVz4SivxMgSelGRYn19wOLUtObiEncCxk= -kmodules.xyz/offshoot-api v0.0.0-20220323112402-3b0fd2ea77d6 h1:cFZhSDx8Po4orPTkoTY89O70kMrJXdzntqrzzEv6aDo= -kmodules.xyz/offshoot-api v0.0.0-20220323112402-3b0fd2ea77d6/go.mod h1:9i9RrFY0BtU9jSm70nxhWlLdl9TSZ8pxTnfyPUicq90= -kmodules.xyz/prober v0.0.0-20210618020259-5836fb959027 h1:rtSPsruEkoBOLcbJkxMQjnPafpv8/vJnfWlTIj9yRBg= -kmodules.xyz/prober v0.0.0-20210618020259-5836fb959027/go.mod h1:H4NcvS1RQxeXtQONALbU6r9OT3Xa7cMhfamX/k9t9wo= -kmodules.xyz/resource-metrics v0.0.6/go.mod h1:M7rWuo2qh3BpHhogiEVPnvGY9Xx4Pfygqn1Rex8YbgM= +kmodules.xyz/offshoot-api v0.0.0-20220329041708-c076b2bcb0f8 h1:epLCcaqw60QQ+VbNawJrhM9Y4DpumaLSGzRebsfBCkE= +kmodules.xyz/offshoot-api v0.0.0-20220329041708-c076b2bcb0f8/go.mod h1:9i9RrFY0BtU9jSm70nxhWlLdl9TSZ8pxTnfyPUicq90= +kmodules.xyz/prober v0.0.0-20220317043828-5ae0114adcad h1:bMfimFOEgmaKCN/gnSxLIRvQbWg4dqBgcWrMnHWQgyc= +kmodules.xyz/prober v0.0.0-20220317043828-5ae0114adcad/go.mod h1:QC3O1p+sU/8NnpLKI0VCAO3IQwPlwuimf9l6+Qp3Vt8= kmodules.xyz/resource-metrics v0.0.8/go.mod h1:M7rWuo2qh3BpHhogiEVPnvGY9Xx4Pfygqn1Rex8YbgM= modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw= modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk= @@ -1146,5 +1137,5 @@ sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= -stash.appscode.dev/apimachinery v0.18.0 h1:Mo5m3ffLKePJMPVWufGlFXas3rAwu96R9BeswSNkTrI= -stash.appscode.dev/apimachinery v0.18.0/go.mod h1:MDzqJ66A2QZKAHRksfHT5crOD29a0S5Hfuy/D5hHAjw= +stash.appscode.dev/apimachinery v0.19.0 h1:G4oBu55042Ewigtwz/7iICWSiamvomJD8SuFlrEm7x8= +stash.appscode.dev/apimachinery v0.19.0/go.mod h1:vgzwLa2KFxfbcrTS3gzhJLYmx4WdZpHfW9n8a7Hzhzc= diff --git a/vendor/gomodules.xyz/x/arrays/convert.go b/vendor/gomodules.xyz/x/arrays/convert.go new file mode 100644 index 000000000..01616b88b --- /dev/null +++ b/vendor/gomodules.xyz/x/arrays/convert.go @@ -0,0 +1,21 @@ +package arrays + +import ( + "errors" + "reflect" +) + +func InterfaceToSlice(slice interface{}) ([]interface{}, error) { + s := reflect.ValueOf(slice) + if s.Kind() != reflect.Slice { + return nil, errors.New("slice of interface not found") + } + + ret := make([]interface{}, s.Len()) + + for i := 0; i < s.Len(); i++ { + ret[i] = s.Index(i).Interface() + } + + return ret, nil +} diff --git a/vendor/gomodules.xyz/x/arrays/slice.go b/vendor/gomodules.xyz/x/arrays/slice.go new file mode 100644 index 000000000..c56ccd897 --- /dev/null +++ b/vendor/gomodules.xyz/x/arrays/slice.go @@ -0,0 +1,45 @@ +package arrays + +import ( + "reflect" +) + +func Reverse(slice interface{}) ([]interface{}, error) { + sliceA, err := InterfaceToSlice(slice) + if err != nil { + return nil, err + } + for i := len(sliceA)/2 - 1; i >= 0; i-- { + opp := len(sliceA) - 1 - i + sliceA[i], sliceA[opp] = sliceA[opp], sliceA[i] + } + return sliceA, nil +} + +func Filter(slice interface{}, f func(interface{}) bool) ([]interface{}, error) { + sliceA, err := InterfaceToSlice(slice) + if err != nil { + return nil, err + } + b := sliceA[:0] + for _, x := range sliceA { + if f(x) { + b = append(b, x) + } + } + return b, nil +} + +func Contains(slice interface{}, value interface{}) (bool, int) { + s, err := InterfaceToSlice(slice) + if err != nil { + return false, -1 + } + + for i, v := range s { + if reflect.DeepEqual(v, value) { + return true, i + } + } + return false, -1 +} diff --git a/vendor/kmodules.xyz/offshoot-api/api/v1/runtime_settings_types.go b/vendor/kmodules.xyz/offshoot-api/api/v1/runtime_settings_types.go index c2b6782ba..73f1f179a 100644 --- a/vendor/kmodules.xyz/offshoot-api/api/v1/runtime_settings_types.go +++ b/vendor/kmodules.xyz/offshoot-api/api/v1/runtime_settings_types.go @@ -43,7 +43,7 @@ type PodRuntimeSettings struct { ServiceAccountName string `json:"serviceAccountName,omitempty" protobuf:"bytes,2,opt,name=serviceAccountName"` // ServiceAccountAnnotations are the annotations that will be attached with the respective ServiceAccount // +optional - ServiceAccountAnnotations map[string]string `json:"serviceAccountAnnotations" protobuf:"bytes,16,rep,name=serviceAccountAnnotations"` + ServiceAccountAnnotations map[string]string `json:"serviceAccountAnnotations,omitempty" protobuf:"bytes,16,rep,name=serviceAccountAnnotations"` // AutomountServiceAccountToken indicates whether a service account token should be automatically mounted. // +optional AutomountServiceAccountToken *bool `json:"automountServiceAccountToken,omitempty" protobuf:"varint,3,opt,name=automountServiceAccountToken"` diff --git a/vendor/kmodules.xyz/prober/api/v1/doc.go b/vendor/kmodules.xyz/prober/api/v1/doc.go index da5db8add..494a30610 100644 --- a/vendor/kmodules.xyz/prober/api/v1/doc.go +++ b/vendor/kmodules.xyz/prober/api/v1/doc.go @@ -16,4 +16,5 @@ limitations under the License. // +k8s:deepcopy-gen=package // +k8s:openapi-gen=true +// +gencrdrefdocs:force=true package v1 // import "kmodules.xyz/prober/api/v1" diff --git a/vendor/kmodules.xyz/prober/api/v1/openapi_generated.go b/vendor/kmodules.xyz/prober/api/v1/openapi_generated.go index a84f29ce7..5b1347691 100644 --- a/vendor/kmodules.xyz/prober/api/v1/openapi_generated.go +++ b/vendor/kmodules.xyz/prober/api/v1/openapi_generated.go @@ -1,3 +1,4 @@ +//go:build !ignore_autogenerated // +build !ignore_autogenerated /* diff --git a/vendor/kmodules.xyz/prober/api/v1/zz_generated.deepcopy.go b/vendor/kmodules.xyz/prober/api/v1/zz_generated.deepcopy.go index 7869f6c5a..5b76dd833 100644 --- a/vendor/kmodules.xyz/prober/api/v1/zz_generated.deepcopy.go +++ b/vendor/kmodules.xyz/prober/api/v1/zz_generated.deepcopy.go @@ -1,3 +1,4 @@ +//go:build !ignore_autogenerated // +build !ignore_autogenerated /* diff --git a/vendor/modules.txt b/vendor/modules.txt index 289b9c814..43f80f938 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -29,7 +29,6 @@ github.com/davecgh/go-spew/spew github.com/emicklei/go-restful github.com/emicklei/go-restful/log # github.com/evanphx/json-patch v4.12.0+incompatible -## explicit github.com/evanphx/json-patch # github.com/fatih/structs v1.1.0 github.com/fatih/structs @@ -38,22 +37,16 @@ github.com/form3tech-oss/jwt-go # github.com/go-logr/logr v0.4.0 github.com/go-logr/logr # github.com/go-openapi/jsonpointer v0.19.5 => github.com/go-openapi/jsonpointer v0.19.3 -## explicit github.com/go-openapi/jsonpointer # github.com/go-openapi/jsonreference v0.19.5 => github.com/go-openapi/jsonreference v0.19.3 -## explicit github.com/go-openapi/jsonreference # github.com/go-openapi/spec v0.19.8 => github.com/go-openapi/spec v0.19.5 -## explicit github.com/go-openapi/spec # github.com/go-openapi/swag v0.19.14 => github.com/go-openapi/swag v0.19.5 -## explicit github.com/go-openapi/swag # github.com/gogo/protobuf v1.3.2 => github.com/gogo/protobuf v1.3.2 github.com/gogo/protobuf/proto github.com/gogo/protobuf/sortkeys -# github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da -## explicit # github.com/golang/protobuf v1.5.2 => github.com/golang/protobuf v1.4.3 github.com/golang/protobuf/jsonpb github.com/golang/protobuf/proto @@ -68,7 +61,6 @@ github.com/google/go-cmp/cmp/internal/flags github.com/google/go-cmp/cmp/internal/function github.com/google/go-cmp/cmp/internal/value # github.com/google/gofuzz v1.2.0 -## explicit github.com/google/gofuzz github.com/google/gofuzz/bytesource # github.com/googleapis/gnostic v0.5.5 => github.com/googleapis/gnostic v0.4.1 @@ -87,7 +79,6 @@ github.com/josharian/intern # github.com/json-iterator/go v1.1.12 github.com/json-iterator/go # github.com/mailru/easyjson v0.7.7 -## explicit github.com/mailru/easyjson/buffer github.com/mailru/easyjson/jlexer github.com/mailru/easyjson/jwriter @@ -97,14 +88,8 @@ github.com/mitchellh/mapstructure github.com/modern-go/concurrent # github.com/modern-go/reflect2 v1.0.2 github.com/modern-go/reflect2 -# github.com/onsi/ginkgo v1.16.5 -## explicit -# github.com/onsi/gomega v1.17.0 -## explicit # github.com/pkg/errors v0.9.1 github.com/pkg/errors -# github.com/prometheus/common v0.28.0 -## explicit # github.com/sergi/go-diff v1.2.0 github.com/sergi/go-diff/diffmatchpatch # github.com/spf13/cobra v1.2.1 @@ -125,13 +110,10 @@ go.bytebuilders.dev/license-verifier/info # go.bytebuilders.dev/license-verifier/kubernetes v0.9.7 ## explicit go.bytebuilders.dev/license-verifier/kubernetes -# go.uber.org/zap v1.19.1 -## explicit # golang.org/x/crypto v0.0.0-20210314154223-e6e6c4f2bb5b golang.org/x/crypto/pkcs12 golang.org/x/crypto/pkcs12/internal/rc2 # golang.org/x/net v0.0.0-20211209124913-491a49abca63 -## explicit golang.org/x/net/context golang.org/x/net/context/ctxhttp golang.org/x/net/http/httpguts @@ -139,7 +121,6 @@ golang.org/x/net/http2 golang.org/x/net/http2/hpack golang.org/x/net/idna # golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f -## explicit golang.org/x/oauth2 golang.org/x/oauth2/authhandler golang.org/x/oauth2/google @@ -148,13 +129,11 @@ golang.org/x/oauth2/internal golang.org/x/oauth2/jws golang.org/x/oauth2/jwt # golang.org/x/sys v0.0.0-20211029165221-6e7872819dc8 -## explicit golang.org/x/sys/internal/unsafeheader golang.org/x/sys/plan9 golang.org/x/sys/unix golang.org/x/sys/windows # golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b -## explicit golang.org/x/term # golang.org/x/text v0.3.7 golang.org/x/text/secure/bidirule @@ -187,6 +166,7 @@ gomodules.xyz/sets gomodules.xyz/wait # gomodules.xyz/x v0.0.13 ## explicit +gomodules.xyz/x/arrays gomodules.xyz/x/version # google.golang.org/appengine v1.6.7 google.golang.org/appengine @@ -200,7 +180,6 @@ google.golang.org/appengine/internal/remote_api google.golang.org/appengine/internal/urlfetch google.golang.org/appengine/urlfetch # google.golang.org/protobuf v1.27.1 -## explicit google.golang.org/protobuf/encoding/protojson google.golang.org/protobuf/encoding/prototext google.golang.org/protobuf/encoding/protowire @@ -521,13 +500,11 @@ k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1 k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1beta1 # k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65 => k8s.io/kube-openapi v0.0.0-20210305001622-591a79e4bda7 -## explicit k8s.io/kube-openapi/pkg/common k8s.io/kube-openapi/pkg/util/proto # k8s.io/kubernetes v1.21.1 => github.com/kmodules/kubernetes v1.22.0-alpha.0.0.20210617232219-a432af45d932 k8s.io/kubernetes/pkg/util/hash # k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b => k8s.io/utils v0.0.0-20201110183641-67b214c5f920 -## explicit k8s.io/utils/buffer k8s.io/utils/integer k8s.io/utils/pointer @@ -558,12 +535,11 @@ kmodules.xyz/custom-resources/client/clientset/versioned/typed/auditor/v1alpha1 kmodules.xyz/custom-resources/client/clientset/versioned/typed/metrics/v1alpha1 kmodules.xyz/custom-resources/crds # kmodules.xyz/objectstore-api v0.0.0-20220317220441-f1d593d0a778 -## explicit kmodules.xyz/objectstore-api/api/v1 -# kmodules.xyz/offshoot-api v0.0.0-20220323112402-3b0fd2ea77d6 +# kmodules.xyz/offshoot-api v0.0.0-20220329041708-c076b2bcb0f8 ## explicit kmodules.xyz/offshoot-api/api/v1 -# kmodules.xyz/prober v0.0.0-20210618020259-5836fb959027 +# kmodules.xyz/prober v0.0.0-20220317043828-5ae0114adcad kmodules.xyz/prober/api/v1 # sigs.k8s.io/controller-runtime v0.9.0 sigs.k8s.io/controller-runtime/pkg/client @@ -571,17 +547,14 @@ sigs.k8s.io/controller-runtime/pkg/client/apiutil sigs.k8s.io/controller-runtime/pkg/log sigs.k8s.io/controller-runtime/pkg/scheme # sigs.k8s.io/structured-merge-diff/v4 v4.2.0 -## explicit sigs.k8s.io/structured-merge-diff/v4/fieldpath sigs.k8s.io/structured-merge-diff/v4/schema sigs.k8s.io/structured-merge-diff/v4/typed sigs.k8s.io/structured-merge-diff/v4/value # sigs.k8s.io/yaml v1.3.0 -## explicit sigs.k8s.io/yaml -# stash.appscode.dev/apimachinery v0.18.0 +# stash.appscode.dev/apimachinery v0.19.0 ## explicit -stash.appscode.dev/apimachinery/apis stash.appscode.dev/apimachinery/apis/repositories stash.appscode.dev/apimachinery/apis/repositories/v1alpha1 stash.appscode.dev/apimachinery/apis/stash diff --git a/vendor/stash.appscode.dev/apimachinery/apis/constants.go b/vendor/stash.appscode.dev/apimachinery/apis/constants.go deleted file mode 100644 index c524f0f68..000000000 --- a/vendor/stash.appscode.dev/apimachinery/apis/constants.go +++ /dev/null @@ -1,344 +0,0 @@ -/* -Copyright AppsCode Inc. and Contributors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package apis - -import "time" - -const ( - StashDockerRegistry = "STASH_DOCKER_REGISTRY" - StashDockerImage = "STASH_DOCKER_IMAGE" - StashImageTag = "STASH_IMAGE_TAG" - ImageStash = "stash" - - Namespace = "NAMESPACE" - BackupSession = "BACKUP_SESSION" - RestoreSession = "RESTORE_SESSION" - - RepositoryName = "REPOSITORY_NAME" - RepositoryNamespace = "REPOSITORY_NAMESPACE" - RepositoryProvider = "REPOSITORY_PROVIDER" - RepositorySecretName = "REPOSITORY_SECRET_NAME" - RepositorySecretNamespace = "REPOSITORY_SECRET_NAMESPACE" - RepositoryBucket = "REPOSITORY_BUCKET" - RepositoryPrefix = "REPOSITORY_PREFIX" - RepositoryEndpoint = "REPOSITORY_ENDPOINT" - RepositoryRegion = "REPOSITORY_REGION" - - Hostname = "HOSTNAME" - SourceHostname = "SOURCE_HOSTNAME" - InterimDataDir = "INTERIM_DATA_DIR" - - TargetName = "TARGET_NAME" - TargetAPIVersion = "TARGET_API_VERSION" - TargetKind = "TARGET_KIND" - TargetResource = "TARGET_RESOURCE" - TargetNamespace = "TARGET_NAMESPACE" - TargetMountPath = "TARGET_MOUNT_PATH" - TargetPaths = "TARGET_PATHS" - - TargetAppVersion = "TARGET_APP_VERSION" - TargetAppType = "TARGET_APP_TYPE" - TargetAppGroup = "TARGET_APP_GROUP" - TargetAppResource = "TARGET_APP_RESOURCE" - TargetAppReplicas = "TARGET_APP_REPLICAS" - - InvokerKind = "INVOKER_KIND" - InvokerName = "INVOKER_NAME" - AddonImage = "ADDON_IMAGE" - - ExcludePatterns = "EXCLUDE_PATTERNS" - IncludePatterns = "INCLUDE_PATTERNS" - - RestorePaths = "RESTORE_PATHS" - RestoreSnapshots = "RESTORE_SNAPSHOTS" - - RetentionKeepLast = "RETENTION_KEEP_LAST" - RetentionKeepHourly = "RETENTION_KEEP_HOURLY" - RetentionKeepDaily = "RETENTION_KEEP_DAILY" - RetentionKeepWeekly = "RETENTION_KEEP_WEEKLY" - RetentionKeepMonthly = "RETENTION_KEEP_MONTHLY" - RetentionKeepYearly = "RETENTION_KEEP_YEARLY" - RetentionKeepTags = "RETENTION_KEEP_TAGS" - RetentionPrune = "RETENTION_PRUNE" - RetentionDryRun = "RETENTION_DRY_RUN" - - // default true - // false when TmpDir.DisableCaching is true in backupConfig/restoreSession - EnableCache = "ENABLE_CACHE" - MaxConnections = "MAX_CONNECTIONS" - - PushgatewayURL = "PROMETHEUS_PUSHGATEWAY_URL" - PrometheusJobName = "PROMETHEUS_JOB_NAME" - - StashDefaultVolume = "stash-volume" - StashDefaultMountPath = "/stash-data" - StashInterimVolume = "stash-interim-volume" - StashInterimVolumeMountPath = "/stash-interim-volume" - StashInterimDataDir = "/stash-interim-volume/data" - - // backup or restore hooks - HookType = "HOOK_TYPE" - PreBackupHook = "preBackup" - PostBackupHook = "postBackup" - PreRestoreHook = "preRestore" - PostRestoreHook = "postRestore" - PreTaskHook = "pre-task-hook" - PostTaskHook = "post-task-hook" - - // License related constants - LicenseApiService = "LICENSE_APISERVICE" - LicenseReader = "appscode:license-reader" -) - -const ( - PrefixStashBackup = "stash-backup" - PrefixStashRestore = "stash-restore" - PrefixStashVolumeSnapshot = "stash-vs" - PrefixStashTrigger = "stash-trigger" - - StashContainer = "stash" - StashInitContainer = "stash-init" - StashCronJobContainer = "stash-trigger" - LocalVolumeName = "stash-local" - ScratchDirVolumeName = "stash-scratchdir" - TmpDirVolumeName = "tmp-dir" - TmpDirMountPath = "/tmp" - PodinfoVolumeName = "stash-podinfo" - - RecoveryJobPrefix = "stash-recovery-" - ScaledownCronPrefix = "stash-scaledown-cron-" - CheckJobPrefix = "stash-check-" - - AnnotationRestic = "restic" - AnnotationRecovery = "recovery" - AnnotationOperation = "operation" - AnnotationOldReplica = "old-replica" - - OperationRecovery = "recovery" - OperationCheck = "check" - - AppLabelStash = "stash" - AppLabelStashV1Beta1 = "stash-v1beta1" - OperationScaleDown = "scale-down" - - RepositoryFinalizer = "stash" - SnapshotIDLength = 8 - - ModelSidecar = "sidecar" - ModelCronJob = "cronjob" - LabelApp = "app" - LabelInvokerType = StashKey + "/invoker-type" - LabelInvokerName = StashKey + "/invoker-name" - StashSecretVolume = "stash-secret-volume" - StashSecretMountDir = "/etc/stash/repository/secret" - StashNetVolAccessor = "stash-netvol-accessor" - - KeyPodName = "POD_NAME" - KeyNodeName = "NODE_NAME" - KeyPodOrdinal = "POD_ORDINAL" - - RetryInterval = 50 * time.Millisecond - ReadinessTimeout = 2 * time.Minute -) - -const ( - CallerWebhook = "webhook" - CallerController = "controller" - DefaultHost = "host-0" -) - -// ==================== Prometheus metrics related constants ============ -const ( - PromJobStashBackup = "stash-backup" - PromJobStashRestore = "stash-restore" - - // RepositoryMetricsPushed whether the Repository metrics for this backup session were pushed or not - RepositoryMetricsPushed = "RepositoryMetricsPushed" - // SuccessfullyPushedRepositoryMetrics indicates that the condition transitioned to this state because the repository metrics was successfully pushed to the pushgateway - SuccessfullyPushedRepositoryMetrics = "SuccessfullyPushedRepositoryMetrics" - // FailedToPushRepositoryMetrics indicates that the condition transitioned to this state because the Stash was unable to push the repository metrics to the pushgateway - FailedToPushRepositoryMetrics = "FailedToPushRepositoryMetrics" - - // MetricsPushed whether the metrics for this backup session were pushed or not - MetricsPushed = "MetricsPushed" - // SuccessfullyPushedMetrics indicates that the condition transitioned to this state because the metrics was successfully pushed to the pushgateway - SuccessfullyPushedMetrics = "SuccessfullyPushedMetrics" - // FailedToPushMetrics indicates that the condition transitioned to this state because the Stash was unable to push the metrics to the pushgateway - FailedToPushMetrics = "FailedToPushMetrics" -) - -// ==================== RBAC related constants ========================== -const ( - KindRole = "Role" - KindClusterRole = "ClusterRole" - - StashBackupJobClusterRole = "stash-backup-job" - StashRestoreJobClusterRole = "stash-restore-job" - StashCronJobClusterRole = "stash-cron-job" - StashSidecarClusterRole = "stash-sidecar" - StashRestoreInitContainerClusterRole = "stash-restore-init-container" - - StashVolumeSnapshotterClusterRole = "stash-vs-job" - StashVolumeSnapshotRestorerClusterRole = "stash-vs-restorer-job" - StashStorageClassReaderClusterRole = "stash-sc-reader" -) - -// ================== Condition Types Related Constants =========================== -const ( - // RepositoryFound indicates whether the respective Repository object was found or not. - RepositoryFound = "RepositoryFound" - // ValidationPassed indicates the validation conditions of the CRD are passed or not. - ValidationPassed = "ValidationPassed" - // ResourceValidationPassed indicates that the condition transitioned to this state because the CRD meets validation criteria - ResourceValidationPassed = "ResourceValidationPassed" - // ResourceValidationFailed indicates that the condition transitioned to this state because the CRD does not meet validation criteria - ResourceValidationFailed = "ResourceValidationFailed" - // BackendSecretFound indicates whether the respective backend secret was found or not. - BackendSecretFound = "BackendSecretFound" - - // BackupTargetFound indicates whether the backup target was found - BackupTargetFound = "BackupTargetFound" - // StashSidecarInjected indicates whether stash sidecar was injected into the targeted workload - // This condition is applicable only for sidecar model - StashSidecarInjected = "StashSidecarInjected" - // CronJobCreated indicates whether the backup triggering CronJob was created - CronJobCreated = "CronJobCreated" - - // RestoreTargetFound indicates whether the restore target was found - RestoreTargetFound = "RestoreTargetFound" - // StashInitContainerInjected indicates whether stash init-container was injected into the targeted workload - // This condition is applicable only for sidecar model - StashInitContainerInjected = "StashInitContainerInjected" - // RestoreJobCreated indicates whether the restore job was created - RestoreJobCreated = "RestoreJobCreated" - // RestoreCompleted condition indicates whether the restore process has been completed or not. - // This condition is particularly helpful when the restore addon require some additional operations to perform - // before marking the RestoreSession Succeeded/Failed. - RestoreCompleted = "RestoreCompleted" - // RestorerEnsured condition indicates whether the restore job / init-container was created or not. - RestorerEnsured = "RestorerEnsured" - - // GlobalPreBackupHookSucceeded indicates whether the global PreBackupHook was executed successfully or not - GlobalPreBackupHookSucceeded = "GlobalPreBackupHookSucceeded" - // GlobalPostBackupHookSucceeded indicates whether the global PostBackupHook was executed successfully or not - GlobalPostBackupHookSucceeded = "GlobalPostBackupHookSucceeded" - // GlobalPreRestoreHookSucceeded indicates whether the global PreRestoreHook was executed successfully or not - GlobalPreRestoreHookSucceeded = "GlobalPreRestoreHookSucceeded" - // GlobalPostRestoreHookSucceeded indicates whether the global PostRestoreHook was executed successfully or not - GlobalPostRestoreHookSucceeded = "GlobalPostRestoreHookSucceeded" - // BackendRepositoryInitialized indicates that whether backend repository was initialized or not - BackendRepositoryInitialized = "BackendRepositoryInitialized" - // RetentionPolicyApplied indicates that whether the retention policies were applied or not - RetentionPolicyApplied = "RetentionPolicyApplied" - // RepositoryIntegrityVerified indicates whether the repository integrity check succeeded or not - RepositoryIntegrityVerified = "RepositoryIntegrityVerified" -) - -// ================== Condition Types Related Constants =========================== -const ( - // RepositoryAvailable indicates that the condition transitioned to this state because the Repository was available - RepositoryAvailable = "RepositoryAvailable" - // RepositoryNotAvailable indicates that the condition transitioned to this state because the Repository was not available - RepositoryNotAvailable = "RepositoryNotAvailable" - // UnableToCheckRepositoryAvailability indicates that the condition transitioned to this state because operator was unable - // to check the Repository availability - UnableToCheckRepositoryAvailability = "UnableToCheckRepositoryAvailability" - - // BackendSecretAvailable indicates that the condition transitioned to this state because the backend Secret was available - BackendSecretAvailable = "BackendSecretAvailable" - // BackendSecretNotAvailable indicates that the condition transitioned to this state because the backend Secret was not available - BackendSecretNotAvailable = "BackendSecretNotAvailable" - // UnableToCheckBackendSecretAvailability indicates that the condition transitioned to this state because operator was unable - // to check the backend Secret availability - UnableToCheckBackendSecretAvailability = "UnableToCheckBackendSecretAvailability" - - // TargetAvailable indicates that the condition transitioned to this state because the target was available - TargetAvailable = "TargetAvailable" - // TargetNotAvailable indicates that the condition transitioned to this state because the target was not available - TargetNotAvailable = "TargetNotAvailable" - // UnableToCheckTargetAvailability indicates that the condition transitioned to this state because operator was unable - // to check the target availability - UnableToCheckTargetAvailability = "UnableToCheckTargetAvailability" - - // SidecarInjectionSucceeded indicates that the condition transitioned to this state because sidecar was injected - // successfully into the targeted workload - SidecarInjectionSucceeded = "SidecarInjectionSucceeded" - // SidecarInjectionFailed indicates that the condition transitioned to this state because operator was unable - // to inject sidecar into the targeted workload - SidecarInjectionFailed = "SidecarInjectionFailed" - - // InitContainerInjectionSucceeded indicates that the condition transitioned to this state because stash init-container - // was injected successfully into the targeted workload - InitContainerInjectionSucceeded = "InitContainerInjectionSucceeded" - // InitContainerInjectionFailed indicates that the condition transitioned to this state because operator was unable - // to inject stash init-container into the targeted workload - InitContainerInjectionFailed = "InitContainerInjectionFailed" - - // CronJobCreationSucceeded indicates that the condition transitioned to this state because backup triggering CronJob was created successfully - CronJobCreationSucceeded = "CronJobCreationSucceeded" - // CronJobCreationFailed indicates that the condition transitioned to this state because operator was unable to create backup triggering CronJob - CronJobCreationFailed = "CronJobCreationFailed" - - // RestoreJobCreationSucceeded indicates that the condition transitioned to this state because restore job was created successfully - RestoreJobCreationSucceeded = "RestoreJobCreationSucceeded" - // RestoreJobCreationFailed indicates that the condition transitioned to this state because operator was unable to create restore job - RestoreJobCreationFailed = "RestoreJobCreationFailed" - - // GlobalPreBackupHookExecutedSuccessfully indicates that the condition transitioned to this state because the global PreBackupHook was executed successfully - GlobalPreBackupHookExecutedSuccessfully = "GlobalPreBackupHookExecutedSuccessfully" - // GlobalPreBackupHookExecutionFailed indicates that the condition transitioned to this state because the Stash was unable to execute global PreBackupHook - GlobalPreBackupHookExecutionFailed = "GlobalPreBackupHookExecutionFailed" - - // GlobalPostBackupHookExecutedSuccessfully indicates that the condition transitioned to this state because the global PostBackupHook was executed successfully - GlobalPostBackupHookExecutedSuccessfully = "GlobalPostBackupHookExecutedSuccessfully" - // GlobalPostBackupHookExecutionFailed indicates that the condition transitioned to this state because the Stash was unable to execute global PostBackupHook - GlobalPostBackupHookExecutionFailed = "GlobalPostBackupHookExecutionFailed" - - // GlobalPreRestoreHookExecutedSuccessfully indicates that the condition transitioned to this state because the global PreRestoreHook was executed successfully - GlobalPreRestoreHookExecutedSuccessfully = "GlobalPreRestoreHookExecutedSuccessfully" - // GlobalPreRestoreHookExecutionFailed indicates that the condition transitioned to this state because the Stash was unable to execute global PreRestoreHook - GlobalPreRestoreHookExecutionFailed = "GlobalPreRestoreHookExecutionFailed" - - // GlobalPostRestoreHookExecutedSuccessfully indicates that the condition transitioned to this state because the global PostRestoreHook was executed successfully - GlobalPostRestoreHookExecutedSuccessfully = "GlobalPostRestoreHookExecutedSuccessfully" - // GlobalPostRestoreHookExecutionFailed indicates that the condition transitioned to this state because the Stash was unable to execute global PostRestoreHook - GlobalPostRestoreHookExecutionFailed = "GlobalPostRestoreHookExecutionFailed" - - // BackendRepositoryFound indicates that the condition transitioned to this state because the restic repository was found in the backend - BackendRepositoryFound = "BackendRepositoryFound" - // FailedToInitializeBackendRepository indicates that the condition transitioned to this state because the Stash was unable to initialize a repository in the backend - FailedToInitializeBackendRepository = "FailedToInitializeBackendRepository" - // SuccessfullyAppliedRetentionPolicy indicates that the condition transitioned to this state because the retention policies was applied successfully - SuccessfullyAppliedRetentionPolicy = "SuccessfullyAppliedRetentionPolicy" - // FailedToApplyRetentionPolicy indicates that the condition transitioned to this state because the Stash was unable to apply the retention policies - FailedToApplyRetentionPolicy = "FailedToApplyRetentionPolicy" - // SuccessfullyVerifiedRepositoryIntegrity indicates that the condition transitioned to this state because the repository has passed the integrity check - SuccessfullyVerifiedRepositoryIntegrity = "SuccessfullyVerifiedRepositoryIntegrity" - // FailedToVerifyRepositoryIntegrity indicates that the condition transitioned to this state because the repository has failed the integrity check - FailedToVerifyRepositoryIntegrity = "FailedToVerifyRepositoryIntegrity" -) - -// ==================== Action related constants ============ -const ( - // Pre-backup actions - InitializeBackendRepository = "InitializeBackendRepository" - - // Post-backup actions - ApplyRetentionPolicy = "ApplyRetentionPolicy" - VerifyRepositoryIntegrity = "VerifyRepositoryIntegrity" - SendRepositoryMetrics = "SendRepositoryMetrics" -) diff --git a/vendor/stash.appscode.dev/apimachinery/apis/repositories/v1alpha1/openapi_generated.go b/vendor/stash.appscode.dev/apimachinery/apis/repositories/v1alpha1/openapi_generated.go index f9e3f5ec3..6d9feb925 100644 --- a/vendor/stash.appscode.dev/apimachinery/apis/repositories/v1alpha1/openapi_generated.go +++ b/vendor/stash.appscode.dev/apimachinery/apis/repositories/v1alpha1/openapi_generated.go @@ -17298,6 +17298,12 @@ func schema_custom_resources_apis_appcatalog_v1alpha1_AppBindingSpec(ref common. Ref: ref("k8s.io/apimachinery/pkg/runtime.RawExtension"), }, }, + "tlsSecret": { + SchemaProps: spec.SchemaProps{ + Description: "TLSSecret is the name of the secret that will hold the client certificate and private key associated with the AppBinding.", + Ref: ref("k8s.io/api/core/v1.LocalObjectReference"), + }, + }, }, Required: []string{"clientConfig"}, }, @@ -17378,6 +17384,13 @@ func schema_custom_resources_apis_appcatalog_v1alpha1_ClientConfig(ref common.Re Format: "byte", }, }, + "serverName": { + SchemaProps: spec.SchemaProps{ + Description: "ServerName is used to verify the hostname on the returned certificates unless InsecureSkipVerify is given. It is also included in the client's handshake to support virtual hosting unless it is an IP address.", + Type: []string{"string"}, + Format: "", + }, + }, }, }, }, @@ -18459,6 +18472,22 @@ func schema_kmodulesxyz_offshoot_api_api_v1_PodRuntimeSettings(ref common.Refere SchemaProps: spec.SchemaProps{ Type: []string{"object"}, Properties: map[string]spec.Schema{ + "podAnnotations": { + SchemaProps: spec.SchemaProps{ + Description: "PodAnnotations are the annotations that will be attached with the respective Pod", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, "nodeSelector": { SchemaProps: spec.SchemaProps{ Description: "NodeSelector is a selector which must be true for the pod to fit on a node. Selector which must match a node's labels for the pod to be scheduled on that node. More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/", @@ -18482,6 +18511,22 @@ func schema_kmodulesxyz_offshoot_api_api_v1_PodRuntimeSettings(ref common.Refere Format: "", }, }, + "serviceAccountAnnotations": { + SchemaProps: spec.SchemaProps{ + Description: "ServiceAccountAnnotations are the annotations that will be attached with the respective ServiceAccount", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, "automountServiceAccountToken": { SchemaProps: spec.SchemaProps{ Description: "AutomountServiceAccountToken indicates whether a service account token should be automatically mounted.", diff --git a/vendor/stash.appscode.dev/apimachinery/apis/stash/v1alpha1/openapi_generated.go b/vendor/stash.appscode.dev/apimachinery/apis/stash/v1alpha1/openapi_generated.go index 93854961c..1b00eff4a 100644 --- a/vendor/stash.appscode.dev/apimachinery/apis/stash/v1alpha1/openapi_generated.go +++ b/vendor/stash.appscode.dev/apimachinery/apis/stash/v1alpha1/openapi_generated.go @@ -17303,6 +17303,12 @@ func schema_custom_resources_apis_appcatalog_v1alpha1_AppBindingSpec(ref common. Ref: ref("k8s.io/apimachinery/pkg/runtime.RawExtension"), }, }, + "tlsSecret": { + SchemaProps: spec.SchemaProps{ + Description: "TLSSecret is the name of the secret that will hold the client certificate and private key associated with the AppBinding.", + Ref: ref("k8s.io/api/core/v1.LocalObjectReference"), + }, + }, }, Required: []string{"clientConfig"}, }, @@ -17383,6 +17389,13 @@ func schema_custom_resources_apis_appcatalog_v1alpha1_ClientConfig(ref common.Re Format: "byte", }, }, + "serverName": { + SchemaProps: spec.SchemaProps{ + Description: "ServerName is used to verify the hostname on the returned certificates unless InsecureSkipVerify is given. It is also included in the client's handshake to support virtual hosting unless it is an IP address.", + Type: []string{"string"}, + Format: "", + }, + }, }, }, }, @@ -18464,6 +18477,22 @@ func schema_kmodulesxyz_offshoot_api_api_v1_PodRuntimeSettings(ref common.Refere SchemaProps: spec.SchemaProps{ Type: []string{"object"}, Properties: map[string]spec.Schema{ + "podAnnotations": { + SchemaProps: spec.SchemaProps{ + Description: "PodAnnotations are the annotations that will be attached with the respective Pod", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, "nodeSelector": { SchemaProps: spec.SchemaProps{ Description: "NodeSelector is a selector which must be true for the pod to fit on a node. Selector which must match a node's labels for the pod to be scheduled on that node. More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/", @@ -18487,6 +18516,22 @@ func schema_kmodulesxyz_offshoot_api_api_v1_PodRuntimeSettings(ref common.Refere Format: "", }, }, + "serviceAccountAnnotations": { + SchemaProps: spec.SchemaProps{ + Description: "ServiceAccountAnnotations are the annotations that will be attached with the respective ServiceAccount", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, "automountServiceAccountToken": { SchemaProps: spec.SchemaProps{ Description: "AutomountServiceAccountToken indicates whether a service account token should be automatically mounted.", diff --git a/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/backup_batch_types.go b/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/backup_batch_types.go index 4b1ff5164..63cea1ca7 100644 --- a/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/backup_batch_types.go +++ b/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/backup_batch_types.go @@ -120,3 +120,25 @@ type BackupBatchList struct { metav1.ListMeta `json:"metadata,omitempty"` Items []BackupBatch `json:"items,omitempty"` } + +// =============================== Condition Types ============================= +const ( + // GlobalPreBackupHookSucceeded indicates whether the global PreBackupHook was executed successfully or not + GlobalPreBackupHookSucceeded = "GlobalPreBackupHookSucceeded" + + // GlobalPostBackupHookSucceeded indicates whether the global PostBackupHook was executed successfully or not + GlobalPostBackupHookSucceeded = "GlobalPostBackupHookSucceeded" +) + +// ============================== Condition Reasons =========================== +const ( + // GlobalPreBackupHookExecutedSuccessfully indicates that the condition transitioned to this state because the global PreBackupHook was executed successfully + GlobalPreBackupHookExecutedSuccessfully = "GlobalPreBackupHookExecutedSuccessfully" + // GlobalPreBackupHookExecutionFailed indicates that the condition transitioned to this state because the Stash was unable to execute global PreBackupHook + GlobalPreBackupHookExecutionFailed = "GlobalPreBackupHookExecutionFailed" + + // GlobalPostBackupHookExecutedSuccessfully indicates that the condition transitioned to this state because the global PostBackupHook was executed successfully + GlobalPostBackupHookExecutedSuccessfully = "GlobalPostBackupHookExecutedSuccessfully" + // GlobalPostBackupHookExecutionFailed indicates that the condition transitioned to this state because the Stash was unable to execute global PostBackupHook + GlobalPostBackupHookExecutionFailed = "GlobalPostBackupHookExecutionFailed" +) diff --git a/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/backup_blueprint_types.go b/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/backup_blueprint_types.go index d38ed72df..1c4d04496 100644 --- a/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/backup_blueprint_types.go +++ b/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/backup_blueprint_types.go @@ -48,7 +48,12 @@ type BackupBlueprint struct { type BackupBlueprintSpec struct { // RepositorySpec is used to create Repository crd for respective workload v1alpha1.RepositorySpec `json:",inline"` - Schedule string `json:"schedule,omitempty"` + // RepoNamespace specifies the namespace where the Repository will be created for the respective target + // +optional + RepoNamespace string `json:"repoNamespace,omitempty"` + // Schedule specifies the default schedule for backup. + // You can overwrite this schedule for a particular target using 'stash.appscode.com/schedule' annotation. + Schedule string `json:"schedule,omitempty"` // Task specify the Task crd that specifies steps for backup process // +optional Task TaskRef `json:"task,omitempty"` diff --git a/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/backup_configuration_types.go b/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/backup_configuration_types.go index b5e702f20..9208a03c1 100644 --- a/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/backup_configuration_types.go +++ b/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/backup_configuration_types.go @@ -159,3 +159,69 @@ const ( BackupInvokerReady BackupInvokerPhase = "Ready" BackupInvokerNotReady BackupInvokerPhase = "NotReady" ) + +// ==================== Condition Types ============================ +const ( + // BackupTargetFound indicates whether the backup target was found + BackupTargetFound = "BackupTargetFound" + + // StashSidecarInjected indicates whether stash sidecar was injected into the targeted workload + // This condition is applicable only for sidecar model + StashSidecarInjected = "StashSidecarInjected" + + // CronJobCreated indicates whether the backup triggering CronJob was created + CronJobCreated = "CronJobCreated" + + // RepositoryFound indicates whether the respective Repository object was found or not. + RepositoryFound = "RepositoryFound" + + // BackendSecretFound indicates whether the respective backend secret was found or not. + BackendSecretFound = "BackendSecretFound" + + // ValidationPassed indicates the validation conditions of the CRD are passed or not. + ValidationPassed = "ValidationPassed" +) + +// ======================= Condition Reasons =========================== +const ( + // TargetAvailable indicates that the condition transitioned to this state because the target was available + TargetAvailable = "TargetAvailable" + // TargetNotAvailable indicates that the condition transitioned to this state because the target was not available + TargetNotAvailable = "TargetNotAvailable" + // UnableToCheckTargetAvailability indicates that the condition transitioned to this state because operator was unable + // to check the target availability + UnableToCheckTargetAvailability = "UnableToCheckTargetAvailability" + + // SidecarInjectionSucceeded indicates that the condition transitioned to this state because sidecar was injected + // successfully into the targeted workload + SidecarInjectionSucceeded = "SidecarInjectionSucceeded" + // SidecarInjectionFailed indicates that the condition transitioned to this state because operator was unable + // to inject sidecar into the targeted workload + SidecarInjectionFailed = "SidecarInjectionFailed" + + // CronJobCreationSucceeded indicates that the condition transitioned to this state because backup triggering CronJob was created successfully + CronJobCreationSucceeded = "CronJobCreationSucceeded" + // CronJobCreationFailed indicates that the condition transitioned to this state because operator was unable to create backup triggering CronJob + CronJobCreationFailed = "CronJobCreationFailed" + + // RepositoryAvailable indicates that the condition transitioned to this state because the Repository was available + RepositoryAvailable = "RepositoryAvailable" + // RepositoryNotAvailable indicates that the condition transitioned to this state because the Repository was not available + RepositoryNotAvailable = "RepositoryNotAvailable" + // UnableToCheckRepositoryAvailability indicates that the condition transitioned to this state because operator was unable + // to check the Repository availability + UnableToCheckRepositoryAvailability = "UnableToCheckRepositoryAvailability" + + // BackendSecretAvailable indicates that the condition transitioned to this state because the backend Secret was available + BackendSecretAvailable = "BackendSecretAvailable" + // BackendSecretNotAvailable indicates that the condition transitioned to this state because the backend Secret was not available + BackendSecretNotAvailable = "BackendSecretNotAvailable" + // UnableToCheckBackendSecretAvailability indicates that the condition transitioned to this state because operator was unable + // to check the backend Secret availability + UnableToCheckBackendSecretAvailability = "UnableToCheckBackendSecretAvailability" + + // ResourceValidationPassed indicates that the condition transitioned to this state because the CRD meets validation criteria + ResourceValidationPassed = "ResourceValidationPassed" + // ResourceValidationFailed indicates that the condition transitioned to this state because the CRD does not meet validation criteria + ResourceValidationFailed = "ResourceValidationFailed" +) diff --git a/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/backup_session_types.go b/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/backup_session_types.go index 9cab82b73..f008f01c6 100644 --- a/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/backup_session_types.go +++ b/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/backup_session_types.go @@ -117,6 +117,9 @@ type BackupTargetStatus struct { // PostBackupActions specifies a list of actions that the backup process should execute after taking backup // +optional PostBackupActions []string `json:"postBackupActions,omitempty"` + // Conditions shows condition of different operations/steps of the backup process for this target + // +optional + Conditions []kmapi.Condition `json:"conditions,omitempty"` } type HostBackupStats struct { @@ -170,3 +173,83 @@ type BackupSessionList struct { metav1.ListMeta `json:"metadata,omitempty"` Items []BackupSession `json:"items,omitempty"` } + +// =============================== Pre-backup Actions ============================ +const ( + InitializeBackendRepository = "InitializeBackendRepository" +) + +// ============================== Post-backup Actions ========================== +const ( + ApplyRetentionPolicy = "ApplyRetentionPolicy" + VerifyRepositoryIntegrity = "VerifyRepositoryIntegrity" + SendRepositoryMetrics = "SendRepositoryMetrics" +) + +// ============================ Condition Types ======================== +const ( + // RetentionPolicyApplied indicates that whether the retention policies were applied or not + RetentionPolicyApplied = "RetentionPolicyApplied" + + // BackendRepositoryInitialized indicates that whether backend repository was initialized or not + BackendRepositoryInitialized = "BackendRepositoryInitialized" + + // RepositoryIntegrityVerified indicates whether the repository integrity check succeeded or not + RepositoryIntegrityVerified = "RepositoryIntegrityVerified" + + // RepositoryMetricsPushed indicates whether the Repository metrics for this backup session were pushed or not + RepositoryMetricsPushed = "RepositoryMetricsPushed" + + // BackupSkipped indicates that the current session was skipped + BackupSkipped = "BackupSkipped" + + // BackupHistoryCleaned indicates whether the backup history was cleaned or not according to backupHistoryLimit + BackupHistoryCleaned = "BackupHistoryCleaned" + + // BackupExecutorEnsured indicates whether the backup executor entity was created or not + BackupExecutorEnsured = "BackupExecutorEnsured" + + // PreBackupHookExecutionSucceeded indicates whether the preBackup hook was executed successfully or not + PreBackupHookExecutionSucceeded = "PreBackupHookExecutionSucceeded" + + // PostBackupHookExecutionSucceeded indicates whether the postBackup hook was executed successfully or not + PostBackupHookExecutionSucceeded = "PostBackupHookExecutionSucceeded" +) + +// =========================== Condition Reasons ======================= +const ( + // SuccessfullyAppliedRetentionPolicy indicates that the condition transitioned to this state because the retention policies was applied successfully + SuccessfullyAppliedRetentionPolicy = "SuccessfullyAppliedRetentionPolicy" + // FailedToApplyRetentionPolicy indicates that the condition transitioned to this state because the Stash was unable to apply the retention policies + FailedToApplyRetentionPolicy = "FailedToApplyRetentionPolicy" + + // BackendRepositoryFound indicates that the condition transitioned to this state because the restic repository was found in the backend + BackendRepositoryFound = "BackendRepositoryFound" + // FailedToInitializeBackendRepository indicates that the condition transitioned to this state because the Stash was unable to initialize a repository in the backend + FailedToInitializeBackendRepository = "FailedToInitializeBackendRepository" + + // SuccessfullyVerifiedRepositoryIntegrity indicates that the condition transitioned to this state because the repository has passed the integrity check + SuccessfullyVerifiedRepositoryIntegrity = "SuccessfullyVerifiedRepositoryIntegrity" + // FailedToVerifyRepositoryIntegrity indicates that the condition transitioned to this state because the repository has failed the integrity check + FailedToVerifyRepositoryIntegrity = "FailedToVerifyRepositoryIntegrity" + + // SuccessfullyPushedRepositoryMetrics indicates that the condition transitioned to this state because the repository metrics was successfully pushed to the pushgateway + SuccessfullyPushedRepositoryMetrics = "SuccessfullyPushedRepositoryMetrics" + // FailedToPushRepositoryMetrics indicates that the condition transitioned to this state because the Stash was unable to push the repository metrics to the pushgateway + FailedToPushRepositoryMetrics = "FailedToPushRepositoryMetrics" + + // SkippedTakingNewBackup indicates that the backup was skipped because another backup was running or backup invoker is not ready state. + SkippedTakingNewBackup = "SkippedTakingNewBackup" + + SuccessfullyCleanedBackupHistory = "SuccessfullyCleanedBackupHistory" + FailedToCleanBackupHistory = "FailedToCleanBackupHistory" + + SuccessfullyEnsuredBackupExecutor = "SuccessfullyEnsuredBackupExecutor" + FailedToEnsureBackupExecutor = "FailedToEnsureBackupExecutor" + + SuccessfullyExecutedPreBackupHook = "SuccessfullyExecutedPreBackupHook" + FailedToExecutePreBackupHook = "FailedToExecutePreBackupHook" + + SuccessfullyExecutedPostBackupHook = "SuccessfullyExecutedPostBackupHook" + FailedToExecutePostBackupHook = "FailedToExecutePostBackupHook" +) diff --git a/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/openapi_generated.go b/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/openapi_generated.go index 4c5172652..82a43c226 100644 --- a/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/openapi_generated.go +++ b/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/openapi_generated.go @@ -435,7 +435,9 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "stash.appscode.dev/apimachinery/apis/stash/v1beta1.RestoreTargetSpec": schema_apimachinery_apis_stash_v1beta1_RestoreTargetSpec(ref), "stash.appscode.dev/apimachinery/apis/stash/v1beta1.Rule": schema_apimachinery_apis_stash_v1beta1_Rule(ref), "stash.appscode.dev/apimachinery/apis/stash/v1beta1.SnapshotStats": schema_apimachinery_apis_stash_v1beta1_SnapshotStats(ref), + "stash.appscode.dev/apimachinery/apis/stash/v1beta1.Summary": schema_apimachinery_apis_stash_v1beta1_Summary(ref), "stash.appscode.dev/apimachinery/apis/stash/v1beta1.TargetRef": schema_apimachinery_apis_stash_v1beta1_TargetRef(ref), + "stash.appscode.dev/apimachinery/apis/stash/v1beta1.TargetStatus": schema_apimachinery_apis_stash_v1beta1_TargetStatus(ref), "stash.appscode.dev/apimachinery/apis/stash/v1beta1.Task": schema_apimachinery_apis_stash_v1beta1_Task(ref), "stash.appscode.dev/apimachinery/apis/stash/v1beta1.TaskList": schema_apimachinery_apis_stash_v1beta1_TaskList(ref), "stash.appscode.dev/apimachinery/apis/stash/v1beta1.TaskRef": schema_apimachinery_apis_stash_v1beta1_TaskRef(ref), @@ -17344,6 +17346,12 @@ func schema_custom_resources_apis_appcatalog_v1alpha1_AppBindingSpec(ref common. Ref: ref("k8s.io/apimachinery/pkg/runtime.RawExtension"), }, }, + "tlsSecret": { + SchemaProps: spec.SchemaProps{ + Description: "TLSSecret is the name of the secret that will hold the client certificate and private key associated with the AppBinding.", + Ref: ref("k8s.io/api/core/v1.LocalObjectReference"), + }, + }, }, Required: []string{"clientConfig"}, }, @@ -17424,6 +17432,13 @@ func schema_custom_resources_apis_appcatalog_v1alpha1_ClientConfig(ref common.Re Format: "byte", }, }, + "serverName": { + SchemaProps: spec.SchemaProps{ + Description: "ServerName is used to verify the hostname on the returned certificates unless InsecureSkipVerify is given. It is also included in the client's handshake to support virtual hosting unless it is an IP address.", + Type: []string{"string"}, + Format: "", + }, + }, }, }, }, @@ -18505,6 +18520,22 @@ func schema_kmodulesxyz_offshoot_api_api_v1_PodRuntimeSettings(ref common.Refere SchemaProps: spec.SchemaProps{ Type: []string{"object"}, Properties: map[string]spec.Schema{ + "podAnnotations": { + SchemaProps: spec.SchemaProps{ + Description: "PodAnnotations are the annotations that will be attached with the respective Pod", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, "nodeSelector": { SchemaProps: spec.SchemaProps{ Description: "NodeSelector is a selector which must be true for the pod to fit on a node. Selector which must match a node's labels for the pod to be scheduled on that node. More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/", @@ -18528,6 +18559,22 @@ func schema_kmodulesxyz_offshoot_api_api_v1_PodRuntimeSettings(ref common.Refere Format: "", }, }, + "serviceAccountAnnotations": { + SchemaProps: spec.SchemaProps{ + Description: "ServiceAccountAnnotations are the annotations that will be attached with the respective ServiceAccount", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, "automountServiceAccountToken": { SchemaProps: spec.SchemaProps{ Description: "AutomountServiceAccountToken indicates whether a service account token should be automatically mounted.", @@ -19599,10 +19646,18 @@ func schema_apimachinery_apis_stash_v1beta1_BackupBlueprintSpec(ref common.Refer Ref: ref("stash.appscode.dev/apimachinery/apis/stash/v1alpha1.UsagePolicy"), }, }, + "repoNamespace": { + SchemaProps: spec.SchemaProps{ + Description: "RepoNamespace specifies the namespace where the Repository will be created for the respective target", + Type: []string{"string"}, + Format: "", + }, + }, "schedule": { SchemaProps: spec.SchemaProps{ - Type: []string{"string"}, - Format: "", + Description: "Schedule specifies the default schedule for backup. You can overwrite this schedule for a particular target using 'stash.appscode.com/schedule' annotation.", + Type: []string{"string"}, + Format: "", }, }, "task": { @@ -20345,11 +20400,25 @@ func schema_apimachinery_apis_stash_v1beta1_BackupTargetStatus(ref common.Refere }, }, }, + "conditions": { + SchemaProps: spec.SchemaProps{ + Description: "Conditions shows condition of different operations/steps of the backup process for this target", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("kmodules.xyz/client-go/api/v1.Condition"), + }, + }, + }, + }, + }, }, }, }, Dependencies: []string{ - "stash.appscode.dev/apimachinery/apis/stash/v1beta1.HostBackupStats", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.TargetRef"}, + "kmodules.xyz/client-go/api/v1.Condition", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.HostBackupStats", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.TargetRef"}, } } @@ -21665,6 +21734,56 @@ func schema_apimachinery_apis_stash_v1beta1_SnapshotStats(ref common.ReferenceCa } } +func schema_apimachinery_apis_stash_v1beta1_Summary(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Summary summarizes backup/restore session information for a target", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name of the respective BackupSession/RestoreSession/RestoreBatch", + Type: []string{"string"}, + Format: "", + }, + }, + "namespace": { + SchemaProps: spec.SchemaProps{ + Description: "Namespace of the respective invoker", + Type: []string{"string"}, + Format: "", + }, + }, + "invoker": { + SchemaProps: spec.SchemaProps{ + Description: "Invoker specifies the information about the invoker which resulted this session", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.TypedLocalObjectReference"), + }, + }, + "target": { + SchemaProps: spec.SchemaProps{ + Description: "Target specifies the target information that has been backed up /restored in this session", + Default: map[string]interface{}{}, + Ref: ref("stash.appscode.dev/apimachinery/apis/stash/v1beta1.TargetRef"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Description: "Status specifies the backup/restore status for the respective target", + Default: map[string]interface{}{}, + Ref: ref("stash.appscode.dev/apimachinery/apis/stash/v1beta1.TargetStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.TypedLocalObjectReference", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.TargetRef", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.TargetStatus"}, + } +} + func schema_apimachinery_apis_stash_v1beta1_TargetRef(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -21695,6 +21814,39 @@ func schema_apimachinery_apis_stash_v1beta1_TargetRef(ref common.ReferenceCallba } } +func schema_apimachinery_apis_stash_v1beta1_TargetStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "phase": { + SchemaProps: spec.SchemaProps{ + Description: "Phase represent the backup/restore phase of the target", + Type: []string{"string"}, + Format: "", + }, + }, + "duration": { + SchemaProps: spec.SchemaProps{ + Description: "Duration represent the amount of time it took to complete the backup for this target.", + Type: []string{"string"}, + Format: "", + }, + }, + "error": { + SchemaProps: spec.SchemaProps{ + Description: "Error specifies the respective error message in case of backup/restore failure", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + func schema_apimachinery_apis_stash_v1beta1_Task(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ diff --git a/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/restore_batch_types.go b/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/restore_batch_types.go index b359a3d37..2a8c75faf 100644 --- a/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/restore_batch_types.go +++ b/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/restore_batch_types.go @@ -119,3 +119,25 @@ type RestoreBatchList struct { metav1.ListMeta `json:"metadata,omitempty"` Items []RestoreBatch `json:"items,omitempty"` } + +// =============================== Condition Types ===================================== +const ( + // GlobalPreRestoreHookSucceeded indicates whether the global PreRestoreHook was executed successfully or not + GlobalPreRestoreHookSucceeded = "GlobalPreRestoreHookSucceeded" + + // GlobalPostRestoreHookSucceeded indicates whether the global PostRestoreHook was executed successfully or not + GlobalPostRestoreHookSucceeded = "GlobalPostRestoreHookSucceeded" +) + +// ============================== Condition Reasons =================================== +const ( + // GlobalPreRestoreHookExecutedSuccessfully indicates that the condition transitioned to this state because the global PreRestoreHook was executed successfully + GlobalPreRestoreHookExecutedSuccessfully = "GlobalPreRestoreHookExecutedSuccessfully" + // GlobalPreRestoreHookExecutionFailed indicates that the condition transitioned to this state because the Stash was unable to execute global PreRestoreHook + GlobalPreRestoreHookExecutionFailed = "GlobalPreRestoreHookExecutionFailed" + + // GlobalPostRestoreHookExecutedSuccessfully indicates that the condition transitioned to this state because the global PostRestoreHook was executed successfully + GlobalPostRestoreHookExecutedSuccessfully = "GlobalPostRestoreHookExecutedSuccessfully" + // GlobalPostRestoreHookExecutionFailed indicates that the condition transitioned to this state because the Stash was unable to execute global PostRestoreHook + GlobalPostRestoreHookExecutionFailed = "GlobalPostRestoreHookExecutionFailed" +) diff --git a/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/restore_session_types.go b/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/restore_session_types.go index 9d61962da..3a770dafd 100644 --- a/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/restore_session_types.go +++ b/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/restore_session_types.go @@ -164,3 +164,65 @@ type HostRestoreStats struct { // +optional Error string `json:"error,omitempty"` } + +// ========================= Condition Types =================== +const ( + // RestoreTargetFound indicates whether the restore target was found + RestoreTargetFound = "RestoreTargetFound" + + // StashInitContainerInjected indicates whether stash init-container was injected into the targeted workload + // This condition is applicable only for sidecar model + StashInitContainerInjected = "StashInitContainerInjected" + + // RestoreJobCreated indicates whether the restore job was created + RestoreJobCreated = "RestoreJobCreated" + + // RestoreCompleted condition indicates whether the restore process has been completed or not. + // This condition is particularly helpful when the restore addon require some additional operations to perform + // before marking the RestoreSession Succeeded/Failed. + RestoreCompleted = "RestoreCompleted" + + // RestoreExecutorEnsured condition indicates whether the restore job / init-container was ensured or not. + RestoreExecutorEnsured = "RestoreExecutorEnsured" + + // MetricsPushed whether the metrics for this backup session were pushed or not + MetricsPushed = "MetricsPushed" + + // PreRestoreHookExecutionSucceeded indicates whether the preRestore hook was executed successfully or not + PreRestoreHookExecutionSucceeded = "PreRestoreHookExecutionSucceeded" + + // PostRestoreHookExecutionSucceeded indicates whether the postRestore hook was executed successfully or not + PostRestoreHookExecutionSucceeded = "PostRestoreHookExecutionSucceeded" +) + +// ======================== Condition Reasons =================== +const ( + // InitContainerInjectionSucceeded indicates that the condition transitioned to this state because stash init-container + // was injected successfully into the targeted workload + InitContainerInjectionSucceeded = "InitContainerInjectionSucceeded" + // InitContainerInjectionFailed indicates that the condition transitioned to this state because operator was unable + // to inject stash init-container into the targeted workload + InitContainerInjectionFailed = "InitContainerInjectionFailed" + + // RestoreJobCreationSucceeded indicates that the condition transitioned to this state because restore job was created successfully + RestoreJobCreationSucceeded = "RestoreJobCreationSucceeded" + // RestoreJobCreationFailed indicates that the condition transitioned to this state because operator was unable to create restore job + RestoreJobCreationFailed = "RestoreJobCreationFailed" + + // SuccessfullyPushedMetrics indicates that the condition transitioned to this state because the metrics was successfully pushed to the pushgateway + SuccessfullyPushedMetrics = "SuccessfullyPushedMetrics" + // FailedToPushMetrics indicates that the condition transitioned to this state because the Stash was unable to push the metrics to the pushgateway + FailedToPushMetrics = "FailedToPushMetrics" + + SuccessfullyEnsuredRestoreExecutor = "SuccessfullyEnsuredRestoreExecutor" + FailedToEnsureRestoreExecutor = "FailedToEnsureRestoreExecutor" + + SuccessfullyExecutedPreRestoreHook = "SuccessfullyExecutedPreRestoreHook" + FailedToExecutePreRestoreHook = "FailedToExecutePreRestoreHook" + + SuccessfullyExecutedPostRestoreHook = "SuccessfullyExecutedPostRestoreHook" + FailedToExecutePostRestoreHook = "FailedToExecutePostRestoreHook" + + PostRestoreTasksExecuted = "PostRestoreTasksExecuted" + PostRestoreTasksNotExecuted = "PostRestoreTasksNotExecuted" +) diff --git a/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/summary_types.go b/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/summary_types.go new file mode 100644 index 000000000..95e1118cc --- /dev/null +++ b/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/summary_types.go @@ -0,0 +1,45 @@ +/* +Copyright AppsCode Inc. and Contributors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import ( + core "k8s.io/api/core/v1" +) + +// Summary summarizes backup/restore session information for a target +type Summary struct { + // Name of the respective BackupSession/RestoreSession/RestoreBatch + Name string `json:"name,omitempty"` + // Namespace of the respective invoker + Namespace string `json:"namespace,omitempty"` + + // Invoker specifies the information about the invoker which resulted this session + Invoker core.TypedLocalObjectReference `json:"invoker,omitempty"` + // Target specifies the target information that has been backed up /restored in this session + Target TargetRef `json:"target,omitempty"` + // Status specifies the backup/restore status for the respective target + Status TargetStatus `json:"status,omitempty"` +} + +type TargetStatus struct { + // Phase represent the backup/restore phase of the target + Phase string `json:"phase,omitempty"` + // Duration represent the amount of time it took to complete the backup for this target. + Duration string `json:"duration,omitempty"` + // Error specifies the respective error message in case of backup/restore failure + Error string `json:"error,omitempty"` +} diff --git a/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/types.go b/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/types.go index 4629897d3..9cd857280 100644 --- a/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/types.go +++ b/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/types.go @@ -62,7 +62,7 @@ type BackupTarget struct { // Specify the volumes that contains the target directories // +optional VolumeMounts []core.VolumeMount `json:"volumeMounts,omitempty"` - //replicas are the desired number of replicas whose data should be backed up. + // replicas are the desired number of replicas whose data should be backed up. // If unspecified, defaults to 1. // +optional Replicas *int32 `json:"replicas,omitempty"` diff --git a/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/zz_generated.deepcopy.go b/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/zz_generated.deepcopy.go index 93d8fde67..400f1d30b 100644 --- a/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/zz_generated.deepcopy.go +++ b/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/zz_generated.deepcopy.go @@ -609,6 +609,13 @@ func (in *BackupTargetStatus) DeepCopyInto(out *BackupTargetStatus) { *out = make([]string, len(*in)) copy(*out, *in) } + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } return } @@ -1326,6 +1333,25 @@ func (in *SnapshotStats) DeepCopy() *SnapshotStats { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Summary) DeepCopyInto(out *Summary) { + *out = *in + in.Invoker.DeepCopyInto(&out.Invoker) + out.Target = in.Target + out.Status = in.Status + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Summary. +func (in *Summary) DeepCopy() *Summary { + if in == nil { + return nil + } + out := new(Summary) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TargetRef) DeepCopyInto(out *TargetRef) { *out = *in @@ -1342,6 +1368,22 @@ func (in *TargetRef) DeepCopy() *TargetRef { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TargetStatus) DeepCopyInto(out *TargetStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TargetStatus. +func (in *TargetStatus) DeepCopy() *TargetStatus { + if in == nil { + return nil + } + out := new(TargetStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Task) DeepCopyInto(out *Task) { *out = *in diff --git a/vendor/stash.appscode.dev/apimachinery/apis/ui/v1alpha1/openapi_generated.go b/vendor/stash.appscode.dev/apimachinery/apis/ui/v1alpha1/openapi_generated.go index a6bf8d2f0..cb943a047 100644 --- a/vendor/stash.appscode.dev/apimachinery/apis/ui/v1alpha1/openapi_generated.go +++ b/vendor/stash.appscode.dev/apimachinery/apis/ui/v1alpha1/openapi_generated.go @@ -17298,6 +17298,12 @@ func schema_custom_resources_apis_appcatalog_v1alpha1_AppBindingSpec(ref common. Ref: ref("k8s.io/apimachinery/pkg/runtime.RawExtension"), }, }, + "tlsSecret": { + SchemaProps: spec.SchemaProps{ + Description: "TLSSecret is the name of the secret that will hold the client certificate and private key associated with the AppBinding.", + Ref: ref("k8s.io/api/core/v1.LocalObjectReference"), + }, + }, }, Required: []string{"clientConfig"}, }, @@ -17378,6 +17384,13 @@ func schema_custom_resources_apis_appcatalog_v1alpha1_ClientConfig(ref common.Re Format: "byte", }, }, + "serverName": { + SchemaProps: spec.SchemaProps{ + Description: "ServerName is used to verify the hostname on the returned certificates unless InsecureSkipVerify is given. It is also included in the client's handshake to support virtual hosting unless it is an IP address.", + Type: []string{"string"}, + Format: "", + }, + }, }, }, }, @@ -18459,6 +18472,22 @@ func schema_kmodulesxyz_offshoot_api_api_v1_PodRuntimeSettings(ref common.Refere SchemaProps: spec.SchemaProps{ Type: []string{"object"}, Properties: map[string]spec.Schema{ + "podAnnotations": { + SchemaProps: spec.SchemaProps{ + Description: "PodAnnotations are the annotations that will be attached with the respective Pod", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, "nodeSelector": { SchemaProps: spec.SchemaProps{ Description: "NodeSelector is a selector which must be true for the pod to fit on a node. Selector which must match a node's labels for the pod to be scheduled on that node. More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/", @@ -18482,6 +18511,22 @@ func schema_kmodulesxyz_offshoot_api_api_v1_PodRuntimeSettings(ref common.Refere Format: "", }, }, + "serviceAccountAnnotations": { + SchemaProps: spec.SchemaProps{ + Description: "ServiceAccountAnnotations are the annotations that will be attached with the respective ServiceAccount", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, "automountServiceAccountToken": { SchemaProps: spec.SchemaProps{ Description: "AutomountServiceAccountToken indicates whether a service account token should be automatically mounted.", diff --git a/vendor/stash.appscode.dev/apimachinery/apis/util.go b/vendor/stash.appscode.dev/apimachinery/apis/util.go deleted file mode 100644 index d6e26f505..000000000 --- a/vendor/stash.appscode.dev/apimachinery/apis/util.go +++ /dev/null @@ -1,55 +0,0 @@ -/* -Copyright AppsCode Inc. and Contributors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package apis - -const ( - StashKey = "stash.appscode.com" - VersionTag = StashKey + "/tag" - - KeyDeleteJobOnCompletion = StashKey + "/delete-job-on-completion" - AllowDeletingJobOnCompletion = "true" -) - -const ( - KindDeployment = "Deployment" - KindReplicaSet = "ReplicaSet" - KindReplicationController = "ReplicationController" - KindStatefulSet = "StatefulSet" - KindDaemonSet = "DaemonSet" - KindPod = "Pod" - KindPersistentVolumeClaim = "PersistentVolumeClaim" - KindAppBinding = "AppBinding" - KindDeploymentConfig = "DeploymentConfig" - KindSecret = "Secret" - KindService = "Service" - KindJob = "Job" - KindCronJob = "CronJob" -) - -const ( - ResourcePluralDeployment = "deployments" - ResourcePluralReplicaSet = "replicasets" - ResourcePluralReplicationController = "replicationcontrollers" - ResourcePluralStatefulSet = "statefulsets" - ResourcePluralDaemonSet = "daemonsets" - ResourcePluralPod = "pods" - ResourcePluralPersistentVolumeClaim = "persistentvolumeclaims" - ResourcePluralAppBinding = "appbindings" - ResourcePluralDeploymentConfig = "deploymentconfigs" - ResourcePluralSecret = "secrets" - ResourcePluralService = "services" -) diff --git a/vendor/stash.appscode.dev/apimachinery/crds/stash.appscode.com_backupbatches.yaml b/vendor/stash.appscode.dev/apimachinery/crds/stash.appscode.com_backupbatches.yaml index 86d4e974e..4f839d30d 100644 --- a/vendor/stash.appscode.dev/apimachinery/crds/stash.appscode.com_backupbatches.yaml +++ b/vendor/stash.appscode.dev/apimachinery/crds/stash.appscode.com_backupbatches.yaml @@ -2904,6 +2904,12 @@ spec: must match a node''s labels for the pod to be scheduled on that node. More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/' type: object + podAnnotations: + additionalProperties: + type: string + description: PodAnnotations are the annotations that + will be attached with the respective Pod + type: object priority: description: The priority value. Various system components use this field to find the priority of the pod. When @@ -3118,6 +3124,12 @@ spec: type: string type: object type: object + serviceAccountAnnotations: + additionalProperties: + type: string + description: ServiceAccountAnnotations are the annotations + that will be attached with the respective ServiceAccount + type: object serviceAccountName: description: 'ServiceAccountName is the name of the ServiceAccount to use to run this pod. More info: @@ -5137,6 +5149,12 @@ spec: a node''s labels for the pod to be scheduled on that node. More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/' type: object + podAnnotations: + additionalProperties: + type: string + description: PodAnnotations are the annotations that will + be attached with the respective Pod + type: object priority: description: The priority value. Various system components use this field to find the priority of the pod. When Priority @@ -5344,6 +5362,12 @@ spec: type: string type: object type: object + serviceAccountAnnotations: + additionalProperties: + type: string + description: ServiceAccountAnnotations are the annotations + that will be attached with the respective ServiceAccount + type: object serviceAccountName: description: 'ServiceAccountName is the name of the ServiceAccount to use to run this pod. More info: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/' diff --git a/vendor/stash.appscode.dev/apimachinery/crds/stash.appscode.com_backupblueprints.yaml b/vendor/stash.appscode.dev/apimachinery/crds/stash.appscode.com_backupblueprints.yaml index e7b984f7c..a8cff2c39 100644 --- a/vendor/stash.appscode.dev/apimachinery/crds/stash.appscode.com_backupblueprints.yaml +++ b/vendor/stash.appscode.dev/apimachinery/crds/stash.appscode.com_backupblueprints.yaml @@ -1881,6 +1881,10 @@ spec: type: string type: object type: object + repoNamespace: + description: RepoNamespace specifies the namespace where the Repository + will be created for the respective target + type: string retentionPolicy: description: RetentionPolicy indicates the policy to follow to clean old backup snapshots @@ -3689,6 +3693,12 @@ spec: a node''s labels for the pod to be scheduled on that node. More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/' type: object + podAnnotations: + additionalProperties: + type: string + description: PodAnnotations are the annotations that will + be attached with the respective Pod + type: object priority: description: The priority value. Various system components use this field to find the priority of the pod. When Priority @@ -3896,6 +3906,12 @@ spec: type: string type: object type: object + serviceAccountAnnotations: + additionalProperties: + type: string + description: ServiceAccountAnnotations are the annotations + that will be attached with the respective ServiceAccount + type: object serviceAccountName: description: 'ServiceAccountName is the name of the ServiceAccount to use to run this pod. More info: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/' @@ -3945,6 +3961,9 @@ spec: type: object type: object schedule: + description: Schedule specifies the default schedule for backup. You + can overwrite this schedule for a particular target using 'stash.appscode.com/schedule' + annotation. type: string task: description: Task specify the Task crd that specifies steps for backup diff --git a/vendor/stash.appscode.dev/apimachinery/crds/stash.appscode.com_backupconfigurations.yaml b/vendor/stash.appscode.dev/apimachinery/crds/stash.appscode.com_backupconfigurations.yaml index 838c52083..d59da36de 100644 --- a/vendor/stash.appscode.dev/apimachinery/crds/stash.appscode.com_backupconfigurations.yaml +++ b/vendor/stash.appscode.dev/apimachinery/crds/stash.appscode.com_backupconfigurations.yaml @@ -2503,6 +2503,12 @@ spec: a node''s labels for the pod to be scheduled on that node. More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/' type: object + podAnnotations: + additionalProperties: + type: string + description: PodAnnotations are the annotations that will + be attached with the respective Pod + type: object priority: description: The priority value. Various system components use this field to find the priority of the pod. When Priority @@ -2710,6 +2716,12 @@ spec: type: string type: object type: object + serviceAccountAnnotations: + additionalProperties: + type: string + description: ServiceAccountAnnotations are the annotations + that will be attached with the respective ServiceAccount + type: object serviceAccountName: description: 'ServiceAccountName is the name of the ServiceAccount to use to run this pod. More info: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/' diff --git a/vendor/stash.appscode.dev/apimachinery/crds/stash.appscode.com_backupsessions.yaml b/vendor/stash.appscode.dev/apimachinery/crds/stash.appscode.com_backupsessions.yaml index ecaf84feb..1491612b1 100644 --- a/vendor/stash.appscode.dev/apimachinery/crds/stash.appscode.com_backupsessions.yaml +++ b/vendor/stash.appscode.dev/apimachinery/crds/stash.appscode.com_backupsessions.yaml @@ -141,6 +141,55 @@ spec: description: Targets specify the backup status of individual targets items: properties: + conditions: + description: Conditions shows condition of different operations/steps + of the backup process for this target + items: + properties: + lastTransitionTime: + description: Last time the condition transitioned from + one status to another. This should be when the underlying + condition changed. If that is not known, then using + the time when the API field changed is acceptable. + format: date-time + type: string + message: + description: A human readable message indicating details + about the transition. This field may be empty. + type: string + observedGeneration: + description: If set, this represents the .metadata.generation + that the condition was set based upon. For instance, + if .metadata.generation is currently 12, but the .status.condition[x].observedGeneration + is 9, the condition is out of date with respect to the + current state of the instance. + format: int64 + type: integer + reason: + description: The reason for the condition's last transition + in CamelCase. The specific API may choose whether or + not this field is considered a guaranteed API. This + field may not be empty. + type: string + status: + description: Status of the condition, one of True, False, + Unknown. + type: string + type: + description: Type of condition in CamelCase or in foo.example.com/CamelCase. + Many .condition.type values are consistent across resources + like Available, but because arbitrary conditions can + be useful (see .node.status.conditions), the ability + to deconflict is important. + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array phase: description: Phase indicates backup phase of this target enum: diff --git a/vendor/stash.appscode.dev/apimachinery/crds/stash.appscode.com_restorebatches.yaml b/vendor/stash.appscode.dev/apimachinery/crds/stash.appscode.com_restorebatches.yaml index eb15da3a0..b3c164895 100644 --- a/vendor/stash.appscode.dev/apimachinery/crds/stash.appscode.com_restorebatches.yaml +++ b/vendor/stash.appscode.dev/apimachinery/crds/stash.appscode.com_restorebatches.yaml @@ -2895,6 +2895,12 @@ spec: must match a node''s labels for the pod to be scheduled on that node. More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/' type: object + podAnnotations: + additionalProperties: + type: string + description: PodAnnotations are the annotations that + will be attached with the respective Pod + type: object priority: description: The priority value. Various system components use this field to find the priority of the pod. When @@ -3109,6 +3115,12 @@ spec: type: string type: object type: object + serviceAccountAnnotations: + additionalProperties: + type: string + description: ServiceAccountAnnotations are the annotations + that will be attached with the respective ServiceAccount + type: object serviceAccountName: description: 'ServiceAccountName is the name of the ServiceAccount to use to run this pod. More info: diff --git a/vendor/stash.appscode.dev/apimachinery/crds/stash.appscode.com_restoresessions.yaml b/vendor/stash.appscode.dev/apimachinery/crds/stash.appscode.com_restoresessions.yaml index 94c665925..642d6918e 100644 --- a/vendor/stash.appscode.dev/apimachinery/crds/stash.appscode.com_restoresessions.yaml +++ b/vendor/stash.appscode.dev/apimachinery/crds/stash.appscode.com_restoresessions.yaml @@ -2501,6 +2501,12 @@ spec: a node''s labels for the pod to be scheduled on that node. More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/' type: object + podAnnotations: + additionalProperties: + type: string + description: PodAnnotations are the annotations that will + be attached with the respective Pod + type: object priority: description: The priority value. Various system components use this field to find the priority of the pod. When Priority @@ -2708,6 +2714,12 @@ spec: type: string type: object type: object + serviceAccountAnnotations: + additionalProperties: + type: string + description: ServiceAccountAnnotations are the annotations + that will be attached with the respective ServiceAccount + type: object serviceAccountName: description: 'ServiceAccountName is the name of the ServiceAccount to use to run this pod. More info: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/' diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/conditions/backup.go b/vendor/stash.appscode.dev/apimachinery/pkg/conditions/backup_invoker.go similarity index 64% rename from vendor/stash.appscode.dev/apimachinery/pkg/conditions/backup.go rename to vendor/stash.appscode.dev/apimachinery/pkg/conditions/backup_invoker.go index 921e32fa1..04b945c6d 100644 --- a/vendor/stash.appscode.dev/apimachinery/pkg/conditions/backup.go +++ b/vendor/stash.appscode.dev/apimachinery/pkg/conditions/backup_invoker.go @@ -20,96 +20,103 @@ import ( "fmt" "strings" - "stash.appscode.dev/apimachinery/apis" - api_v1beta1 "stash.appscode.dev/apimachinery/apis/stash/v1beta1" + "stash.appscode.dev/apimachinery/apis/stash/v1beta1" "stash.appscode.dev/apimachinery/pkg/invoker" core "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" kmapi "kmodules.xyz/client-go/api/v1" ) -func SetBackupTargetFoundConditionToUnknown(invoker invoker.BackupInvoker, tref api_v1beta1.TargetRef, err error) error { +func SetBackupTargetFoundConditionToUnknown(invoker invoker.BackupInvoker, tref v1beta1.TargetRef, err error) error { return invoker.SetCondition(&tref, kmapi.Condition{ - Type: apis.BackupTargetFound, + Type: v1beta1.BackupTargetFound, Status: core.ConditionUnknown, - Reason: apis.UnableToCheckTargetAvailability, + Reason: v1beta1.UnableToCheckTargetAvailability, Message: fmt.Sprintf("Failed to check whether backup target %s %s/%s exist or not. Reason: %v", tref.APIVersion, strings.ToLower(tref.Kind), tref.Name, err.Error(), ), + LastTransitionTime: metav1.Now(), }) } -func SetBackupTargetFoundConditionToFalse(invoker invoker.BackupInvoker, tref api_v1beta1.TargetRef) error { +func SetBackupTargetFoundConditionToFalse(invoker invoker.BackupInvoker, tref v1beta1.TargetRef) error { return invoker.SetCondition(&tref, kmapi.Condition{ // Set the "BackupTargetFound" condition to "False" - Type: apis.BackupTargetFound, + Type: v1beta1.BackupTargetFound, Status: core.ConditionFalse, - Reason: apis.TargetNotAvailable, + Reason: v1beta1.TargetNotAvailable, Message: fmt.Sprintf("Backup target %s %s/%s does not exist.", tref.APIVersion, strings.ToLower(tref.Kind), tref.Name, ), + LastTransitionTime: metav1.Now(), }) } -func SetBackupTargetFoundConditionToTrue(invoker invoker.BackupInvoker, tref api_v1beta1.TargetRef) error { +func SetBackupTargetFoundConditionToTrue(invoker invoker.BackupInvoker, tref v1beta1.TargetRef) error { return invoker.SetCondition(&tref, kmapi.Condition{ - Type: apis.BackupTargetFound, + Type: v1beta1.BackupTargetFound, Status: core.ConditionTrue, - Reason: apis.TargetAvailable, + Reason: v1beta1.TargetAvailable, Message: fmt.Sprintf("Backup target %s %s/%s found.", tref.APIVersion, strings.ToLower(tref.Kind), tref.Name, ), + LastTransitionTime: metav1.Now(), }) } func SetCronJobCreatedConditionToFalse(invoker invoker.BackupInvoker, err error) error { return invoker.SetCondition(nil, kmapi.Condition{ - Type: apis.CronJobCreated, - Status: core.ConditionFalse, - Reason: apis.CronJobCreationFailed, - Message: fmt.Sprintf("Failed to create backup triggering CronJob. Reason: %v", err.Error()), + Type: v1beta1.CronJobCreated, + Status: core.ConditionFalse, + Reason: v1beta1.CronJobCreationFailed, + Message: fmt.Sprintf("Failed to create backup triggering CronJob. Reason: %v", err.Error()), + LastTransitionTime: metav1.Now(), }) } func SetCronJobCreatedConditionToTrue(invoker invoker.BackupInvoker) error { return invoker.SetCondition(nil, kmapi.Condition{ - Type: apis.CronJobCreated, - Status: core.ConditionTrue, - Reason: apis.CronJobCreationSucceeded, - Message: "Successfully created backup triggering CronJob.", + Type: v1beta1.CronJobCreated, + Status: core.ConditionTrue, + Reason: v1beta1.CronJobCreationSucceeded, + Message: "Successfully created backup triggering CronJob.", + LastTransitionTime: metav1.Now(), }) } -func SetSidecarInjectedConditionToTrue(invoker invoker.BackupInvoker, tref api_v1beta1.TargetRef) error { +func SetSidecarInjectedConditionToTrue(invoker invoker.BackupInvoker, tref v1beta1.TargetRef) error { return invoker.SetCondition(&tref, kmapi.Condition{ - Type: apis.StashSidecarInjected, + Type: v1beta1.StashSidecarInjected, Status: core.ConditionTrue, - Reason: apis.SidecarInjectionSucceeded, + Reason: v1beta1.SidecarInjectionSucceeded, Message: fmt.Sprintf("Successfully injected stash sidecar into %s %s/%s", tref.APIVersion, strings.ToLower(tref.Kind), tref.Name, ), + LastTransitionTime: metav1.Now(), }) } -func SetSidecarInjectedConditionToFalse(invoker invoker.BackupInvoker, tref api_v1beta1.TargetRef, err error) error { +func SetSidecarInjectedConditionToFalse(invoker invoker.BackupInvoker, tref v1beta1.TargetRef, err error) error { return invoker.SetCondition(&tref, kmapi.Condition{ - Type: apis.StashSidecarInjected, + Type: v1beta1.StashSidecarInjected, Status: core.ConditionFalse, - Reason: apis.SidecarInjectionFailed, + Reason: v1beta1.SidecarInjectionFailed, Message: fmt.Sprintf("Failed to inject stash sidecar into %s %s/%s. Reason: %v", tref.APIVersion, strings.ToLower(tref.Kind), tref.Name, err.Error(), ), + LastTransitionTime: metav1.Now(), }) } diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/conditions/backupsession.go b/vendor/stash.appscode.dev/apimachinery/pkg/conditions/backupsession.go new file mode 100644 index 000000000..48a051d5b --- /dev/null +++ b/vendor/stash.appscode.dev/apimachinery/pkg/conditions/backupsession.go @@ -0,0 +1,380 @@ +/* +Copyright AppsCode Inc. and Contributors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package conditions + +import ( + "fmt" + + "stash.appscode.dev/apimachinery/apis/stash/v1beta1" + "stash.appscode.dev/apimachinery/pkg/invoker" + + core "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + kmapi "kmodules.xyz/client-go/api/v1" +) + +func SetBackendRepositoryInitializedConditionToFalse(session *invoker.BackupSessionHandler, err error) error { + return session.UpdateStatus(&v1beta1.BackupSessionStatus{ + Conditions: []kmapi.Condition{ + { + Type: v1beta1.BackendRepositoryInitialized, + Status: core.ConditionFalse, + Reason: v1beta1.FailedToInitializeBackendRepository, + Message: fmt.Sprintf("Failed to initialize backend repository. Reason: %v", err.Error()), + LastTransitionTime: metav1.Now(), + }, + }, + }) +} + +func SetBackendRepositoryInitializedConditionToTrue(session *invoker.BackupSessionHandler) error { + return session.UpdateStatus(&v1beta1.BackupSessionStatus{ + Conditions: []kmapi.Condition{ + { + Type: v1beta1.BackendRepositoryInitialized, + Status: core.ConditionTrue, + Reason: v1beta1.BackendRepositoryFound, + Message: "Repository exist in the backend.", + LastTransitionTime: metav1.Now(), + }, + }, + }) +} + +func SetBackupExecutorEnsuredToFalse(session *invoker.BackupSessionHandler, target v1beta1.TargetRef, err error) error { + return session.UpdateStatus(&v1beta1.BackupSessionStatus{ + Targets: []v1beta1.BackupTargetStatus{ + { + Ref: target, + Conditions: []kmapi.Condition{ + { + Type: v1beta1.BackupExecutorEnsured, + Status: core.ConditionFalse, + Reason: v1beta1.FailedToEnsureBackupExecutor, + Message: fmt.Sprintf("Failed to ensure backup executor. Reason: %v", err.Error()), + LastTransitionTime: metav1.Now(), + }, + }, + }, + }, + }) +} + +func SetBackupExecutorEnsuredToTrue(session *invoker.BackupSessionHandler, target v1beta1.TargetRef) error { + return session.UpdateStatus(&v1beta1.BackupSessionStatus{ + Targets: []v1beta1.BackupTargetStatus{ + { + Ref: target, + Conditions: []kmapi.Condition{ + { + Type: v1beta1.BackupExecutorEnsured, + Status: core.ConditionTrue, + Reason: v1beta1.SuccessfullyEnsuredBackupExecutor, + Message: "Successfully ensured backup executor.", + LastTransitionTime: metav1.Now(), + }, + }, + }, + }, + }) +} + +func SetPreBackupHookExecutionSucceededToFalse(session *invoker.BackupSessionHandler, target v1beta1.TargetRef, err error) error { + return session.UpdateStatus(&v1beta1.BackupSessionStatus{ + Targets: []v1beta1.BackupTargetStatus{ + { + Ref: target, + Conditions: []kmapi.Condition{ + { + Type: v1beta1.PreBackupHookExecutionSucceeded, + Status: core.ConditionFalse, + Reason: v1beta1.FailedToExecutePreBackupHook, + Message: fmt.Sprintf("Failed to execute preBackup hook. Reason: %v", err.Error()), + LastTransitionTime: metav1.Now(), + }, + }, + }, + }, + }) +} + +func SetPreBackupHookExecutionSucceededToTrue(session *invoker.BackupSessionHandler, target v1beta1.TargetRef) error { + return session.UpdateStatus(&v1beta1.BackupSessionStatus{ + Targets: []v1beta1.BackupTargetStatus{ + { + Ref: target, + Conditions: []kmapi.Condition{ + { + Type: v1beta1.PreBackupHookExecutionSucceeded, + Status: core.ConditionTrue, + Reason: v1beta1.SuccessfullyExecutedPreBackupHook, + Message: "Successfully executed preBackup hook.", + LastTransitionTime: metav1.Now(), + }, + }, + }, + }, + }) +} + +func SetPostBackupHookExecutionSucceededToFalse(session *invoker.BackupSessionHandler, target v1beta1.TargetRef, err error) error { + return session.UpdateStatus(&v1beta1.BackupSessionStatus{ + Targets: []v1beta1.BackupTargetStatus{ + { + Ref: target, + Conditions: []kmapi.Condition{ + { + Type: v1beta1.PostBackupHookExecutionSucceeded, + Status: core.ConditionFalse, + Reason: v1beta1.FailedToExecutePostBackupHook, + Message: fmt.Sprintf("Failed to execute postBackup hook. Reason: %v", err.Error()), + LastTransitionTime: metav1.Now(), + }, + }, + }, + }, + }) +} + +func SetPostBackupHookExecutionSucceededToTrue(session *invoker.BackupSessionHandler, target v1beta1.TargetRef) error { + return session.UpdateStatus(&v1beta1.BackupSessionStatus{ + Targets: []v1beta1.BackupTargetStatus{ + { + Ref: target, + Conditions: []kmapi.Condition{ + { + Type: v1beta1.PostBackupHookExecutionSucceeded, + Status: core.ConditionTrue, + Reason: v1beta1.SuccessfullyExecutedPostBackupHook, + Message: "Successfully executed postBackup hook.", + LastTransitionTime: metav1.Now(), + }, + }, + }, + }, + }) +} + +func SetGlobalPreBackupHookSucceededConditionToFalse(session *invoker.BackupSessionHandler, hookErr error) error { + return session.UpdateStatus(&v1beta1.BackupSessionStatus{ + Conditions: []kmapi.Condition{ + { + Type: v1beta1.GlobalPreBackupHookSucceeded, + Status: core.ConditionFalse, + Reason: v1beta1.GlobalPreBackupHookExecutionFailed, + Message: fmt.Sprintf("Failed to execute global PreBackup Hook. Reason: %v.", hookErr), + LastTransitionTime: metav1.Now(), + }, + }, + }) +} + +func SetGlobalPreBackupHookSucceededConditionToTrue(session *invoker.BackupSessionHandler) error { + return session.UpdateStatus(&v1beta1.BackupSessionStatus{ + Conditions: []kmapi.Condition{ + { + Type: v1beta1.GlobalPreBackupHookSucceeded, + Status: core.ConditionTrue, + Reason: v1beta1.GlobalPreBackupHookExecutedSuccessfully, + Message: "Global PreBackup hook has been executed successfully", + LastTransitionTime: metav1.Now(), + }, + }, + }) +} + +func SetGlobalPostBackupHookSucceededConditionToFalse(session *invoker.BackupSessionHandler, hookErr error) error { + return session.UpdateStatus(&v1beta1.BackupSessionStatus{ + Conditions: []kmapi.Condition{ + { + Type: v1beta1.GlobalPostBackupHookSucceeded, + Status: core.ConditionFalse, + Reason: v1beta1.GlobalPostBackupHookExecutionFailed, + Message: fmt.Sprintf("Failed to execute global PostBackup Hook. Reason: %v.", hookErr), + LastTransitionTime: metav1.Now(), + }, + }, + }) +} + +func SetGlobalPostBackupHookSucceededConditionToTrue(session *invoker.BackupSessionHandler) error { + return session.UpdateStatus(&v1beta1.BackupSessionStatus{ + Conditions: []kmapi.Condition{ + { + Type: v1beta1.GlobalPostBackupHookSucceeded, + Status: core.ConditionTrue, + Reason: v1beta1.GlobalPostBackupHookExecutedSuccessfully, + Message: "Global PostBackup hook has been executed successfully", + LastTransitionTime: metav1.Now(), + }, + }, + }) +} + +func SetRetentionPolicyAppliedConditionToFalse(session *invoker.BackupSessionHandler, err error) error { + return session.UpdateStatus(&v1beta1.BackupSessionStatus{ + Conditions: []kmapi.Condition{ + { + Type: v1beta1.RetentionPolicyApplied, + Status: core.ConditionFalse, + Reason: v1beta1.FailedToApplyRetentionPolicy, + Message: fmt.Sprintf("Failed to apply retention policy. Reason: %v", err.Error()), + LastTransitionTime: metav1.Now(), + }, + }, + }) +} + +func SetRetentionPolicyAppliedConditionToTrue(session *invoker.BackupSessionHandler) error { + return session.UpdateStatus(&v1beta1.BackupSessionStatus{ + Conditions: []kmapi.Condition{ + { + Type: v1beta1.RetentionPolicyApplied, + Status: core.ConditionTrue, + Reason: v1beta1.SuccessfullyAppliedRetentionPolicy, + Message: "Successfully applied retention policy.", + LastTransitionTime: metav1.Now(), + }, + }, + }) +} + +func SetRepositoryIntegrityVerifiedConditionToFalse(session *invoker.BackupSessionHandler, err error) error { + return session.UpdateStatus(&v1beta1.BackupSessionStatus{ + Conditions: []kmapi.Condition{ + { + Type: v1beta1.RepositoryIntegrityVerified, + Status: core.ConditionFalse, + Reason: v1beta1.FailedToVerifyRepositoryIntegrity, + Message: fmt.Sprintf("Repository integrity verification failed. Reason: %v", err.Error()), + LastTransitionTime: metav1.Now(), + }, + }, + }) +} + +func SetRepositoryIntegrityVerifiedConditionToTrue(session *invoker.BackupSessionHandler) error { + return session.UpdateStatus(&v1beta1.BackupSessionStatus{ + Conditions: []kmapi.Condition{ + { + Type: v1beta1.RepositoryIntegrityVerified, + Status: core.ConditionTrue, + Reason: v1beta1.SuccessfullyVerifiedRepositoryIntegrity, + Message: "Repository integrity verification succeeded.", + LastTransitionTime: metav1.Now(), + }, + }, + }) +} + +func SetRepositoryMetricsPushedConditionToFalse(session *invoker.BackupSessionHandler, err error) error { + return session.UpdateStatus(&v1beta1.BackupSessionStatus{ + Conditions: []kmapi.Condition{ + { + Type: v1beta1.RepositoryMetricsPushed, + Status: core.ConditionFalse, + Reason: v1beta1.FailedToPushRepositoryMetrics, + Message: fmt.Sprintf("Failed to push repository metrics. Reason: %v", err.Error()), + LastTransitionTime: metav1.Now(), + }, + }, + }) +} + +func SetRepositoryMetricsPushedConditionToTrue(session *invoker.BackupSessionHandler) error { + return session.UpdateStatus(&v1beta1.BackupSessionStatus{ + Conditions: []kmapi.Condition{ + { + Type: v1beta1.RepositoryMetricsPushed, + Status: core.ConditionTrue, + Reason: v1beta1.SuccessfullyPushedRepositoryMetrics, + Message: "Successfully pushed repository metrics.", + LastTransitionTime: metav1.Now(), + }, + }, + }) +} + +func SetBackupSkippedConditionToTrue(session *invoker.BackupSessionHandler, msg string) error { + return session.UpdateStatus(&v1beta1.BackupSessionStatus{ + Conditions: []kmapi.Condition{ + { + Type: v1beta1.BackupSkipped, + Status: core.ConditionTrue, + Reason: v1beta1.SkippedTakingNewBackup, + Message: msg, + LastTransitionTime: metav1.Now(), + }, + }, + }) +} + +func SetBackupMetricsPushedConditionToFalse(session *invoker.BackupSessionHandler, err error) error { + return session.UpdateStatus(&v1beta1.BackupSessionStatus{ + Conditions: []kmapi.Condition{ + { + Type: v1beta1.MetricsPushed, + Status: core.ConditionFalse, + Reason: v1beta1.FailedToPushMetrics, + Message: fmt.Sprintf("Failed to push metrics. Reason: %v", err.Error()), + LastTransitionTime: metav1.Now(), + }, + }, + }) +} + +func SetBackupMetricsPushedConditionToTrue(session *invoker.BackupSessionHandler) error { + return session.UpdateStatus(&v1beta1.BackupSessionStatus{ + Conditions: []kmapi.Condition{ + { + Type: v1beta1.MetricsPushed, + Status: core.ConditionTrue, + Reason: v1beta1.SuccessfullyPushedMetrics, + Message: "Successfully pushed metrics.", + LastTransitionTime: metav1.Now(), + }, + }, + }) +} + +func SetBackupHistoryCleanedConditionToFalse(session *invoker.BackupSessionHandler, err error) error { + return session.UpdateStatus(&v1beta1.BackupSessionStatus{ + Conditions: []kmapi.Condition{ + { + Type: v1beta1.BackupHistoryCleaned, + Status: core.ConditionFalse, + Reason: v1beta1.FailedToCleanBackupHistory, + Message: fmt.Sprintf("Failed to cleanup old BackupSessions. Reason: %v", err.Error()), + LastTransitionTime: metav1.Now(), + }, + }, + }) +} + +func SetBackupHistoryCleanedConditionToTrue(session *invoker.BackupSessionHandler) error { + return session.UpdateStatus(&v1beta1.BackupSessionStatus{ + Conditions: []kmapi.Condition{ + { + Type: v1beta1.BackupHistoryCleaned, + Status: core.ConditionTrue, + Reason: v1beta1.SuccessfullyCleanedBackupHistory, + Message: "Successfully cleaned up backup history according to backupHistoryLimit.", + LastTransitionTime: metav1.Now(), + }, + }, + }) +} diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/conditions/hooks.go b/vendor/stash.appscode.dev/apimachinery/pkg/conditions/hooks.go deleted file mode 100644 index 540a21b51..000000000 --- a/vendor/stash.appscode.dev/apimachinery/pkg/conditions/hooks.go +++ /dev/null @@ -1,145 +0,0 @@ -/* -Copyright AppsCode Inc. and Contributors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package conditions - -import ( - "context" - "fmt" - - "stash.appscode.dev/apimachinery/apis" - api_v1beta1 "stash.appscode.dev/apimachinery/apis/stash/v1beta1" - cs "stash.appscode.dev/apimachinery/client/clientset/versioned" - stash_util "stash.appscode.dev/apimachinery/client/clientset/versioned/typed/stash/v1beta1/util" - "stash.appscode.dev/apimachinery/pkg/invoker" - - core "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/types" - kmapi "kmodules.xyz/client-go/api/v1" -) - -func SetGlobalPreBackupHookSucceededConditionToFalse(stashClient cs.Interface, backupSession *api_v1beta1.BackupSession, hookErr error) (*api_v1beta1.BackupSession, error) { - return stash_util.UpdateBackupSessionStatus( - context.TODO(), - stashClient.StashV1beta1(), - backupSession.ObjectMeta, - func(in *api_v1beta1.BackupSessionStatus) (types.UID, *api_v1beta1.BackupSessionStatus) { - in.Conditions = kmapi.SetCondition(in.Conditions, kmapi.Condition{ - Type: apis.GlobalPreBackupHookSucceeded, - Status: core.ConditionFalse, - Reason: apis.GlobalPreBackupHookExecutionFailed, - Message: fmt.Sprintf("Failed to execute global PreBackup Hook. Reason: %v.", hookErr), - }, - ) - return backupSession.UID, in - }, - metav1.UpdateOptions{}, - ) -} - -func SetGlobalPreBackupHookSucceededConditionToTrue(stashClient cs.Interface, backupSession *api_v1beta1.BackupSession) (*api_v1beta1.BackupSession, error) { - return stash_util.UpdateBackupSessionStatus( - context.TODO(), - stashClient.StashV1beta1(), - backupSession.ObjectMeta, - func(in *api_v1beta1.BackupSessionStatus) (types.UID, *api_v1beta1.BackupSessionStatus) { - in.Conditions = kmapi.SetCondition(in.Conditions, kmapi.Condition{ - Type: apis.GlobalPreBackupHookSucceeded, - Status: core.ConditionTrue, - Reason: apis.GlobalPreBackupHookExecutedSuccessfully, - Message: "Global PreBackup hook has been executed successfully", - }, - ) - return backupSession.UID, in - }, - metav1.UpdateOptions{}, - ) -} - -func SetGlobalPostBackupHookSucceededConditionToFalse(stashClient cs.Interface, backupSession *api_v1beta1.BackupSession, hookErr error) (*api_v1beta1.BackupSession, error) { - return stash_util.UpdateBackupSessionStatus( - context.TODO(), - stashClient.StashV1beta1(), - backupSession.ObjectMeta, - func(in *api_v1beta1.BackupSessionStatus) (types.UID, *api_v1beta1.BackupSessionStatus) { - in.Conditions = kmapi.SetCondition(in.Conditions, kmapi.Condition{ - Type: apis.GlobalPostBackupHookSucceeded, - Status: core.ConditionFalse, - Reason: apis.GlobalPostBackupHookExecutionFailed, - Message: fmt.Sprintf("Failed to execute global PostBackup Hook. Reason: %v.", hookErr), - }, - ) - return backupSession.UID, in - }, - metav1.UpdateOptions{}, - ) -} - -func SetGlobalPostBackupHookSucceededConditionToTrue(stashClient cs.Interface, backupSession *api_v1beta1.BackupSession) (*api_v1beta1.BackupSession, error) { - return stash_util.UpdateBackupSessionStatus( - context.TODO(), - stashClient.StashV1beta1(), - backupSession.ObjectMeta, - func(in *api_v1beta1.BackupSessionStatus) (types.UID, *api_v1beta1.BackupSessionStatus) { - in.Conditions = kmapi.SetCondition(in.Conditions, kmapi.Condition{ - Type: apis.GlobalPostBackupHookSucceeded, - Status: core.ConditionTrue, - Reason: apis.GlobalPostBackupHookExecutedSuccessfully, - Message: "Global PostBackup hook has been executed successfully", - }, - ) - return backupSession.UID, in - }, - metav1.UpdateOptions{}, - ) -} - -func SetGlobalPreRestoreHookSucceededConditionToFalse(invoker invoker.RestoreInvoker, hookErr error) error { - return invoker.SetCondition(nil, kmapi.Condition{ - Type: apis.GlobalPreRestoreHookSucceeded, - Status: core.ConditionFalse, - Reason: apis.GlobalPreRestoreHookExecutionFailed, - Message: fmt.Sprintf("Failed to execute global PreRestore Hook. Reason: %v.", hookErr), - }) -} - -func SetGlobalPreRestoreHookSucceededConditionToTrue(invoker invoker.RestoreInvoker) error { - return invoker.SetCondition(nil, kmapi.Condition{ - Type: apis.GlobalPreRestoreHookSucceeded, - Status: core.ConditionTrue, - Reason: apis.GlobalPreRestoreHookExecutedSuccessfully, - Message: "Global PreRestore hook has been executed successfully", - }) -} - -func SetGlobalPostRestoreHookSucceededConditionToFalse(invoker invoker.RestoreInvoker, hookErr error) error { - return invoker.SetCondition(nil, kmapi.Condition{ - Type: apis.GlobalPostRestoreHookSucceeded, - Status: core.ConditionFalse, - Reason: apis.GlobalPostRestoreHookExecutionFailed, - Message: fmt.Sprintf("Failed to execute global PostRestore Hook. Reason: %v.", hookErr), - }) -} - -func SetGlobalPostRestoreHookSucceededConditionToTrue(invoker invoker.RestoreInvoker) error { - return invoker.SetCondition(nil, kmapi.Condition{ - Type: apis.GlobalPostRestoreHookSucceeded, - Status: core.ConditionTrue, - Reason: apis.GlobalPostRestoreHookExecutedSuccessfully, - Message: "Global PostRestore hook has been executed successfully", - }) -} diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/conditions/repository.go b/vendor/stash.appscode.dev/apimachinery/pkg/conditions/repository.go index c43befc4a..24408f3fd 100644 --- a/vendor/stash.appscode.dev/apimachinery/pkg/conditions/repository.go +++ b/vendor/stash.appscode.dev/apimachinery/pkg/conditions/repository.go @@ -17,85 +17,44 @@ limitations under the License. package conditions import ( - "context" "fmt" - "stash.appscode.dev/apimachinery/apis" "stash.appscode.dev/apimachinery/apis/stash/v1beta1" - api_v1beta1 "stash.appscode.dev/apimachinery/apis/stash/v1beta1" - cs "stash.appscode.dev/apimachinery/client/clientset/versioned" - stash_util "stash.appscode.dev/apimachinery/client/clientset/versioned/typed/stash/v1beta1/util" "stash.appscode.dev/apimachinery/pkg/invoker" core "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/types" kmapi "kmodules.xyz/client-go/api/v1" ) -func SetBackendRepositoryInitializedConditionToFalse(stashClient cs.Interface, backupSession *v1beta1.BackupSession, err error) (*v1beta1.BackupSession, error) { - return stash_util.UpdateBackupSessionStatus( - context.TODO(), - stashClient.StashV1beta1(), - backupSession.ObjectMeta, - func(in *api_v1beta1.BackupSessionStatus) (types.UID, *api_v1beta1.BackupSessionStatus) { - in.Conditions = kmapi.SetCondition(in.Conditions, kmapi.Condition{ - Type: apis.BackendRepositoryInitialized, - Status: core.ConditionFalse, - Reason: apis.FailedToInitializeBackendRepository, - Message: fmt.Sprintf("Failed to initialize backend repository. Reason: %v", err.Error()), - }, - ) - return backupSession.UID, in - }, - metav1.UpdateOptions{}, - ) -} - -func SetBackendRepositoryInitializedConditionToTrue(stashClient cs.Interface, backupSession *v1beta1.BackupSession) (*v1beta1.BackupSession, error) { - return stash_util.UpdateBackupSessionStatus( - context.TODO(), - stashClient.StashV1beta1(), - backupSession.ObjectMeta, - func(in *api_v1beta1.BackupSessionStatus) (types.UID, *api_v1beta1.BackupSessionStatus) { - in.Conditions = kmapi.SetCondition(in.Conditions, kmapi.Condition{ - Type: apis.BackendRepositoryInitialized, - Status: core.ConditionTrue, - Reason: apis.BackendRepositoryFound, - Message: "Repository exist in the backend.", - }) - return backupSession.UID, in - }, - metav1.UpdateOptions{}, - ) -} - func SetRepositoryFoundConditionToUnknown(i interface{}, err error) error { switch in := i.(type) { case invoker.BackupInvoker: return in.SetCondition(nil, kmapi.Condition{ - Type: apis.RepositoryFound, + Type: v1beta1.RepositoryFound, Status: core.ConditionUnknown, - Reason: apis.UnableToCheckRepositoryAvailability, + Reason: v1beta1.UnableToCheckRepositoryAvailability, Message: fmt.Sprintf("Failed to check whether the Repository %s/%s exist or not. Reason: %v", in.GetRepoRef().Namespace, in.GetRepoRef().Name, err.Error(), ), + LastTransitionTime: metav1.Now(), }) case invoker.RestoreInvoker: return in.SetCondition(nil, kmapi.Condition{ - Type: apis.RepositoryFound, + Type: v1beta1.RepositoryFound, Status: core.ConditionUnknown, - Reason: apis.UnableToCheckRepositoryAvailability, + Reason: v1beta1.UnableToCheckRepositoryAvailability, Message: fmt.Sprintf("Failed to check whether the Repository %s/%s exist or not. Reason: %v", in.GetRepoRef().Namespace, in.GetRepoRef().Name, err.Error(), ), + LastTransitionTime: metav1.Now(), }) default: - return fmt.Errorf("unable to set %s condition. Reason: invoker type unknown", apis.RepositoryFound) + return fmt.Errorf("unable to set %s condition. Reason: invoker type unknown", v1beta1.RepositoryFound) } } @@ -103,26 +62,28 @@ func SetRepositoryFoundConditionToFalse(i interface{}) error { switch in := i.(type) { case invoker.BackupInvoker: return in.SetCondition(nil, kmapi.Condition{ - Type: apis.RepositoryFound, + Type: v1beta1.RepositoryFound, Status: core.ConditionFalse, - Reason: apis.RepositoryNotAvailable, + Reason: v1beta1.RepositoryNotAvailable, Message: fmt.Sprintf("Repository %s/%s does not exist.", in.GetRepoRef().Namespace, in.GetRepoRef().Name, ), + LastTransitionTime: metav1.Now(), }) case invoker.RestoreInvoker: return in.SetCondition(nil, kmapi.Condition{ - Type: apis.RepositoryFound, + Type: v1beta1.RepositoryFound, Status: core.ConditionFalse, - Reason: apis.RepositoryNotAvailable, + Reason: v1beta1.RepositoryNotAvailable, Message: fmt.Sprintf("Repository %s/%s does not exist.", in.GetRepoRef().Namespace, in.GetRepoRef().Name, ), + LastTransitionTime: metav1.Now(), }) default: - return fmt.Errorf("unable to set %s condition. Reason: invoker type unknown", apis.RepositoryFound) + return fmt.Errorf("unable to set %s condition. Reason: invoker type unknown", v1beta1.RepositoryFound) } } @@ -130,26 +91,28 @@ func SetRepositoryFoundConditionToTrue(i interface{}) error { switch in := i.(type) { case invoker.BackupInvoker: return in.SetCondition(nil, kmapi.Condition{ - Type: apis.RepositoryFound, + Type: v1beta1.RepositoryFound, Status: core.ConditionTrue, - Reason: apis.RepositoryAvailable, + Reason: v1beta1.RepositoryAvailable, Message: fmt.Sprintf("Repository %s/%s exist.", in.GetRepoRef().Namespace, in.GetRepoRef().Name, ), + LastTransitionTime: metav1.Now(), }) case invoker.RestoreInvoker: return in.SetCondition(nil, kmapi.Condition{ - Type: apis.RepositoryFound, + Type: v1beta1.RepositoryFound, Status: core.ConditionTrue, - Reason: apis.RepositoryAvailable, + Reason: v1beta1.RepositoryAvailable, Message: fmt.Sprintf("Repository %s/%s exist.", in.GetRepoRef().Namespace, in.GetRepoRef().Name, ), + LastTransitionTime: metav1.Now(), }) default: - return fmt.Errorf("unable to set %s condition. Reason: invoker type unknown", apis.RepositoryFound) + return fmt.Errorf("unable to set %s condition. Reason: invoker type unknown", v1beta1.RepositoryFound) } } @@ -157,20 +120,22 @@ func SetValidationPassedToTrue(i interface{}) error { switch in := i.(type) { case invoker.BackupInvoker: return in.SetCondition(nil, kmapi.Condition{ - Type: apis.ValidationPassed, - Status: core.ConditionTrue, - Reason: apis.ResourceValidationPassed, - Message: "Successfully validated.", + Type: v1beta1.ValidationPassed, + Status: core.ConditionTrue, + Reason: v1beta1.ResourceValidationPassed, + Message: "Successfully validated.", + LastTransitionTime: metav1.Now(), }) case invoker.RestoreInvoker: return in.SetCondition(nil, kmapi.Condition{ - Type: apis.ValidationPassed, - Status: core.ConditionTrue, - Reason: apis.ResourceValidationPassed, - Message: "Successfully validated.", + Type: v1beta1.ValidationPassed, + Status: core.ConditionTrue, + Reason: v1beta1.ResourceValidationPassed, + Message: "Successfully validated.", + LastTransitionTime: metav1.Now(), }) default: - return fmt.Errorf("unable to set %s condition. Reason: invoker type unknown", apis.ValidationPassed) + return fmt.Errorf("unable to set %s condition. Reason: invoker type unknown", v1beta1.ValidationPassed) } } @@ -178,20 +143,22 @@ func SetValidationPassedToFalse(i interface{}, err error) error { switch in := i.(type) { case invoker.BackupInvoker: return in.SetCondition(nil, kmapi.Condition{ - Type: apis.ValidationPassed, - Status: core.ConditionFalse, - Reason: apis.ResourceValidationFailed, - Message: err.Error(), + Type: v1beta1.ValidationPassed, + Status: core.ConditionFalse, + Reason: v1beta1.ResourceValidationFailed, + Message: err.Error(), + LastTransitionTime: metav1.Now(), }) case invoker.RestoreInvoker: return in.SetCondition(nil, kmapi.Condition{ - Type: apis.ValidationPassed, - Status: core.ConditionFalse, - Reason: apis.ResourceValidationFailed, - Message: err.Error(), + Type: v1beta1.ValidationPassed, + Status: core.ConditionFalse, + Reason: v1beta1.ResourceValidationFailed, + Message: err.Error(), + LastTransitionTime: metav1.Now(), }) default: - return fmt.Errorf("unable to set %s condition. Reason: invoker type unknown", apis.ValidationPassed) + return fmt.Errorf("unable to set %s condition. Reason: invoker type unknown", v1beta1.ValidationPassed) } } @@ -199,28 +166,30 @@ func SetBackendSecretFoundConditionToUnknown(i interface{}, secretName string, e switch in := i.(type) { case invoker.BackupInvoker: return in.SetCondition(nil, kmapi.Condition{ - Type: apis.BackendSecretFound, + Type: v1beta1.BackendSecretFound, Status: core.ConditionUnknown, - Reason: apis.UnableToCheckBackendSecretAvailability, + Reason: v1beta1.UnableToCheckBackendSecretAvailability, Message: fmt.Sprintf("Failed to check whether the backend Secret %s/%s exist or not. Reason: %v", in.GetRepoRef().Namespace, secretName, err.Error(), ), + LastTransitionTime: metav1.Now(), }) case invoker.RestoreInvoker: return in.SetCondition(nil, kmapi.Condition{ - Type: apis.BackendSecretFound, + Type: v1beta1.BackendSecretFound, Status: core.ConditionUnknown, - Reason: apis.UnableToCheckBackendSecretAvailability, + Reason: v1beta1.UnableToCheckBackendSecretAvailability, Message: fmt.Sprintf("Failed to check whether the backend Secret %s/%s exist or not. Reason: %v", in.GetRepoRef().Namespace, secretName, err.Error(), ), + LastTransitionTime: metav1.Now(), }) default: - return fmt.Errorf("unable to set %s condition. Reason: invoker type unknown", apis.BackendSecretFound) + return fmt.Errorf("unable to set %s condition. Reason: invoker type unknown", v1beta1.BackendSecretFound) } } @@ -228,26 +197,28 @@ func SetBackendSecretFoundConditionToFalse(i interface{}, secretName string) err switch in := i.(type) { case invoker.BackupInvoker: return in.SetCondition(nil, kmapi.Condition{ - Type: apis.BackendSecretFound, + Type: v1beta1.BackendSecretFound, Status: core.ConditionFalse, - Reason: apis.BackendSecretNotAvailable, + Reason: v1beta1.BackendSecretNotAvailable, Message: fmt.Sprintf("Backend Secret %s/%s does not exist.", in.GetRepoRef().Namespace, secretName, ), + LastTransitionTime: metav1.Now(), }) case invoker.RestoreInvoker: return in.SetCondition(nil, kmapi.Condition{ - Type: apis.BackendSecretFound, + Type: v1beta1.BackendSecretFound, Status: core.ConditionFalse, - Reason: apis.BackendSecretNotAvailable, + Reason: v1beta1.BackendSecretNotAvailable, Message: fmt.Sprintf("Backend Secret %s/%s does not exist.", in.GetRepoRef().Namespace, secretName, ), + LastTransitionTime: metav1.Now(), }) default: - return fmt.Errorf("unable to set %s condition. Reason: invoker type unknown", apis.BackendSecretFound) + return fmt.Errorf("unable to set %s condition. Reason: invoker type unknown", v1beta1.BackendSecretFound) } } @@ -255,139 +226,27 @@ func SetBackendSecretFoundConditionToTrue(i interface{}, secretName string) erro switch in := i.(type) { case invoker.BackupInvoker: return in.SetCondition(nil, kmapi.Condition{ - Type: apis.BackendSecretFound, + Type: v1beta1.BackendSecretFound, Status: core.ConditionTrue, - Reason: apis.BackendSecretAvailable, + Reason: v1beta1.BackendSecretAvailable, Message: fmt.Sprintf("Backend Secret %s/%s exist.", in.GetRepoRef().Namespace, secretName, ), + LastTransitionTime: metav1.Now(), }) case invoker.RestoreInvoker: return in.SetCondition(nil, kmapi.Condition{ - Type: apis.BackendSecretFound, + Type: v1beta1.BackendSecretFound, Status: core.ConditionTrue, - Reason: apis.BackendSecretAvailable, + Reason: v1beta1.BackendSecretAvailable, Message: fmt.Sprintf("Backend Secret %s/%s exist.", in.GetRepoRef().Namespace, secretName, ), + LastTransitionTime: metav1.Now(), }) default: - return fmt.Errorf("unable to set %s condition. Reason: invoker type unknown", apis.BackendSecretFound) + return fmt.Errorf("unable to set %s condition. Reason: invoker type unknown", v1beta1.BackendSecretFound) } } - -func SetRetentionPolicyAppliedConditionToFalse(stashClient cs.Interface, backupSession *v1beta1.BackupSession, err error) (*v1beta1.BackupSession, error) { - return stash_util.UpdateBackupSessionStatus( - context.TODO(), - stashClient.StashV1beta1(), - backupSession.ObjectMeta, - func(in *api_v1beta1.BackupSessionStatus) (types.UID, *api_v1beta1.BackupSessionStatus) { - in.Conditions = kmapi.SetCondition(in.Conditions, kmapi.Condition{ - Type: apis.RetentionPolicyApplied, - Status: core.ConditionFalse, - Reason: apis.FailedToApplyRetentionPolicy, - Message: fmt.Sprintf("Failed to apply retention policy. Reason: %v", err.Error()), - }, - ) - return backupSession.UID, in - }, - metav1.UpdateOptions{}, - ) -} - -func SetRetentionPolicyAppliedConditionToTrue(stashClient cs.Interface, backupSession *v1beta1.BackupSession) (*v1beta1.BackupSession, error) { - return stash_util.UpdateBackupSessionStatus( - context.TODO(), - stashClient.StashV1beta1(), - backupSession.ObjectMeta, - func(in *api_v1beta1.BackupSessionStatus) (types.UID, *api_v1beta1.BackupSessionStatus) { - in.Conditions = kmapi.SetCondition(in.Conditions, kmapi.Condition{ - Type: apis.RetentionPolicyApplied, - Status: core.ConditionTrue, - Reason: apis.SuccessfullyAppliedRetentionPolicy, - Message: "Successfully applied retention policy.", - }, - ) - return backupSession.UID, in - }, - metav1.UpdateOptions{}, - ) -} - -func SetRepositoryIntegrityVerifiedConditionToFalse(stashClient cs.Interface, backupSession *v1beta1.BackupSession, err error) (*v1beta1.BackupSession, error) { - return stash_util.UpdateBackupSessionStatus( - context.TODO(), - stashClient.StashV1beta1(), - backupSession.ObjectMeta, - func(in *api_v1beta1.BackupSessionStatus) (types.UID, *api_v1beta1.BackupSessionStatus) { - in.Conditions = kmapi.SetCondition(in.Conditions, kmapi.Condition{ - Type: apis.RepositoryIntegrityVerified, - Status: core.ConditionFalse, - Reason: apis.FailedToVerifyRepositoryIntegrity, - Message: fmt.Sprintf("Repository integrity verification failed. Reason: %v", err.Error()), - }, - ) - return backupSession.UID, in - }, - metav1.UpdateOptions{}, - ) -} - -func SetRepositoryIntegrityVerifiedConditionToTrue(stashClient cs.Interface, backupSession *v1beta1.BackupSession) (*v1beta1.BackupSession, error) { - return stash_util.UpdateBackupSessionStatus( - context.TODO(), - stashClient.StashV1beta1(), - backupSession.ObjectMeta, - func(in *api_v1beta1.BackupSessionStatus) (types.UID, *api_v1beta1.BackupSessionStatus) { - in.Conditions = kmapi.SetCondition(in.Conditions, kmapi.Condition{ - Type: apis.RepositoryIntegrityVerified, - Status: core.ConditionTrue, - Reason: apis.SuccessfullyVerifiedRepositoryIntegrity, - Message: "Repository integrity verification succeeded.", - }, - ) - return backupSession.UID, in - }, - metav1.UpdateOptions{}, - ) -} - -func SetRepositoryMetricsPushedConditionToFalse(stashClient cs.Interface, backupSession *v1beta1.BackupSession, err error) (*v1beta1.BackupSession, error) { - return stash_util.UpdateBackupSessionStatus( - context.TODO(), - stashClient.StashV1beta1(), - backupSession.ObjectMeta, - func(in *api_v1beta1.BackupSessionStatus) (types.UID, *api_v1beta1.BackupSessionStatus) { - in.Conditions = kmapi.SetCondition(in.Conditions, kmapi.Condition{ - Type: apis.RepositoryMetricsPushed, - Status: core.ConditionFalse, - Reason: apis.FailedToPushRepositoryMetrics, - Message: fmt.Sprintf("Failed to push repository metrics. Reason: %v", err.Error()), - }, - ) - return backupSession.UID, in - }, - metav1.UpdateOptions{}, - ) -} - -func SetRepositoryMetricsPushedConditionToTrue(stashClient cs.Interface, backupSession *v1beta1.BackupSession) (*v1beta1.BackupSession, error) { - return stash_util.UpdateBackupSessionStatus( - context.TODO(), - stashClient.StashV1beta1(), - backupSession.ObjectMeta, - func(in *api_v1beta1.BackupSessionStatus) (types.UID, *api_v1beta1.BackupSessionStatus) { - in.Conditions = kmapi.SetCondition(in.Conditions, kmapi.Condition{ - Type: apis.RepositoryMetricsPushed, - Status: core.ConditionTrue, - Reason: apis.SuccessfullyPushedRepositoryMetrics, - Message: "Successfully pushed repository metrics.", - }, - ) - return backupSession.UID, in - }, - metav1.UpdateOptions{}, - ) -} diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/conditions/restore.go b/vendor/stash.appscode.dev/apimachinery/pkg/conditions/restore.go deleted file mode 100644 index 25bd777f9..000000000 --- a/vendor/stash.appscode.dev/apimachinery/pkg/conditions/restore.go +++ /dev/null @@ -1,162 +0,0 @@ -/* -Copyright AppsCode Inc. and Contributors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package conditions - -import ( - "fmt" - "strings" - - "stash.appscode.dev/apimachinery/apis" - api_v1beta1 "stash.appscode.dev/apimachinery/apis/stash/v1beta1" - "stash.appscode.dev/apimachinery/pkg/invoker" - - core "k8s.io/api/core/v1" - kmapi "kmodules.xyz/client-go/api/v1" -) - -func SetRestoreTargetFoundConditionToTrue(inv invoker.RestoreInvoker, index int) error { - target := inv.GetTargetInfo()[index].Target - return inv.SetCondition(&target.Ref, kmapi.Condition{ - Type: apis.RestoreTargetFound, - Status: core.ConditionTrue, - Reason: apis.TargetAvailable, - Message: fmt.Sprintf("Restore target %s %s/%s found.", - target.Ref.APIVersion, - strings.ToLower(target.Ref.Kind), - target.Ref.Name, - ), - }) -} - -func SetRestoreTargetFoundConditionToFalse(inv invoker.RestoreInvoker, index int) error { - target := inv.GetTargetInfo()[index].Target - return inv.SetCondition(&target.Ref, kmapi.Condition{ - Type: apis.RestoreTargetFound, - Status: core.ConditionFalse, - Reason: apis.TargetNotAvailable, - Message: fmt.Sprintf("Restore target %s %s/%s does not exist.", - target.Ref.APIVersion, - strings.ToLower(target.Ref.Kind), - target.Ref.Name, - ), - }) -} - -func SetRestoreTargetFoundConditionToUnknown(inv invoker.RestoreInvoker, index int, err error) error { - target := inv.GetTargetInfo()[index].Target - return inv.SetCondition(&target.Ref, kmapi.Condition{ - Type: apis.RestoreTargetFound, - Status: core.ConditionUnknown, - Reason: apis.UnableToCheckTargetAvailability, - Message: fmt.Sprintf("Failed to check whether restore target %s %s/%s exist or not. Reason: %v", - target.Ref.APIVersion, - strings.ToLower(target.Ref.Kind), - target.Ref.Name, - err, - ), - }) -} - -func SetRestoreJobCreatedConditionToTrue(inv invoker.RestoreInvoker, tref *api_v1beta1.TargetRef) error { - return inv.SetCondition(tref, kmapi.Condition{ - Type: apis.RestoreJobCreated, - Status: core.ConditionTrue, - Reason: apis.RestoreJobCreationSucceeded, - Message: "Successfully created restore job.", - }) -} - -func SetRestoreJobCreatedConditionToFalse(inv invoker.RestoreInvoker, tref *api_v1beta1.TargetRef, err error) error { - return inv.SetCondition(tref, kmapi.Condition{ - Type: apis.RestoreJobCreated, - Status: core.ConditionFalse, - Reason: apis.RestoreJobCreationFailed, - Message: fmt.Sprintf("Failed to create restore job. Reason: %v", err.Error()), - }) -} - -func SetInitContainerInjectedConditionToTrue(inv invoker.RestoreInvoker, tref *api_v1beta1.TargetRef) error { - return inv.SetCondition(tref, kmapi.Condition{ - Type: apis.StashInitContainerInjected, - Status: core.ConditionTrue, - Reason: apis.InitContainerInjectionSucceeded, - Message: "Successfully injected stash init-container.", - }) -} - -func SetInitContainerInjectedConditionToFalse(inv invoker.RestoreInvoker, tref *api_v1beta1.TargetRef, err error) error { - return inv.SetCondition(tref, kmapi.Condition{ - Type: apis.StashInitContainerInjected, - Status: core.ConditionFalse, - Reason: apis.InitContainerInjectionFailed, - Message: fmt.Sprintf("Failed to inject Stash init-container. Reason: %v", err.Error()), - }) -} - -func SetRestoreCompletedConditionToTrue(inv invoker.RestoreInvoker, tref *api_v1beta1.TargetRef, msg string) error { - return inv.SetCondition(tref, kmapi.Condition{ - Type: apis.RestoreCompleted, - Status: core.ConditionTrue, - Reason: "PostRestoreTasksExecuted", - Message: msg, - }) -} - -func SetRestoreCompletedConditionToFalse(inv invoker.RestoreInvoker, tref *api_v1beta1.TargetRef, msg string) error { - return inv.SetCondition(tref, kmapi.Condition{ - Type: apis.RestoreCompleted, - Status: core.ConditionFalse, - Reason: "PostRestoreTasksNotExecuted", - Message: msg, - }) -} - -func SetRestorerEnsuredToTrue(inv invoker.RestoreInvoker, tref *api_v1beta1.TargetRef, msg string) error { - return inv.SetCondition(tref, kmapi.Condition{ - Type: apis.RestorerEnsured, - Status: core.ConditionTrue, - Reason: "SuccessfullyEnsuredRestorerEntity", - Message: msg, - }) -} - -func SetRestorerEnsuredToFalse(inv invoker.RestoreInvoker, tref *api_v1beta1.TargetRef, msg string) error { - return inv.SetCondition(tref, kmapi.Condition{ - Type: apis.RestorerEnsured, - Status: core.ConditionFalse, - Reason: "FailedToEnsureRestorerEntity", - Message: msg, - }) -} - -func SetMetricsPushedConditionToFalse(inv invoker.RestoreInvoker, tref *api_v1beta1.TargetRef, err error) error { - return inv.SetCondition(tref, kmapi.Condition{ - Type: apis.MetricsPushed, - Status: core.ConditionFalse, - Reason: apis.FailedToPushMetrics, - Message: fmt.Sprintf("Failed to push metrics. Reason: %v", err.Error()), - }) -} - -func SetMetricsPushedConditionToTrue(inv invoker.RestoreInvoker, tref *api_v1beta1.TargetRef) error { - return inv.SetCondition(tref, kmapi.Condition{ - Type: apis.MetricsPushed, - Status: core.ConditionTrue, - Reason: apis.SuccessfullyPushedMetrics, - Message: "Successfully pushed metrics.", - }) -} diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/conditions/restore_invoker.go b/vendor/stash.appscode.dev/apimachinery/pkg/conditions/restore_invoker.go new file mode 100644 index 000000000..a6939f51d --- /dev/null +++ b/vendor/stash.appscode.dev/apimachinery/pkg/conditions/restore_invoker.go @@ -0,0 +1,255 @@ +/* +Copyright AppsCode Inc. and Contributors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package conditions + +import ( + "fmt" + "strings" + + "stash.appscode.dev/apimachinery/apis/stash/v1beta1" + "stash.appscode.dev/apimachinery/pkg/invoker" + + core "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + kmapi "kmodules.xyz/client-go/api/v1" +) + +func SetRestoreTargetFoundConditionToTrue(inv invoker.RestoreInvoker, index int) error { + target := inv.GetTargetInfo()[index].Target + return inv.SetCondition(&target.Ref, kmapi.Condition{ + Type: v1beta1.RestoreTargetFound, + Status: core.ConditionTrue, + Reason: v1beta1.TargetAvailable, + Message: fmt.Sprintf("Restore target %s %s/%s found.", + target.Ref.APIVersion, + strings.ToLower(target.Ref.Kind), + target.Ref.Name, + ), + LastTransitionTime: metav1.Now(), + }) +} + +func SetRestoreTargetFoundConditionToFalse(inv invoker.RestoreInvoker, index int) error { + target := inv.GetTargetInfo()[index].Target + return inv.SetCondition(&target.Ref, kmapi.Condition{ + Type: v1beta1.RestoreTargetFound, + Status: core.ConditionFalse, + Reason: v1beta1.TargetNotAvailable, + Message: fmt.Sprintf("Restore target %s %s/%s does not exist.", + target.Ref.APIVersion, + strings.ToLower(target.Ref.Kind), + target.Ref.Name, + ), + LastTransitionTime: metav1.Now(), + }) +} + +func SetRestoreTargetFoundConditionToUnknown(inv invoker.RestoreInvoker, index int, err error) error { + target := inv.GetTargetInfo()[index].Target + return inv.SetCondition(&target.Ref, kmapi.Condition{ + Type: v1beta1.RestoreTargetFound, + Status: core.ConditionUnknown, + Reason: v1beta1.UnableToCheckTargetAvailability, + Message: fmt.Sprintf("Failed to check whether restore target %s %s/%s exist or not. Reason: %v", + target.Ref.APIVersion, + strings.ToLower(target.Ref.Kind), + target.Ref.Name, + err, + ), + LastTransitionTime: metav1.Now(), + }) +} + +func SetRestoreJobCreatedConditionToTrue(inv invoker.RestoreInvoker, tref *v1beta1.TargetRef) error { + return inv.SetCondition(tref, kmapi.Condition{ + Type: v1beta1.RestoreJobCreated, + Status: core.ConditionTrue, + Reason: v1beta1.RestoreJobCreationSucceeded, + Message: "Successfully created restore job.", + LastTransitionTime: metav1.Now(), + }) +} + +func SetRestoreJobCreatedConditionToFalse(inv invoker.RestoreInvoker, tref *v1beta1.TargetRef, err error) error { + return inv.SetCondition(tref, kmapi.Condition{ + Type: v1beta1.RestoreJobCreated, + Status: core.ConditionFalse, + Reason: v1beta1.RestoreJobCreationFailed, + Message: fmt.Sprintf("Failed to create restore job. Reason: %v", err.Error()), + LastTransitionTime: metav1.Now(), + }) +} + +func SetInitContainerInjectedConditionToTrue(inv invoker.RestoreInvoker, tref *v1beta1.TargetRef) error { + return inv.SetCondition(tref, kmapi.Condition{ + Type: v1beta1.StashInitContainerInjected, + Status: core.ConditionTrue, + Reason: v1beta1.InitContainerInjectionSucceeded, + Message: "Successfully injected stash init-container.", + LastTransitionTime: metav1.Now(), + }) +} + +func SetInitContainerInjectedConditionToFalse(inv invoker.RestoreInvoker, tref *v1beta1.TargetRef, err error) error { + return inv.SetCondition(tref, kmapi.Condition{ + Type: v1beta1.StashInitContainerInjected, + Status: core.ConditionFalse, + Reason: v1beta1.InitContainerInjectionFailed, + Message: fmt.Sprintf("Failed to inject Stash init-container. Reason: %v", err.Error()), + LastTransitionTime: metav1.Now(), + }) +} + +func SetRestoreCompletedConditionToTrue(inv invoker.RestoreInvoker, tref *v1beta1.TargetRef, msg string) error { + return inv.SetCondition(tref, kmapi.Condition{ + Type: v1beta1.RestoreCompleted, + Status: core.ConditionTrue, + Reason: v1beta1.PostRestoreTasksExecuted, + Message: msg, + LastTransitionTime: metav1.Now(), + }) +} + +func SetRestoreCompletedConditionToFalse(inv invoker.RestoreInvoker, tref *v1beta1.TargetRef, msg string) error { + return inv.SetCondition(tref, kmapi.Condition{ + Type: v1beta1.RestoreCompleted, + Status: core.ConditionFalse, + Reason: v1beta1.PostRestoreTasksNotExecuted, + Message: msg, + LastTransitionTime: metav1.Now(), + }) +} + +func SetRestoreExecutorEnsuredToTrue(inv invoker.RestoreInvoker, tref *v1beta1.TargetRef, msg string) error { + return inv.SetCondition(tref, kmapi.Condition{ + Type: v1beta1.RestoreExecutorEnsured, + Status: core.ConditionTrue, + Reason: v1beta1.SuccessfullyEnsuredRestoreExecutor, + Message: msg, + LastTransitionTime: metav1.Now(), + }) +} + +func SetRestoreExecutorEnsuredToFalse(inv invoker.RestoreInvoker, tref *v1beta1.TargetRef, msg string) error { + return inv.SetCondition(tref, kmapi.Condition{ + Type: v1beta1.RestoreExecutorEnsured, + Status: core.ConditionFalse, + Reason: v1beta1.FailedToEnsureRestoreExecutor, + Message: msg, + LastTransitionTime: metav1.Now(), + }) +} + +func SetRestoreMetricsPushedConditionToFalse(inv invoker.RestoreInvoker, err error) error { + return inv.SetCondition(nil, kmapi.Condition{ + Type: v1beta1.MetricsPushed, + Status: core.ConditionFalse, + Reason: v1beta1.FailedToPushMetrics, + Message: fmt.Sprintf("Failed to push metrics. Reason: %v", err.Error()), + LastTransitionTime: metav1.Now(), + }) +} + +func SetRestoreMetricsPushedConditionToTrue(inv invoker.RestoreInvoker) error { + return inv.SetCondition(nil, kmapi.Condition{ + Type: v1beta1.MetricsPushed, + Status: core.ConditionTrue, + Reason: v1beta1.SuccessfullyPushedMetrics, + Message: "Successfully pushed metrics.", + LastTransitionTime: metav1.Now(), + }) +} + +func SetPreRestoreHookExecutionSucceededToFalse(inv invoker.RestoreInvoker, err error) error { + return inv.SetCondition(nil, kmapi.Condition{ + Type: v1beta1.PreRestoreHookExecutionSucceeded, + Status: core.ConditionFalse, + Reason: v1beta1.FailedToExecutePreRestoreHook, + Message: fmt.Sprintf("Failed to execute preRestore hook. Reason: %v", err.Error()), + LastTransitionTime: metav1.Now(), + }) +} + +func SetPreRestoreHookExecutionSucceededToTrue(inv invoker.RestoreInvoker) error { + return inv.SetCondition(nil, kmapi.Condition{ + Type: v1beta1.PreRestoreHookExecutionSucceeded, + Status: core.ConditionTrue, + Reason: v1beta1.SuccessfullyExecutedPreRestoreHook, + Message: "Successfully executed preRestore hook.", + LastTransitionTime: metav1.Now(), + }) +} + +func SetPostRestoreHookExecutionSucceededToFalse(inv invoker.RestoreInvoker, err error) error { + return inv.SetCondition(nil, kmapi.Condition{ + Type: v1beta1.PostRestoreHookExecutionSucceeded, + Status: core.ConditionFalse, + Reason: v1beta1.FailedToExecutePostRestoreHook, + Message: fmt.Sprintf("Failed to execute postRestore hook. Reason: %v", err.Error()), + LastTransitionTime: metav1.Now(), + }) +} + +func SetPostRestoreHookExecutionSucceededToTrue(inv invoker.RestoreInvoker) error { + return inv.SetCondition(nil, kmapi.Condition{ + Type: v1beta1.PostRestoreHookExecutionSucceeded, + Status: core.ConditionTrue, + Reason: v1beta1.SuccessfullyExecutedPostRestoreHook, + Message: "Successfully executed postRestore hook.", + LastTransitionTime: metav1.Now(), + }) +} + +func SetGlobalPreRestoreHookSucceededConditionToFalse(invoker invoker.RestoreInvoker, hookErr error) error { + return invoker.SetCondition(nil, kmapi.Condition{ + Type: v1beta1.GlobalPreRestoreHookSucceeded, + Status: core.ConditionFalse, + Reason: v1beta1.GlobalPreRestoreHookExecutionFailed, + Message: fmt.Sprintf("Failed to execute global PreRestore Hook. Reason: %v.", hookErr), + LastTransitionTime: metav1.Now(), + }) +} + +func SetGlobalPreRestoreHookSucceededConditionToTrue(invoker invoker.RestoreInvoker) error { + return invoker.SetCondition(nil, kmapi.Condition{ + Type: v1beta1.GlobalPreRestoreHookSucceeded, + Status: core.ConditionTrue, + Reason: v1beta1.GlobalPreRestoreHookExecutedSuccessfully, + Message: "Global PreRestore hook has been executed successfully", + LastTransitionTime: metav1.Now(), + }) +} + +func SetGlobalPostRestoreHookSucceededConditionToFalse(invoker invoker.RestoreInvoker, hookErr error) error { + return invoker.SetCondition(nil, kmapi.Condition{ + Type: v1beta1.GlobalPostRestoreHookSucceeded, + Status: core.ConditionFalse, + Reason: v1beta1.GlobalPostRestoreHookExecutionFailed, + Message: fmt.Sprintf("Failed to execute global PostRestore Hook. Reason: %v.", hookErr), + LastTransitionTime: metav1.Now(), + }) +} + +func SetGlobalPostRestoreHookSucceededConditionToTrue(invoker invoker.RestoreInvoker) error { + return invoker.SetCondition(nil, kmapi.Condition{ + Type: v1beta1.GlobalPostRestoreHookSucceeded, + Status: core.ConditionTrue, + Reason: v1beta1.GlobalPostRestoreHookExecutedSuccessfully, + Message: "Global PostRestore hook has been executed successfully", + LastTransitionTime: metav1.Now(), + }) +} diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/invoker/backup_invoker.go b/vendor/stash.appscode.dev/apimachinery/pkg/invoker/backup_invoker.go index ffe31e5c7..be52b33c3 100644 --- a/vendor/stash.appscode.dev/apimachinery/pkg/invoker/backup_invoker.go +++ b/vendor/stash.appscode.dev/apimachinery/pkg/invoker/backup_invoker.go @@ -19,8 +19,8 @@ package invoker import ( "context" "fmt" + "time" - "stash.appscode.dev/apimachinery/apis" "stash.appscode.dev/apimachinery/apis/stash/v1alpha1" "stash.appscode.dev/apimachinery/apis/stash/v1beta1" cs "stash.appscode.dev/apimachinery/client/clientset/versioned" @@ -39,6 +39,7 @@ type BackupInvoker interface { DriverHandler ObjectFormatter BackupInvokerStatusHandler + Summarizer } type BackupExecutionOrderHandler interface { @@ -170,18 +171,18 @@ func isConditionSatisfied(conditions []kmapi.Condition, condType string) bool { return true } -func calculateBackupInvokerPhase(driver v1beta1.Snapshotter, conditions []kmapi.Condition) v1beta1.BackupInvokerPhase { - if !isConditionSatisfied(conditions, apis.RepositoryFound) || - !isConditionSatisfied(conditions, apis.BackendSecretFound) { +func CalculateBackupInvokerPhase(driver v1beta1.Snapshotter, conditions []kmapi.Condition) v1beta1.BackupInvokerPhase { + if !isConditionSatisfied(conditions, v1beta1.RepositoryFound) || + !isConditionSatisfied(conditions, v1beta1.BackendSecretFound) { return v1beta1.BackupInvokerNotReady } - if kmapi.IsConditionFalse(conditions, apis.ValidationPassed) { + if kmapi.IsConditionFalse(conditions, v1beta1.ValidationPassed) { return v1beta1.BackupInvokerInvalid } - if kmapi.IsConditionTrue(conditions, apis.ValidationPassed) && - kmapi.IsConditionTrue(conditions, apis.CronJobCreated) && + if kmapi.IsConditionTrue(conditions, v1beta1.ValidationPassed) && + kmapi.IsConditionTrue(conditions, v1beta1.CronJobCreated) && backendRequirementsSatisfied(driver, conditions) { return v1beta1.BackupInvokerReady } @@ -191,7 +192,77 @@ func calculateBackupInvokerPhase(driver v1beta1.Snapshotter, conditions []kmapi. func backendRequirementsSatisfied(driver v1beta1.Snapshotter, conditions []kmapi.Condition) bool { if driver == v1beta1.ResticSnapshotter { - return kmapi.IsConditionTrue(conditions, apis.RepositoryFound) && kmapi.IsConditionTrue(conditions, apis.BackendSecretFound) + return kmapi.IsConditionTrue(conditions, v1beta1.RepositoryFound) && kmapi.IsConditionTrue(conditions, v1beta1.BackendSecretFound) } return true } + +func getTargetBackupSummary(stashClient cs.Interface, target v1beta1.TargetRef, session kmapi.ObjectReference) *v1beta1.Summary { + summary := &v1beta1.Summary{ + Name: session.Name, + Namespace: session.Namespace, + Target: target, + } + + backupSession, err := stashClient.StashV1beta1().BackupSessions(session.Namespace).Get(context.TODO(), session.Name, metav1.GetOptions{}) + if err != nil { + summary.Status.Phase = string(v1beta1.BackupSessionUnknown) + summary.Status.Error = fmt.Sprintf("Unable to summarize target backup state. Reason: %s", err.Error()) + return summary + } + summary.Status.Duration = time.Since(backupSession.CreationTimestamp.Time).Round(time.Second).String() + + if target.Name != "" { + for _, t := range backupSession.Status.Targets { + if TargetMatched(target, t.Ref) { + failureFound, reason := checkBackupFailureInTargetStatus(t) + if failureFound { + summary.Status.Phase = string(v1beta1.BackupSessionFailed) + summary.Status.Error = reason + return summary + } + } + } + } else { + for _, t := range backupSession.Status.Targets { + failureFound, reason := checkBackupFailureInTargetStatus(t) + if failureFound { + summary.Status.Phase = string(v1beta1.BackupSessionFailed) + summary.Status.Error = reason + return summary + } + } + } + + failureFound, reason := checkFailureInConditions(backupSession.Status.Conditions) + if failureFound { + summary.Status.Phase = string(v1beta1.BackupSessionFailed) + summary.Status.Error = reason + return summary + } + + summary.Status.Phase = string(v1beta1.RestoreSucceeded) + return summary +} + +func checkBackupFailureInTargetStatus(status v1beta1.BackupTargetStatus) (bool, string) { + failureFound, reason := checkBackupFailureInHostStatus(status.Stats) + if failureFound { + return true, reason + } + + failureFound, reason = checkFailureInConditions(status.Conditions) + if failureFound { + return true, reason + } + return false, "" +} + +func checkBackupFailureInHostStatus(status []v1beta1.HostBackupStats) (bool, string) { + for _, host := range status { + if hostBackupCompleted(host.Phase) && host.Phase != v1beta1.HostBackupSucceeded { + return true, host.Error + } + } + return false, "" +} diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/invoker/backupbatch.go b/vendor/stash.appscode.dev/apimachinery/pkg/invoker/backupbatch.go index 9bc04ef3f..1bbee5273 100644 --- a/vendor/stash.appscode.dev/apimachinery/pkg/invoker/backupbatch.go +++ b/vendor/stash.appscode.dev/apimachinery/pkg/invoker/backupbatch.go @@ -25,8 +25,10 @@ import ( stash_scheme "stash.appscode.dev/apimachinery/client/clientset/versioned/scheme" v1beta1_util "stash.appscode.dev/apimachinery/client/clientset/versioned/typed/stash/v1beta1/util" + "gomodules.xyz/pointer" core "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/reference" kmapi "kmodules.xyz/client-go/api/v1" @@ -69,6 +71,7 @@ func (inv *BackupBatchInvoker) GetOwnerRef() *metav1.OwnerReference { func (inv *BackupBatchInvoker) GetLabels() map[string]string { return inv.backupBatch.OffshootLabels() } + func (inv *BackupBatchInvoker) AddFinalizer() error { updatedBackupBatch, _, err := v1beta1_util.PatchBackupBatch(context.TODO(), inv.stashClient.StashV1beta1(), inv.backupBatch, func(in *v1beta1.BackupBatch) *v1beta1.BackupBatch { in.ObjectMeta = core_util.AddFinalizer(in.ObjectMeta, v1beta1.StashKey) @@ -124,7 +127,7 @@ func (inv *BackupBatchInvoker) SetCondition(target *v1beta1.TargetRef, newCondit } else { in.Conditions = kmapi.SetCondition(in.Conditions, newCondition) } - in.Phase = calculateBackupInvokerPhase(inv.GetDriver(), in.Conditions) + in.Phase = CalculateBackupInvokerPhase(inv.GetDriver(), in.Conditions) return inv.backupBatch.UID, in }, metav1.UpdateOptions{}) if err != nil { @@ -234,6 +237,10 @@ func (inv *BackupBatchInvoker) GetObjectJSON() (string, error) { return string(jsonObj), nil } +func (inv *BackupBatchInvoker) GetRuntimeObject() runtime.Object { + return inv.backupBatch +} + func (inv *BackupBatchInvoker) GetRetentionPolicy() v1alpha1.RetentionPolicy { return inv.backupBatch.Spec.RetentionPolicy } @@ -241,3 +248,13 @@ func (inv *BackupBatchInvoker) GetRetentionPolicy() v1alpha1.RetentionPolicy { func (inv *BackupBatchInvoker) GetPhase() v1beta1.BackupInvokerPhase { return inv.backupBatch.Status.Phase } + +func (inv *BackupBatchInvoker) GetSummary(target v1beta1.TargetRef, session kmapi.ObjectReference) *v1beta1.Summary { + summary := getTargetBackupSummary(inv.stashClient, target, session) + summary.Invoker = core.TypedLocalObjectReference{ + APIGroup: pointer.StringP(v1beta1.SchemeGroupVersion.Group), + Kind: v1beta1.ResourceKindBackupBatch, + Name: inv.backupBatch.Name, + } + return summary +} diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/invoker/backupconfiguration.go b/vendor/stash.appscode.dev/apimachinery/pkg/invoker/backupconfiguration.go index 1a39c7665..3eeadc414 100644 --- a/vendor/stash.appscode.dev/apimachinery/pkg/invoker/backupconfiguration.go +++ b/vendor/stash.appscode.dev/apimachinery/pkg/invoker/backupconfiguration.go @@ -25,6 +25,7 @@ import ( stash_scheme "stash.appscode.dev/apimachinery/client/clientset/versioned/scheme" v1beta1_util "stash.appscode.dev/apimachinery/client/clientset/versioned/typed/stash/v1beta1/util" + "gomodules.xyz/pointer" core "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" @@ -69,6 +70,7 @@ func (inv *BackupConfigurationInvoker) GetOwnerRef() *metav1.OwnerReference { func (inv *BackupConfigurationInvoker) GetLabels() map[string]string { return inv.backupConfig.OffshootLabels() } + func (inv *BackupConfigurationInvoker) AddFinalizer() error { updatedBackupConfig, _, err := v1beta1_util.PatchBackupConfiguration(context.TODO(), inv.stashClient.StashV1beta1(), inv.backupConfig, func(in *v1beta1.BackupConfiguration) *v1beta1.BackupConfiguration { in.ObjectMeta = core_util.AddFinalizer(in.ObjectMeta, v1beta1.StashKey) @@ -113,7 +115,7 @@ func (inv *BackupConfigurationInvoker) GetCondition(target *v1beta1.TargetRef, c func (inv *BackupConfigurationInvoker) SetCondition(target *v1beta1.TargetRef, newCondition kmapi.Condition) error { updatedBackupConfig, err := v1beta1_util.UpdateBackupConfigurationStatus(context.TODO(), inv.stashClient.StashV1beta1(), inv.backupConfig.ObjectMeta, func(in *v1beta1.BackupConfigurationStatus) (types.UID, *v1beta1.BackupConfigurationStatus) { in.Conditions = kmapi.SetCondition(in.Conditions, newCondition) - in.Phase = calculateBackupInvokerPhase(inv.GetDriver(), in.Conditions) + in.Phase = CalculateBackupInvokerPhase(inv.GetDriver(), in.Conditions) return inv.backupConfig.UID, in }, metav1.UpdateOptions{}) if err != nil { @@ -225,3 +227,13 @@ func (inv *BackupConfigurationInvoker) GetRetentionPolicy() v1alpha1.RetentionPo func (inv *BackupConfigurationInvoker) GetPhase() v1beta1.BackupInvokerPhase { return inv.backupConfig.Status.Phase } + +func (inv *BackupConfigurationInvoker) GetSummary(target v1beta1.TargetRef, session kmapi.ObjectReference) *v1beta1.Summary { + summary := getTargetBackupSummary(inv.stashClient, target, session) + summary.Invoker = core.TypedLocalObjectReference{ + APIGroup: pointer.StringP(v1beta1.SchemeGroupVersion.Group), + Kind: v1beta1.ResourceKindBackupConfiguration, + Name: inv.backupConfig.Name, + } + return summary +} diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/invoker/backupsession.go b/vendor/stash.appscode.dev/apimachinery/pkg/invoker/backupsession.go new file mode 100644 index 000000000..6a17a857d --- /dev/null +++ b/vendor/stash.appscode.dev/apimachinery/pkg/invoker/backupsession.go @@ -0,0 +1,299 @@ +/* +Copyright AppsCode Inc. and Contributors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package invoker + +import ( + "context" + "time" + + "stash.appscode.dev/apimachinery/apis/stash/v1beta1" + cs "stash.appscode.dev/apimachinery/client/clientset/versioned" + stash_util "stash.appscode.dev/apimachinery/client/clientset/versioned/typed/stash/v1beta1/util" + + "gomodules.xyz/x/arrays" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" + kmapi "kmodules.xyz/client-go/api/v1" +) + +type BackupSessionHandler struct { + stashClient cs.Interface + backupSession *v1beta1.BackupSession +} + +func NewBackupSessionHandler(stashClient cs.Interface, backupSession *v1beta1.BackupSession) *BackupSessionHandler { + return &BackupSessionHandler{ + stashClient: stashClient, + backupSession: backupSession, + } +} + +func (h *BackupSessionHandler) UpdateStatus(status *v1beta1.BackupSessionStatus) error { + updatedBackupSession, err := stash_util.UpdateBackupSessionStatus( + context.TODO(), + h.stashClient.StashV1beta1(), + h.backupSession.ObjectMeta, + func(in *v1beta1.BackupSessionStatus) (types.UID, *v1beta1.BackupSessionStatus) { + in.Conditions = upsertConditions(in.Conditions, status.Conditions) + + if len(status.Targets) > 0 { + for i := range status.Targets { + in.Targets = upsertBackupMembersStatus(in.Targets, status.Targets[i]) + } + } + + in.Phase = calculateBackupSessionPhase(in) + if IsBackupCompleted(in.Phase) { + in.SessionDuration = time.Since(h.backupSession.ObjectMeta.CreationTimestamp.Time).Round(time.Second).String() + } + return h.backupSession.ObjectMeta.UID, in + }, + metav1.UpdateOptions{}, + ) + if err != nil { + return err + } + h.backupSession = updatedBackupSession + return nil +} + +func (h *BackupSessionHandler) GetObjectMeta() metav1.ObjectMeta { + return h.backupSession.ObjectMeta +} + +func (h *BackupSessionHandler) GetStatus() v1beta1.BackupSessionStatus { + return h.backupSession.Status +} + +func (h *BackupSessionHandler) GetTargetStatus() []v1beta1.BackupTargetStatus { + return h.backupSession.Status.Targets +} + +func (h *BackupSessionHandler) GetConditions() []kmapi.Condition { + return h.backupSession.Status.Conditions +} + +func (h *BackupSessionHandler) GetTargetConditions(target v1beta1.TargetRef) []kmapi.Condition { + for _, t := range h.backupSession.Status.Targets { + if TargetMatched(t.Ref, target) { + return t.Conditions + } + } + return nil +} + +func (h *BackupSessionHandler) GetInvoker() (BackupInvoker, error) { + return NewBackupInvoker(h.stashClient, h.backupSession.Spec.Invoker.Kind, h.backupSession.Spec.Invoker.Name, h.backupSession.Namespace) +} + +func (h *BackupSessionHandler) GetInvokerRef() v1beta1.BackupInvokerRef { + return h.backupSession.Spec.Invoker +} + +func (h *BackupSessionHandler) GetBackupSession() *v1beta1.BackupSession { + b := h.backupSession.DeepCopy() + return b +} + +func IsBackupCompleted(phase v1beta1.BackupSessionPhase) bool { + return phase == v1beta1.BackupSessionSucceeded || + phase == v1beta1.BackupSessionFailed || + phase == v1beta1.BackupSessionSkipped || + phase == v1beta1.BackupSessionUnknown +} + +func BackupCompletedForAllTargets(status []v1beta1.BackupTargetStatus) bool { + for _, t := range status { + if t.TotalHosts == nil || !backupCompletedForAllHosts(t.Stats, *t.TotalHosts) { + return false + } + } + return len(status) > 0 +} + +func backupCompletedForAllHosts(status []v1beta1.HostBackupStats, totalHosts int32) bool { + for _, h := range status { + if !hostBackupCompleted(h.Phase) { + return false + } + } + return len(status) == int(totalHosts) +} + +func hostBackupCompleted(phase v1beta1.HostBackupPhase) bool { + return phase == v1beta1.HostBackupSucceeded || + phase == v1beta1.HostBackupFailed +} + +func upsertBackupMembersStatus(cur []v1beta1.BackupTargetStatus, new v1beta1.BackupTargetStatus) []v1beta1.BackupTargetStatus { + // if the member status already exist, then update it + for i := range cur { + if TargetMatched(cur[i].Ref, new.Ref) { + cur[i] = upsertBackupTargetStatus(cur[i], new) + return cur + } + } + + // the member status does not exist. so, add new entry. + new.Phase = calculateBackupTargetPhase(new) + cur = append(cur, new) + return cur +} + +func upsertBackupTargetStatus(cur, new v1beta1.BackupTargetStatus) v1beta1.BackupTargetStatus { + if len(new.Conditions) > 0 { + cur.Conditions = upsertConditions(cur.Conditions, new.Conditions) + } + + if new.TotalHosts != nil { + cur.TotalHosts = new.TotalHosts + } + + if len(new.Stats) > 0 { + cur.Stats = upsertBackupHostStatus(cur.Stats, new.Stats) + } + + if len(new.PreBackupActions) > 0 { + cur.PreBackupActions = upsertArray(cur.PreBackupActions, new.PreBackupActions) + } + + if len(new.PostBackupActions) > 0 { + cur.PostBackupActions = upsertArray(cur.PostBackupActions, new.PostBackupActions) + } + + cur.Phase = calculateBackupTargetPhase(cur) + return cur +} + +func upsertBackupHostStatus(cur, new []v1beta1.HostBackupStats) []v1beta1.HostBackupStats { + for i := range new { + index, hostEntryExist := backupHostEntryIndex(cur, new[i]) + if hostEntryExist { + cur[index] = new[i] + } else { + cur = append(cur, new[i]) + } + } + return cur +} + +func calculateBackupTargetPhase(status v1beta1.BackupTargetStatus) v1beta1.TargetPhase { + if kmapi.IsConditionFalse(status.Conditions, v1beta1.BackupExecutorEnsured) || + kmapi.IsConditionFalse(status.Conditions, v1beta1.PreBackupHookExecutionSucceeded) || + kmapi.IsConditionFalse(status.Conditions, v1beta1.PostBackupHookExecutionSucceeded) { + return v1beta1.TargetBackupFailed + } + + if status.TotalHosts == nil { + return v1beta1.TargetBackupPending + } + + failedHostCount := int32(0) + successfulHostCount := int32(0) + for _, hostStats := range status.Stats { + switch hostStats.Phase { + case v1beta1.HostBackupFailed: + failedHostCount++ + case v1beta1.HostBackupSucceeded: + successfulHostCount++ + } + } + completedHosts := successfulHostCount + failedHostCount + + if completedHosts == *status.TotalHosts { + if failedHostCount > 0 { + return v1beta1.TargetBackupFailed + } + return v1beta1.TargetBackupSucceeded + } + return v1beta1.TargetBackupRunning +} + +func calculateBackupSessionPhase(status *v1beta1.BackupSessionStatus) v1beta1.BackupSessionPhase { + if kmapi.IsConditionFalse(status.Conditions, v1beta1.RetentionPolicyApplied) || + kmapi.IsConditionFalse(status.Conditions, v1beta1.RepositoryMetricsPushed) || + kmapi.IsConditionFalse(status.Conditions, v1beta1.MetricsPushed) || + kmapi.IsConditionFalse(status.Conditions, v1beta1.BackupHistoryCleaned) || + kmapi.IsConditionFalse(status.Conditions, v1beta1.RepositoryIntegrityVerified) || + kmapi.IsConditionFalse(status.Conditions, v1beta1.GlobalPreBackupHookSucceeded) || + kmapi.IsConditionFalse(status.Conditions, v1beta1.GlobalPostBackupHookSucceeded) { + return v1beta1.BackupSessionFailed + } + + if kmapi.IsConditionTrue(status.Conditions, v1beta1.BackupSkipped) { + return v1beta1.BackupSessionSkipped + } + + if len(status.Targets) == 0 || isAllTargetBackupPending(status.Targets) { + return v1beta1.BackupSessionPending + } + + failedTargetCount := 0 + successfulTargetCount := 0 + + for _, t := range status.Targets { + switch t.Phase { + case v1beta1.TargetBackupFailed: + failedTargetCount++ + case v1beta1.TargetBackupSucceeded: + successfulTargetCount++ + } + } + completedTargets := successfulTargetCount + failedTargetCount + + if completedTargets == len(status.Targets) { + if failedTargetCount > 0 { + return v1beta1.BackupSessionFailed + } + + if kmapi.IsConditionTrue(status.Conditions, v1beta1.MetricsPushed) && + kmapi.IsConditionTrue(status.Conditions, v1beta1.BackupHistoryCleaned) { + return v1beta1.BackupSessionSucceeded + } + } + + return v1beta1.BackupSessionRunning +} + +func backupHostEntryIndex(entries []v1beta1.HostBackupStats, target v1beta1.HostBackupStats) (int, bool) { + for i := range entries { + if entries[i].Hostname == target.Hostname { + return i, true + } + } + return -1, false +} + +func upsertArray(cur, new []string) []string { + for i := range new { + if exist, idx := arrays.Contains(cur, new[i]); exist { + cur[idx] = new[i] + continue + } + cur = append(cur, new[i]) + } + return cur +} + +func isAllTargetBackupPending(status []v1beta1.BackupTargetStatus) bool { + for _, t := range status { + if t.Phase != v1beta1.TargetBackupPending { + return false + } + } + return true +} diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/invoker/interfaces.go b/vendor/stash.appscode.dev/apimachinery/pkg/invoker/interfaces.go index 575ecdebd..7c1f0e56d 100644 --- a/vendor/stash.appscode.dev/apimachinery/pkg/invoker/interfaces.go +++ b/vendor/stash.appscode.dev/apimachinery/pkg/invoker/interfaces.go @@ -64,3 +64,7 @@ type ObjectFormatter interface { GetHash() string GetObjectJSON() (string, error) } + +type Summarizer interface { + GetSummary(target v1beta1.TargetRef, session kmapi.ObjectReference) *v1beta1.Summary +} diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/invoker/restore_invoker.go b/vendor/stash.appscode.dev/apimachinery/pkg/invoker/restore_invoker.go index 19ae936f6..d109d0e1e 100644 --- a/vendor/stash.appscode.dev/apimachinery/pkg/invoker/restore_invoker.go +++ b/vendor/stash.appscode.dev/apimachinery/pkg/invoker/restore_invoker.go @@ -20,12 +20,11 @@ import ( "context" "fmt" "strings" + "time" - "stash.appscode.dev/apimachinery/apis" "stash.appscode.dev/apimachinery/apis/stash/v1beta1" cs "stash.appscode.dev/apimachinery/client/clientset/versioned" - core "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" kmapi "kmodules.xyz/client-go/api/v1" @@ -49,6 +48,7 @@ type RestoreInvoker interface { KubeDBIntegrator ObjectFormatter RestoreStatusHandler + Summarizer } type RestoreExecutionOrderHandler interface { @@ -189,19 +189,23 @@ func getInvokerStatusFromRestoreBatch(restoreBatch *v1beta1.RestoreBatch) Restor func getInvokerStatusFromRestoreSession(restoreSession *v1beta1.RestoreSession) RestoreInvokerStatus { invokerStatus := RestoreInvokerStatus{ - Phase: restoreSession.Status.Phase, - SessionDuration: restoreSession.Status.SessionDuration, + SessionDuration: time.Since(restoreSession.CreationTimestamp.Time).Round(time.Second).String(), Conditions: restoreSession.Status.Conditions, } + var targetStatus v1beta1.RestoreMemberStatus if restoreSession.Spec.Target != nil { - invokerStatus.TargetStatus = append(invokerStatus.TargetStatus, v1beta1.RestoreMemberStatus{ + targetStatus = v1beta1.RestoreMemberStatus{ Ref: restoreSession.Spec.Target.Ref, Conditions: restoreSession.Status.Conditions, TotalHosts: restoreSession.Status.TotalHosts, - Phase: v1beta1.RestoreTargetPhase(restoreSession.Status.Phase), Stats: restoreSession.Status.Stats, - }) + } + targetStatus.Phase = calculateRestoreTargetPhase(targetStatus) } + + invokerStatus.TargetStatus = append(invokerStatus.TargetStatus, targetStatus) + invokerStatus.Phase = calculateRestoreSessionPhase(targetStatus) + return invokerStatus } @@ -254,18 +258,15 @@ func upsertRestoreTargetStatus(cur, new v1beta1.RestoreMemberStatus) v1beta1.Res } func calculateRestoreTargetPhase(status v1beta1.RestoreMemberStatus) v1beta1.RestoreTargetPhase { - if kmapi.IsConditionFalse(status.Conditions, apis.RestorerEnsured) || - kmapi.IsConditionFalse(status.Conditions, apis.MetricsPushed) { + if kmapi.IsConditionFalse(status.Conditions, v1beta1.RestoreExecutorEnsured) || + kmapi.IsConditionFalse(status.Conditions, v1beta1.PreRestoreHookExecutionSucceeded) || + kmapi.IsConditionFalse(status.Conditions, v1beta1.PostRestoreHookExecutionSucceeded) { return v1beta1.TargetRestoreFailed } - allConditionTrue := true - for _, c := range status.Conditions { - if c.Status != core.ConditionTrue { - allConditionTrue = false - } - } - if !allConditionTrue || status.TotalHosts == nil { + if status.TotalHosts == nil || + len(status.Conditions) == 0 || + kmapi.IsConditionFalse(status.Conditions, v1beta1.RestoreTargetFound) { return v1beta1.TargetRestorePending } @@ -282,20 +283,19 @@ func calculateRestoreTargetPhase(status v1beta1.RestoreMemberStatus) v1beta1.Res successfulHostCount++ } } - completedHosts := successfulHostCount + failedHostCount + unknownHostCount - if completedHosts < *status.TotalHosts { - return v1beta1.TargetRestoreRunning - } - if failedHostCount > 0 { - return v1beta1.TargetRestoreFailed - } - if unknownHostCount > 0 { - return v1beta1.TargetRestorePhaseUnknown - } + if completedHosts == *status.TotalHosts { + if unknownHostCount > 0 { + return v1beta1.TargetRestorePhaseUnknown + } - return v1beta1.TargetRestoreSucceeded + if failedHostCount > 0 { + return v1beta1.TargetRestoreFailed + } + return v1beta1.TargetRestoreSucceeded + } + return v1beta1.TargetRestoreRunning } func IsRestoreCompleted(phase v1beta1.RestorePhase) bool { diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/invoker/restorebatch.go b/vendor/stash.appscode.dev/apimachinery/pkg/invoker/restorebatch.go index 73ef573dc..abf9131cd 100644 --- a/vendor/stash.appscode.dev/apimachinery/pkg/invoker/restorebatch.go +++ b/vendor/stash.appscode.dev/apimachinery/pkg/invoker/restorebatch.go @@ -21,16 +21,17 @@ import ( "fmt" "time" - "stash.appscode.dev/apimachinery/apis" "stash.appscode.dev/apimachinery/apis/stash/v1alpha1" "stash.appscode.dev/apimachinery/apis/stash/v1beta1" cs "stash.appscode.dev/apimachinery/client/clientset/versioned" stash_scheme "stash.appscode.dev/apimachinery/client/clientset/versioned/scheme" v1beta1_util "stash.appscode.dev/apimachinery/client/clientset/versioned/typed/stash/v1beta1/util" + "gomodules.xyz/pointer" core "k8s.io/api/core/v1" kerr "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/reference" @@ -221,6 +222,10 @@ func (inv *RestoreBatchInvoker) GetObjectJSON() (string, error) { return string(jsonObj), nil } +func (inv *RestoreBatchInvoker) GetRuntimeObject() runtime.Object { + return inv.restoreBatch +} + func (inv *RestoreBatchInvoker) CreateEvent(eventType, source, reason, message string) error { objRef, err := inv.GetObjectRef() if err != nil { @@ -334,19 +339,20 @@ func upsertRestoreMemberStatus(cur []v1beta1.RestoreMemberStatus, new v1beta1.Re } } // the member status does not exist. so, add new entry. + new.Phase = calculateRestoreTargetPhase(new) cur = append(cur, new) return cur } func calculateRestoreBatchPhase(status *v1beta1.RestoreBatchStatus, totalTargets int) v1beta1.RestorePhase { - if len(status.Conditions) == 0 || len(status.Members) == 0 || - kmapi.IsConditionFalse(status.Conditions, apis.RepositoryFound) || - kmapi.IsConditionFalse(status.Conditions, apis.BackendSecretFound) { - return v1beta1.RestorePending + if kmapi.IsConditionFalse(status.Conditions, v1beta1.MetricsPushed) || + kmapi.IsConditionFalse(status.Conditions, v1beta1.GlobalPreRestoreHookSucceeded) || + kmapi.IsConditionFalse(status.Conditions, v1beta1.GlobalPostRestoreHookSucceeded) { + return v1beta1.RestoreFailed } - if kmapi.IsConditionFalse(status.Conditions, apis.ValidationPassed) { - return v1beta1.RestorePhaseInvalid + if len(status.Conditions) == 0 || len(status.Members) == 0 || isAllTargetRestorePending(status.Members) { + return v1beta1.RestorePending } failedTargetCount := 0 @@ -364,15 +370,95 @@ func calculateRestoreBatchPhase(status *v1beta1.RestoreBatchStatus, totalTargets } } completedTargets := successfulTargetCount + failedTargetCount + unknownTargetCount - if completedTargets < len(status.Members) || completedTargets < totalTargets { - return v1beta1.RestoreRunning + + if completedTargets == totalTargets { + if unknownTargetCount > 0 { + return v1beta1.RestorePhaseUnknown + } + + if failedTargetCount > 0 { + return v1beta1.RestoreFailed + } + + if kmapi.IsConditionTrue(status.Conditions, v1beta1.MetricsPushed) { + return v1beta1.RestoreSucceeded + } } - if failedTargetCount > 0 { - return v1beta1.RestoreFailed + + if kmapi.IsConditionFalse(status.Conditions, v1beta1.RepositoryFound) || + kmapi.IsConditionFalse(status.Conditions, v1beta1.BackendSecretFound) { + return v1beta1.RestorePending } - if unknownTargetCount > 0 { - return v1beta1.RestorePhaseUnknown + + if kmapi.IsConditionFalse(status.Conditions, v1beta1.ValidationPassed) { + return v1beta1.RestorePhaseInvalid } - return v1beta1.RestoreSucceeded + return v1beta1.RestoreRunning +} + +func (inv *RestoreBatchInvoker) GetSummary(target v1beta1.TargetRef, session kmapi.ObjectReference) *v1beta1.Summary { + summary := &v1beta1.Summary{ + Name: session.Name, + Namespace: session.Namespace, + Target: target, + Invoker: core.TypedLocalObjectReference{ + APIGroup: pointer.StringP(v1beta1.SchemeGroupVersion.Group), + Kind: v1beta1.ResourceKindRestoreBatch, + Name: inv.restoreBatch.Name, + }, + } + + rb, err := inv.stashClient.StashV1beta1().RestoreBatches(session.Namespace).Get(context.TODO(), session.Name, metav1.GetOptions{}) + if err != nil { + summary.Status.Phase = string(v1beta1.RestorePhaseUnknown) + summary.Status.Error = fmt.Sprintf("Unable to summarize target restore state. Reason: %s", err.Error()) + return summary + } + summary.Status.Duration = time.Since(rb.CreationTimestamp.Time).Round(time.Second).String() + + if target.Name != "" { + for _, m := range rb.Status.Members { + if TargetMatched(target, m.Ref) { + failureFound, reason := checkRestoreFailureInMemberStatus(m) + if failureFound { + summary.Status.Phase = string(v1beta1.RestoreFailed) + summary.Status.Error = reason + return summary + } + } + } + } else { + for _, m := range rb.Status.Members { + failureFound, reason := checkRestoreFailureInMemberStatus(m) + if failureFound { + summary.Status.Phase = string(v1beta1.RestoreFailed) + summary.Status.Error = reason + return summary + } + } + } + + failureFound, reason := checkFailureInConditions(rb.Status.Conditions) + if failureFound { + summary.Status.Phase = string(v1beta1.RestoreFailed) + summary.Status.Error = reason + return summary + } + + summary.Status.Phase = string(v1beta1.RestoreSucceeded) + return summary +} + +func checkRestoreFailureInMemberStatus(status v1beta1.RestoreMemberStatus) (bool, string) { + failureFound, reason := checkRestoreFailureInHostStatus(status.Stats) + if failureFound { + return true, reason + } + + failureFound, reason = checkFailureInConditions(status.Conditions) + if failureFound { + return true, reason + } + return false, "" } diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/invoker/restoresession.go b/vendor/stash.appscode.dev/apimachinery/pkg/invoker/restoresession.go index 891af5f75..5479f7734 100644 --- a/vendor/stash.appscode.dev/apimachinery/pkg/invoker/restoresession.go +++ b/vendor/stash.appscode.dev/apimachinery/pkg/invoker/restoresession.go @@ -21,16 +21,17 @@ import ( "fmt" "time" - "stash.appscode.dev/apimachinery/apis" "stash.appscode.dev/apimachinery/apis/stash/v1alpha1" "stash.appscode.dev/apimachinery/apis/stash/v1beta1" cs "stash.appscode.dev/apimachinery/client/clientset/versioned" stash_scheme "stash.appscode.dev/apimachinery/client/clientset/versioned/scheme" v1beta1_util "stash.appscode.dev/apimachinery/client/clientset/versioned/typed/stash/v1beta1/util" + "gomodules.xyz/pointer" core "k8s.io/api/core/v1" kerr "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/reference" @@ -205,6 +206,10 @@ func (inv *RestoreSessionInvoker) GetObjectJSON() (string, error) { return string(jsonObj), nil } +func (inv *RestoreSessionInvoker) GetRuntimeObject() runtime.Object { + return inv.restoreSession +} + func (inv *RestoreSessionInvoker) CreateEvent(eventType, source, reason, message string) error { objRef, err := inv.GetObjectRef() if err != nil { @@ -274,7 +279,7 @@ func (inv *RestoreSessionInvoker) GetStatus() RestoreInvokerStatus { } func (inv *RestoreSessionInvoker) UpdateStatus(status RestoreInvokerStatus) error { - startTime := inv.GetObjectMeta().CreationTimestamp + startTime := inv.GetObjectMeta().CreationTimestamp.Time updatedRestoreSession, err := v1beta1_util.UpdateRestoreSessionStatus( context.TODO(), inv.stashClient.StashV1beta1(), @@ -298,8 +303,7 @@ func (inv *RestoreSessionInvoker) UpdateStatus(status RestoreInvokerStatus) erro in.Phase = calculateRestoreSessionPhase(updatedStatus) if IsRestoreCompleted(in.Phase) && in.SessionDuration == "" { - duration := time.Since(startTime.Time) - in.SessionDuration = duration.Round(time.Second).String() + in.SessionDuration = time.Since(startTime).Round(time.Second).String() } return inv.restoreSession.ObjectMeta.UID, in }, @@ -312,28 +316,131 @@ func (inv *RestoreSessionInvoker) UpdateStatus(status RestoreInvokerStatus) erro return nil } +func (inv *RestoreSessionInvoker) GetSummary(target v1beta1.TargetRef, session kmapi.ObjectReference) *v1beta1.Summary { + summary := &v1beta1.Summary{ + Name: session.Name, + Namespace: session.Namespace, + Target: target, + Invoker: core.TypedLocalObjectReference{ + APIGroup: pointer.StringP(v1beta1.SchemeGroupVersion.Group), + Kind: v1beta1.ResourceKindRestoreSession, + Name: inv.restoreSession.Name, + }, + } + restoreSession, err := inv.stashClient.StashV1beta1().RestoreSessions(session.Namespace).Get(context.TODO(), session.Name, metav1.GetOptions{}) + if err != nil { + summary.Status.Phase = string(v1beta1.RestorePhaseUnknown) + summary.Status.Error = fmt.Sprintf("Unable to summarize target restore state. Reason: %s", err.Error()) + return summary + } + summary.Status.Duration = time.Since(restoreSession.CreationTimestamp.Time).Round(time.Second).String() + + failureFound, reason := checkRestoreFailureInHostStatus(restoreSession.Status.Stats) + if failureFound { + summary.Status.Phase = string(v1beta1.RestoreFailed) + summary.Status.Error = reason + return summary + } + + failureFound, reason = checkFailureInConditions(restoreSession.Status.Conditions) + if failureFound { + summary.Status.Phase = string(v1beta1.RestoreFailed) + summary.Status.Error = reason + return summary + } + + summary.Status.Phase = string(v1beta1.RestoreSucceeded) + + return summary +} + +func checkRestoreFailureInHostStatus(status []v1beta1.HostRestoreStats) (bool, string) { + for _, host := range status { + if hostRestoreCompleted(host.Phase) && host.Phase != v1beta1.HostRestoreSucceeded { + return true, host.Error + } + } + return false, "" +} + +func checkFailureInConditions(conditions []kmapi.Condition) (bool, string) { + for _, c := range conditions { + if c.Status == core.ConditionFalse { + return true, c.Message + } + } + return false, "" +} + func calculateRestoreSessionPhase(status v1beta1.RestoreMemberStatus) v1beta1.RestorePhase { - if len(status.Conditions) == 0 || - kmapi.IsConditionFalse(status.Conditions, apis.RepositoryFound) || - kmapi.IsConditionFalse(status.Conditions, apis.BackendSecretFound) || - kmapi.IsConditionFalse(status.Conditions, apis.RestoreTargetFound) { + if kmapi.IsConditionFalse(status.Conditions, v1beta1.RestoreExecutorEnsured) || + kmapi.IsConditionFalse(status.Conditions, v1beta1.PreRestoreHookExecutionSucceeded) || + kmapi.IsConditionFalse(status.Conditions, v1beta1.PostRestoreHookExecutionSucceeded) { + return v1beta1.RestoreFailed + } + + if len(status.Conditions) == 0 || isAllTargetRestorePending([]v1beta1.RestoreMemberStatus{status}) { return v1beta1.RestorePending } - if kmapi.IsConditionFalse(status.Conditions, apis.ValidationPassed) { - return v1beta1.RestorePhaseInvalid + if RestoreCompletedForAllTargets([]v1beta1.RestoreMemberStatus{status}) { + if status.Phase == v1beta1.TargetRestorePhaseUnknown { + return v1beta1.RestorePhaseUnknown + } + + if status.Phase == v1beta1.TargetRestoreFailed || + kmapi.IsConditionFalse(status.Conditions, v1beta1.MetricsPushed) { + return v1beta1.RestoreFailed + } + + if kmapi.IsConditionTrue(status.Conditions, v1beta1.MetricsPushed) { + return v1beta1.RestoreSucceeded + } } - switch status.Phase { - case v1beta1.TargetRestorePending: + if status.Phase == v1beta1.TargetRestorePending || + kmapi.IsConditionFalse(status.Conditions, v1beta1.RepositoryFound) || + kmapi.IsConditionFalse(status.Conditions, v1beta1.BackendSecretFound) || + kmapi.IsConditionFalse(status.Conditions, v1beta1.RestoreTargetFound) { return v1beta1.RestorePending - case v1beta1.TargetRestoreSucceeded: - return v1beta1.RestoreSucceeded - case v1beta1.TargetRestoreFailed: - return v1beta1.RestoreFailed - case v1beta1.TargetRestorePhaseUnknown: - return v1beta1.RestorePhaseUnknown - default: - return v1beta1.RestoreRunning } + + if kmapi.IsConditionFalse(status.Conditions, v1beta1.ValidationPassed) { + return v1beta1.RestorePhaseInvalid + } + + return v1beta1.RestoreRunning +} + +func RestoreCompletedForAllTargets(status []v1beta1.RestoreMemberStatus) bool { + for _, t := range status { + if t.TotalHosts == nil || !restoreCompletedForAllHosts(t.Stats, *t.TotalHosts) { + return false + } + } + return len(status) > 0 +} + +func restoreCompletedForAllHosts(status []v1beta1.HostRestoreStats, totalHosts int32) bool { + for _, h := range status { + if !hostRestoreCompleted(h.Phase) { + return false + } + } + return len(status) == int(totalHosts) +} + +func hostRestoreCompleted(phase v1beta1.HostRestorePhase) bool { + return phase == v1beta1.HostRestoreSucceeded || + phase == v1beta1.HostRestoreFailed || + phase == v1beta1.HostRestoreUnknown +} + +func isAllTargetRestorePending(status []v1beta1.RestoreMemberStatus) bool { + for _, m := range status { + if m.Phase != v1beta1.TargetRestorePending { + return false + } + } + return true } diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/restic/backup.go b/vendor/stash.appscode.dev/apimachinery/pkg/restic/backup.go index 7c0bfedc4..d5d06437c 100644 --- a/vendor/stash.appscode.dev/apimachinery/pkg/restic/backup.go +++ b/vendor/stash.appscode.dev/apimachinery/pkg/restic/backup.go @@ -82,7 +82,6 @@ func (w *ResticWrapper) RunParallelBackup(backupOptions []BackupOptions, targetR wg.Add(1) go func(opt BackupOptions, startTime time.Time) { - // when this go routine completes it task, release a slot from the concurrencyLimiter channel // so that another go routine can start. Also, tell the WaitGroup that it is done with its task. defer func() { @@ -126,7 +125,7 @@ func (w *ResticWrapper) runBackup(backupOption BackupOptions) (api_v1beta1.HostB Hostname: backupOption.Host, } - //fmt.Println("shell: ",w) + // fmt.Println("shell: ",w) // Backup from stdin if len(backupOption.StdinPipeCommands) != 0 { out, err := w.backupFromStdin(backupOption) @@ -179,7 +178,6 @@ func upsertSnapshotStats(hostStats api_v1beta1.HostBackupStats, snapStats api_v1 } func (backupOutput *BackupOutput) upsertHostBackupStats(hostStats api_v1beta1.HostBackupStats) { - // check if a entry already exist for this host in backupOutput. If exist then update it. for i, v := range backupOutput.BackupTargetStatus.Stats { if v.Hostname == hostStats.Hostname { diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/restic/config.go b/vendor/stash.appscode.dev/apimachinery/pkg/restic/config.go index d80ed86d5..cde197533 100644 --- a/vendor/stash.appscode.dev/apimachinery/pkg/restic/config.go +++ b/vendor/stash.appscode.dev/apimachinery/pkg/restic/config.go @@ -145,8 +145,9 @@ func (w *ResticWrapper) GetEnv(key string) string { func (w *ResticWrapper) GetCaPath() string { return w.config.CacertFile } + func (w *ResticWrapper) DumpEnv(path string, dumpedFile string) error { - if err := os.MkdirAll(path, 0755); err != nil { + if err := os.MkdirAll(path, 0o755); err != nil { return err } @@ -156,13 +157,13 @@ func (w *ResticWrapper) DumpEnv(path string, dumpedFile string) error { for k := range w.sh.Env { sortedKeys = append(sortedKeys, k) } - sort.Strings(sortedKeys) //sort by key + sort.Strings(sortedKeys) // sort by key for _, v := range sortedKeys { envs = envs + fmt.Sprintln(v+"="+w.sh.Env[v]) } } - if err := ioutil.WriteFile(filepath.Join(path, dumpedFile), []byte(envs), 0600); err != nil { + if err := ioutil.WriteFile(filepath.Join(path, dumpedFile), []byte(envs), 0o600); err != nil { return err } return nil @@ -196,9 +197,9 @@ func (w *ResticWrapper) Copy() *ResticWrapper { out.sh.Env[k] = v } // don't use same stdin, stdout, stderr for each instant to avoid data race. - //out.sh.Stdin = in.sh.Stdin - //out.sh.Stdout = in.sh.Stdout - //out.sh.Stderr = in.sh.Stderr + // out.sh.Stdin = in.sh.Stdin + // out.sh.Stdout = in.sh.Stdout + // out.sh.Stderr = in.sh.Stderr out.sh.ShowCMD = w.sh.ShowCMD out.sh.PipeFail = w.sh.PipeFail out.sh.PipeStdErrors = w.sh.PipeStdErrors diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/restic/output.go b/vendor/stash.appscode.dev/apimachinery/pkg/restic/output.go index cfbd77685..cae3da7ec 100644 --- a/vendor/stash.appscode.dev/apimachinery/pkg/restic/output.go +++ b/vendor/stash.appscode.dev/apimachinery/pkg/restic/output.go @@ -30,7 +30,7 @@ import ( api_v1beta1 "stash.appscode.dev/apimachinery/apis/stash/v1beta1" ) -const FileModeRWXAll = 0777 +const FileModeRWXAll = 0o777 type BackupOutput struct { // BackupTargetStatus shows the status of a backup target @@ -53,7 +53,7 @@ type RestoreOutput struct { RestoreTargetStatus api_v1beta1.RestoreMemberStatus `json:"targetStatus,omitempty"` } -// WriteOutput write output of backup process into output.json file in the directory +// WriteOutput write output of backup process into output.go file in the directory // specified by outputDir parameter func (out *BackupOutput) WriteOutput(fileName string) error { jsonOutput, err := json.MarshalIndent(out, "", " ") diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/restic/restore.go b/vendor/stash.appscode.dev/apimachinery/pkg/restic/restore.go index 36aac0077..82a4d6362 100644 --- a/vendor/stash.appscode.dev/apimachinery/pkg/restic/restore.go +++ b/vendor/stash.appscode.dev/apimachinery/pkg/restic/restore.go @@ -56,7 +56,6 @@ func (w *ResticWrapper) RunRestore(restoreOptions RestoreOptions, targetRef api_ // RunParallelRestore run restore process for multiple hosts in parallel using go routine. // You can control maximum number of parallel restore using maxConcurrency parameter. func (w *ResticWrapper) RunParallelRestore(restoreOptions []RestoreOptions, targetRef api_v1beta1.TargetRef, maxConcurrency int) (*RestoreOutput, error) { - // WaitGroup to wait until all go routine finish wg := sync.WaitGroup{} // concurrencyLimiter channel is used to limit maximum number simultaneous go routine @@ -154,7 +153,6 @@ func (w *ResticWrapper) Dump(dumpOptions DumpOptions, targetRef api_v1beta1.Targ // ParallelDump run dump for multiple hosts concurrently using go routine. // You can control maximum number of parallel restore process using maxConcurrency parameter. func (w *ResticWrapper) ParallelDump(dumpOptions []DumpOptions, targetRef api_v1beta1.TargetRef, maxConcurrency int) (*RestoreOutput, error) { - // WaitGroup to wait until all go routine finish wg := sync.WaitGroup{} // concurrencyLimiter channel is used to limit maximum number simultaneous go routine @@ -258,7 +256,6 @@ func (w *ResticWrapper) runRestore(restoreOptions RestoreOptions) error { } func (restoreOutput *RestoreOutput) upsertHostRestoreStats(hostStats api_v1beta1.HostRestoreStats) { - // check if a entry already exist for this host in restoreOutput. If exist then update it. for i, v := range restoreOutput.RestoreTargetStatus.Stats { if v.Hostname == hostStats.Hostname { diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/restic/setup.go b/vendor/stash.appscode.dev/apimachinery/pkg/restic/setup.go index 494a50fa0..37450b069 100644 --- a/vendor/stash.appscode.dev/apimachinery/pkg/restic/setup.go +++ b/vendor/stash.appscode.dev/apimachinery/pkg/restic/setup.go @@ -111,18 +111,18 @@ func (w *ResticWrapper) setupEnv() error { if w.config.EnableCache { cacheDir := filepath.Join(w.config.ScratchDir, resticCacheDir) - if err := os.MkdirAll(cacheDir, 0755); err != nil { + if err := os.MkdirAll(cacheDir, 0o755); err != nil { return err } } - //path = strings.TrimPrefix(path, "/") + // path = strings.TrimPrefix(path, "/") switch w.config.Provider { case storage.ProviderLocal: r := w.config.Bucket - if err := os.MkdirAll(r, 0755); err != nil { + if err := os.MkdirAll(r, 0o755); err != nil { return err } w.sh.SetEnv(RESTIC_REPOSITORY, r) @@ -131,11 +131,11 @@ func (w *ResticWrapper) setupEnv() error { r := fmt.Sprintf("s3:%s/%s", w.config.Endpoint, filepath.Join(w.config.Bucket, w.config.Path)) w.sh.SetEnv(RESTIC_REPOSITORY, r) - if err := w.exportSecretKey(AWS_ACCESS_KEY_ID, true); err != nil { + if err := w.exportSecretKey(AWS_ACCESS_KEY_ID, false); err != nil { return err } - if err := w.exportSecretKey(AWS_SECRET_ACCESS_KEY, true); err != nil { + if err := w.exportSecretKey(AWS_SECRET_ACCESS_KEY, false); err != nil { return err } @@ -147,25 +147,26 @@ func (w *ResticWrapper) setupEnv() error { r := fmt.Sprintf("gs:%s:/%s", w.config.Bucket, w.config.Path) w.sh.SetEnv(RESTIC_REPOSITORY, r) - if err := w.exportSecretKey(GOOGLE_PROJECT_ID, true); err != nil { + if err := w.exportSecretKey(GOOGLE_PROJECT_ID, false); err != nil { return err } - filePath, err := w.writeSecretKeyToFile(GOOGLE_SERVICE_ACCOUNT_JSON_KEY, GOOGLE_SERVICE_ACCOUNT_JSON_KEY) - if err != nil { - return err + if w.isSecretKeyExist(GOOGLE_SERVICE_ACCOUNT_JSON_KEY) { + filePath, err := w.writeSecretKeyToFile(GOOGLE_SERVICE_ACCOUNT_JSON_KEY, GOOGLE_SERVICE_ACCOUNT_JSON_KEY) + if err != nil { + return err + } + w.sh.SetEnv(GOOGLE_APPLICATION_CREDENTIALS, filePath) } - w.sh.SetEnv(GOOGLE_APPLICATION_CREDENTIALS, filePath) - case storage.ProviderAzure: r := fmt.Sprintf("azure:%s:/%s", w.config.Bucket, w.config.Path) w.sh.SetEnv(RESTIC_REPOSITORY, r) - if err := w.exportSecretKey(AZURE_ACCOUNT_NAME, true); err != nil { + if err := w.exportSecretKey(AZURE_ACCOUNT_NAME, false); err != nil { return err } - if err := w.exportSecretKey(AZURE_ACCOUNT_KEY, true); err != nil { + if err := w.exportSecretKey(AZURE_ACCOUNT_KEY, false); err != nil { return err } @@ -323,6 +324,11 @@ func (w *ResticWrapper) exportSecretKey(key string, required bool) error { return nil } +func (w *ResticWrapper) isSecretKeyExist(key string) bool { + _, ok := w.config.StorageSecret.Data[key] + return ok +} + func (w *ResticWrapper) writeSecretKeyToFile(key, name string) (string, error) { v, ok := w.config.StorageSecret.Data[key] if !ok { @@ -332,7 +338,7 @@ func (w *ResticWrapper) writeSecretKeyToFile(key, name string) (string, error) { tmpDir := w.GetEnv(TMPDIR) filePath := filepath.Join(tmpDir, name) - if err := ioutil.WriteFile(filePath, v, 0755); err != nil { + if err := ioutil.WriteFile(filePath, v, 0o755); err != nil { return "", err } return filePath, nil diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/restic/snapshot.go b/vendor/stash.appscode.dev/apimachinery/pkg/restic/snapshot.go index 727869339..b41dc0021 100644 --- a/vendor/stash.appscode.dev/apimachinery/pkg/restic/snapshot.go +++ b/vendor/stash.appscode.dev/apimachinery/pkg/restic/snapshot.go @@ -39,5 +39,4 @@ func (w *ResticWrapper) GetSnapshotSize(snapshotID string) (uint64, error) { return 0, err } return stat.TotalSize, nil - } diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/util/backup.go b/vendor/stash.appscode.dev/apimachinery/pkg/util/backup.go index a18b1f163..e207666d9 100644 --- a/vendor/stash.appscode.dev/apimachinery/pkg/util/backup.go +++ b/vendor/stash.appscode.dev/apimachinery/pkg/util/backup.go @@ -21,7 +21,6 @@ import ( "fmt" "time" - "stash.appscode.dev/apimachinery/apis" "stash.appscode.dev/apimachinery/apis/stash/v1beta1" cs "stash.appscode.dev/apimachinery/client/clientset/versioned" "stash.appscode.dev/apimachinery/pkg/conditions" @@ -29,7 +28,6 @@ import ( "stash.appscode.dev/apimachinery/pkg/restic" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/errors" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/klog/v2" kmapi "kmodules.xyz/client-go/api/v1" @@ -49,35 +47,37 @@ func ExecutePreBackupActions(opt ActionOptions) error { if err != nil { return err } - for _, targetStatus := range backupSession.Status.Targets { - if invoker.TargetMatched(targetStatus.Ref, opt.TargetRef) { - // check if it has any pre-backup action assigned to it - if len(targetStatus.PreBackupActions) > 0 { - // execute the pre-backup actions - for _, action := range targetStatus.PreBackupActions { - switch action { - case apis.InitializeBackendRepository: - if !kmapi.HasCondition(backupSession.Status.Conditions, apis.BackendRepositoryInitialized) { - err := initializeBackendRepository(opt.SetupOptions) - if err != nil { - _, condErr := conditions.SetBackendRepositoryInitializedConditionToFalse(opt.StashClient, backupSession, err) - return errors.NewAggregate([]error{err, condErr}) - } - _, condErr := conditions.SetBackendRepositoryInitializedConditionToTrue(opt.StashClient, backupSession) - if condErr != nil { - return condErr - } - } - default: - return fmt.Errorf("unknown PreBackupAction: %s", action) - } + session := invoker.NewBackupSessionHandler(opt.StashClient, backupSession) + + for _, targetStatus := range session.GetTargetStatus() { + if invoker.TargetMatched(targetStatus.Ref, opt.TargetRef) && len(targetStatus.PreBackupActions) > 0 { + return opt.executePreBackupActions(session, targetStatus) + } + } + return nil +} + +func (opt *ActionOptions) executePreBackupActions(session *invoker.BackupSessionHandler, targetStatus v1beta1.BackupTargetStatus) error { + for _, action := range targetStatus.PreBackupActions { + switch action { + case v1beta1.InitializeBackendRepository: + if !repoAlreadyInitialized(session) { + err := opt.initializeBackendRepository(session) + if err != nil { + return conditions.SetBackendRepositoryInitializedConditionToFalse(session, err) } } + default: + return fmt.Errorf("unknown PreBackupAction: %s", action) } } return nil } +func repoAlreadyInitialized(session *invoker.BackupSessionHandler) bool { + return kmapi.HasCondition(session.GetConditions(), v1beta1.BackendRepositoryInitialized) +} + // IsRepositoryInitialized check whether the backend restic repository has been initialized or not func IsRepositoryInitialized(opt ActionOptions) (bool, error) { backupSession, err := opt.StashClient.StashV1beta1().BackupSessions(opt.Namespace).Get(context.Background(), opt.BackupSessionName, metav1.GetOptions{}) @@ -85,12 +85,12 @@ func IsRepositoryInitialized(opt ActionOptions) (bool, error) { return false, err } // If the condition is not present, then the repository hasn't been initialized - if !kmapi.HasCondition(backupSession.Status.Conditions, apis.BackendRepositoryInitialized) { + if !kmapi.HasCondition(backupSession.Status.Conditions, v1beta1.BackendRepositoryInitialized) { return false, nil } // If the condition is present but it is set to "False", then the repository initialization has failed. Possibly due to invalid backend / storage secret. - if !kmapi.IsConditionTrue(backupSession.Status.Conditions, apis.BackendRepositoryInitialized) { - _, cnd := kmapi.GetCondition(backupSession.Status.Conditions, apis.BackendRepositoryInitialized) + if !kmapi.IsConditionTrue(backupSession.Status.Conditions, v1beta1.BackendRepositoryInitialized) { + _, cnd := kmapi.GetCondition(backupSession.Status.Conditions, v1beta1.BackendRepositoryInitialized) return false, fmt.Errorf(cnd.Reason) } return true, nil @@ -112,14 +112,17 @@ func WaitForBackendRepository(opt ActionOptions) error { }) } -func initializeBackendRepository(opts restic.SetupOptions) error { - w, err := restic.NewResticWrapper(opts) +func (opts *ActionOptions) initializeBackendRepository(session *invoker.BackupSessionHandler) error { + w, err := restic.NewResticWrapper(opts.SetupOptions) if err != nil { return err } // initialize repository if it doesn't exist if !w.RepositoryAlreadyExist() { - return w.InitializeRepository() + err = w.InitializeRepository() + if err != nil { + return err + } } - return nil + return conditions.SetBackendRepositoryInitializedConditionToTrue(session) }