diff --git a/go.mod b/go.mod index cb1d7be24..e15e65a9d 100644 --- a/go.mod +++ b/go.mod @@ -15,11 +15,11 @@ require ( k8s.io/apimachinery v0.25.1 k8s.io/client-go v0.25.1 k8s.io/klog/v2 v2.80.1 - kmodules.xyz/client-go v0.25.2 + kmodules.xyz/client-go v0.25.6 kmodules.xyz/custom-resources v0.25.0 kmodules.xyz/offshoot-api v0.25.0 kubedb.dev/apimachinery v0.28.4-0.20220918021210-a0b96812228b - stash.appscode.dev/apimachinery v0.22.1-0.20220917042332-522f4e18711d + stash.appscode.dev/apimachinery v0.23.0 ) require ( @@ -66,7 +66,7 @@ require ( golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect golang.org/x/net v0.0.0-20220909164309-bea034e7d591 // indirect golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094 // indirect - golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 // indirect + golang.org/x/sys v0.0.0-20220906135438-9e1f76180b77 // indirect golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 // indirect golang.org/x/text v0.3.7 // indirect golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9 // indirect @@ -85,6 +85,7 @@ require ( k8s.io/kube-aggregator v0.25.1 // indirect k8s.io/kube-openapi v0.0.0-20220803164354-a70c9af30aea // indirect k8s.io/utils v0.0.0-20220823124924-e9cbc92d1a73 // indirect + kmodules.xyz/apiversion v0.2.0 // indirect kmodules.xyz/objectstore-api v0.25.0 // indirect kmodules.xyz/prober v0.25.0 // indirect sigs.k8s.io/controller-runtime v0.13.0 // indirect diff --git a/go.sum b/go.sum index 79a441f7e..a211ace07 100644 --- a/go.sum +++ b/go.sum @@ -593,8 +593,8 @@ golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 h1:v6hYoSR9T5oet+pMXwUWkbiVqx/63mlHjefrHmxwfeY= -golang.org/x/sys v0.0.0-20220829200755-d48e67d00261/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220906135438-9e1f76180b77 h1:C1tElbkWrsSkn3IRl1GCW/gETw1TywWIPgwZtXTZbYg= +golang.org/x/sys v0.0.0-20220906135438-9e1f76180b77/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 h1:Q5284mrmYTpACcm+eAKjKJH48BBwSyfJqmmGDTtT8Vc= golang.org/x/term v0.0.0-20220722155259-a9ba230a4035/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -883,8 +883,10 @@ k8s.io/kube-openapi v0.0.0-20220803164354-a70c9af30aea h1:3QOH5+2fGsY8e1qf+GIFpg k8s.io/kube-openapi v0.0.0-20220803164354-a70c9af30aea/go.mod h1:C/N6wCaBHeBHkHUesQOQy2/MZqGgMAFPqGsGQLdbZBU= k8s.io/utils v0.0.0-20220823124924-e9cbc92d1a73 h1:H9TCJUUx+2VA0ZiD9lvtaX8fthFsMoD+Izn93E/hm8U= k8s.io/utils v0.0.0-20220823124924-e9cbc92d1a73/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= -kmodules.xyz/client-go v0.25.2 h1:Uav3RB85b3Pz2dhWI3VQR4XYjSSklpw8EFb88HHpMjI= -kmodules.xyz/client-go v0.25.2/go.mod h1:PQAVWlXoHmk/OXqIuUz3xEW5H04uidiLwVyGX0yYnBQ= +kmodules.xyz/apiversion v0.2.0 h1:vAQYqZFm4xu4pbB1cAdHbFEPES6EQkcR4wc06xdTOWk= +kmodules.xyz/apiversion v0.2.0/go.mod h1:oPX8g8LvlPdPX3Yc5YvCzJHQnw3YF/X4/jdW0b1am80= +kmodules.xyz/client-go v0.25.6 h1:59mMNoanKrqOFYqDMtqYU5caFxd+7YrfNqpvyKYWqNE= +kmodules.xyz/client-go v0.25.6/go.mod h1:NgLAVr+IEAFpI9g7FhZF5qG0SG+SBADxknWu5jp0m8M= kmodules.xyz/custom-resources v0.25.0 h1:5JQTEuiv6lC/+VVFNKqzfX4YtJCmN5E7mcNtGnHGVQM= kmodules.xyz/custom-resources v0.25.0/go.mod h1:ULwzvLmOqZJcPSXKI7iLclYL5eYRlKx8Nbex28Ht19E= kmodules.xyz/objectstore-api v0.25.0 h1:xT7+SXBqAMtVkfOdp4espHAfZ6MYUC4G1OgzTkURNnU= @@ -906,5 +908,5 @@ sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kF sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E= sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= -stash.appscode.dev/apimachinery v0.22.1-0.20220917042332-522f4e18711d h1:nGXRD7UTu0B1ifqKeSpcRsA8RPJa6/rGdtiVYUvoIHE= -stash.appscode.dev/apimachinery v0.22.1-0.20220917042332-522f4e18711d/go.mod h1:f1yvcracYbBFRbabEdX3VFhzgXjOLER2QFvyyBNdeik= +stash.appscode.dev/apimachinery v0.23.0 h1:wEOxoVsnF7LtOFxgQyvW+5dlVe8bw6kLhUm2LrQM41s= +stash.appscode.dev/apimachinery v0.23.0/go.mod h1:Tb1y/+h1r3+YdBvI5RYIC0tW1b8S+0pIb3iG0X7BOjo= diff --git a/vendor/golang.org/x/sys/unix/syscall_freebsd_386.go b/vendor/golang.org/x/sys/unix/syscall_freebsd_386.go index c3c4c698e..b11ede89a 100644 --- a/vendor/golang.org/x/sys/unix/syscall_freebsd_386.go +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd_386.go @@ -61,7 +61,7 @@ func PtraceGetFsBase(pid int, fsbase *int64) (err error) { } func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) { - ioDesc := PtraceIoDesc{Op: int32(req), Offs: (*byte)(unsafe.Pointer(addr)), Addr: (*byte)(unsafe.Pointer(&out[0])), Len: uint32(countin)} + ioDesc := PtraceIoDesc{Op: int32(req), Offs: uintptr(unsafe.Pointer(addr)), Addr: uintptr(unsafe.Pointer(&out[0])), Len: uint32(countin)} err = ptrace(PT_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0) return int(ioDesc.Len), err } diff --git a/vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go b/vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go index 82be61a2f..9ed8eec6c 100644 --- a/vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go @@ -61,7 +61,7 @@ func PtraceGetFsBase(pid int, fsbase *int64) (err error) { } func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) { - ioDesc := PtraceIoDesc{Op: int32(req), Offs: (*byte)(unsafe.Pointer(addr)), Addr: (*byte)(unsafe.Pointer(&out[0])), Len: uint64(countin)} + ioDesc := PtraceIoDesc{Op: int32(req), Offs: uintptr(unsafe.Pointer(addr)), Addr: uintptr(unsafe.Pointer(&out[0])), Len: uint64(countin)} err = ptrace(PT_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0) return int(ioDesc.Len), err } diff --git a/vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go b/vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go index cd58f1026..f8ac98247 100644 --- a/vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go @@ -57,7 +57,7 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) { - ioDesc := PtraceIoDesc{Op: int32(req), Offs: (*byte)(unsafe.Pointer(addr)), Addr: (*byte)(unsafe.Pointer(&out[0])), Len: uint32(countin)} + ioDesc := PtraceIoDesc{Op: int32(req), Offs: uintptr(unsafe.Pointer(addr)), Addr: uintptr(unsafe.Pointer(&out[0])), Len: uint32(countin)} err = ptrace(PT_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0) return int(ioDesc.Len), err } diff --git a/vendor/golang.org/x/sys/unix/syscall_freebsd_arm64.go b/vendor/golang.org/x/sys/unix/syscall_freebsd_arm64.go index d6f538f9e..8e932036e 100644 --- a/vendor/golang.org/x/sys/unix/syscall_freebsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd_arm64.go @@ -57,7 +57,7 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) { - ioDesc := PtraceIoDesc{Op: int32(req), Offs: (*byte)(unsafe.Pointer(addr)), Addr: (*byte)(unsafe.Pointer(&out[0])), Len: uint64(countin)} + ioDesc := PtraceIoDesc{Op: int32(req), Offs: uintptr(unsafe.Pointer(addr)), Addr: uintptr(unsafe.Pointer(&out[0])), Len: uint64(countin)} err = ptrace(PT_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0) return int(ioDesc.Len), err } diff --git a/vendor/golang.org/x/sys/unix/syscall_freebsd_riscv64.go b/vendor/golang.org/x/sys/unix/syscall_freebsd_riscv64.go index 8ea6e9610..cbe122278 100644 --- a/vendor/golang.org/x/sys/unix/syscall_freebsd_riscv64.go +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd_riscv64.go @@ -57,7 +57,7 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) { - ioDesc := PtraceIoDesc{Op: int32(req), Offs: (*byte)(unsafe.Pointer(addr)), Addr: (*byte)(unsafe.Pointer(&out[0])), Len: uint64(countin)} + ioDesc := PtraceIoDesc{Op: int32(req), Offs: uintptr(unsafe.Pointer(addr)), Addr: uintptr(unsafe.Pointer(&out[0])), Len: uint64(countin)} err = ptrace(PT_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0) return int(ioDesc.Len), err } diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go index dea0c9a60..d9c78cdcb 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go @@ -294,7 +294,7 @@ type PtraceLwpInfoStruct struct { Flags int32 Sigmask Sigset_t Siglist Sigset_t - Siginfo __Siginfo + Siginfo __PtraceSiginfo Tdname [20]int8 Child_pid int32 Syscall_code uint32 @@ -312,6 +312,17 @@ type __Siginfo struct { Value [4]byte _ [32]byte } +type __PtraceSiginfo struct { + Signo int32 + Errno int32 + Code int32 + Pid int32 + Uid uint32 + Status int32 + Addr uintptr + Value [4]byte + _ [32]byte +} type Sigset_t struct { Val [4]uint32 @@ -350,8 +361,8 @@ type FpExtendedPrecision struct{} type PtraceIoDesc struct { Op int32 - Offs *byte - Addr *byte + Offs uintptr + Addr uintptr Len uint32 } diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go index da0ea0d60..26991b165 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go @@ -291,7 +291,7 @@ type PtraceLwpInfoStruct struct { Flags int32 Sigmask Sigset_t Siglist Sigset_t - Siginfo __Siginfo + Siginfo __PtraceSiginfo Tdname [20]int8 Child_pid int32 Syscall_code uint32 @@ -310,6 +310,18 @@ type __Siginfo struct { _ [40]byte } +type __PtraceSiginfo struct { + Signo int32 + Errno int32 + Code int32 + Pid int32 + Uid uint32 + Status int32 + Addr uintptr + Value [8]byte + _ [40]byte +} + type Sigset_t struct { Val [4]uint32 } @@ -354,8 +366,8 @@ type FpExtendedPrecision struct{} type PtraceIoDesc struct { Op int32 - Offs *byte - Addr *byte + Offs uintptr + Addr uintptr Len uint64 } diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go index da8f74045..f8324e7e7 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go @@ -293,7 +293,7 @@ type PtraceLwpInfoStruct struct { Flags int32 Sigmask Sigset_t Siglist Sigset_t - Siginfo __Siginfo + Siginfo __PtraceSiginfo Tdname [20]int8 Child_pid int32 Syscall_code uint32 @@ -312,6 +312,18 @@ type __Siginfo struct { _ [32]byte } +type __PtraceSiginfo struct { + Signo int32 + Errno int32 + Code int32 + Pid int32 + Uid uint32 + Status int32 + Addr uintptr + Value [4]byte + _ [32]byte +} + type Sigset_t struct { Val [4]uint32 } @@ -337,8 +349,8 @@ type FpExtendedPrecision struct { type PtraceIoDesc struct { Op int32 - Offs *byte - Addr *byte + Offs uintptr + Addr uintptr Len uint32 } diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go index d69988e5e..4220411f3 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go @@ -291,7 +291,7 @@ type PtraceLwpInfoStruct struct { Flags int32 Sigmask Sigset_t Siglist Sigset_t - Siginfo __Siginfo + Siginfo __PtraceSiginfo Tdname [20]int8 Child_pid int32 Syscall_code uint32 @@ -310,6 +310,18 @@ type __Siginfo struct { _ [40]byte } +type __PtraceSiginfo struct { + Signo int32 + Errno int32 + Code int32 + Pid int32 + Uid uint32 + Status int32 + Addr uintptr + Value [8]byte + _ [40]byte +} + type Sigset_t struct { Val [4]uint32 } @@ -334,8 +346,8 @@ type FpExtendedPrecision struct{} type PtraceIoDesc struct { Op int32 - Offs *byte - Addr *byte + Offs uintptr + Addr uintptr Len uint64 } diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_riscv64.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_riscv64.go index d6fd9e883..0660fd45c 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_riscv64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_riscv64.go @@ -291,7 +291,7 @@ type PtraceLwpInfoStruct struct { Flags int32 Sigmask Sigset_t Siglist Sigset_t - Siginfo __Siginfo + Siginfo __PtraceSiginfo Tdname [20]int8 Child_pid int32 Syscall_code uint32 @@ -310,6 +310,18 @@ type __Siginfo struct { _ [40]byte } +type __PtraceSiginfo struct { + Signo int32 + Errno int32 + Code int32 + Pid int32 + Uid uint32 + Status int32 + Addr uintptr + Value [8]byte + _ [40]byte +} + type Sigset_t struct { Val [4]uint32 } @@ -335,8 +347,8 @@ type FpExtendedPrecision struct{} type PtraceIoDesc struct { Op int32 - Offs *byte - Addr *byte + Offs uintptr + Addr uintptr Len uint64 } diff --git a/vendor/kmodules.xyz/apiversion/.gitignore b/vendor/kmodules.xyz/apiversion/.gitignore new file mode 100644 index 000000000..2928ec4ae --- /dev/null +++ b/vendor/kmodules.xyz/apiversion/.gitignore @@ -0,0 +1,16 @@ +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Dependency directories (remove the comment below to include it) +vendor/ +.idea/ diff --git a/vendor/kmodules.xyz/apiversion/LICENSE b/vendor/kmodules.xyz/apiversion/LICENSE new file mode 100644 index 000000000..261eeb9e9 --- /dev/null +++ b/vendor/kmodules.xyz/apiversion/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/vendor/kmodules.xyz/apiversion/README.md b/vendor/kmodules.xyz/apiversion/README.md new file mode 100644 index 000000000..52a126e16 --- /dev/null +++ b/vendor/kmodules.xyz/apiversion/README.md @@ -0,0 +1,3 @@ +# apiversion + +A Go library for parsing and comparing versions like `v1alpha1` `v1beta1`, `v1rc1` and `v1` commonly found in Kubernetes. diff --git a/vendor/kmodules.xyz/apiversion/lib.go b/vendor/kmodules.xyz/apiversion/lib.go new file mode 100644 index 000000000..e2c0de8d6 --- /dev/null +++ b/vendor/kmodules.xyz/apiversion/lib.go @@ -0,0 +1,110 @@ +package apiversion + +import ( + "fmt" + "regexp" + "strconv" +) + +type Version struct { + X int + Y string + Z int +} + +type InvalidVersion struct { + v string +} + +func (e InvalidVersion) Error() string { + return fmt.Sprintf("invalid version %s", e.v) +} + +var ( + re = regexp.MustCompile(`^v(\d+)(alpha|beta|rc)?(\d*)$`) +) + +func NewVersion(s string) (*Version, error) { + groups := re.FindStringSubmatch(s) + if len(groups) == 0 { + return nil, InvalidVersion{v: s} + } + + var out Version + + x, err := strconv.Atoi(groups[1]) + if err != nil { + return nil, err + } + out.X = x + + out.Y = groups[2] + + if groups[3] != "" { + z, err := strconv.Atoi(groups[3]) + if err != nil { + return nil, err + } + out.Z = z + } + + return &out, nil +} + +// Compare returns an integer comparing two version strings. +// The result will be 0 if v==other, -1 if v < other, and +1 if v > other. +func (v Version) Compare(other Version) int { + diffX := v.X - other.X + switch { + case diffX > 0: + return 1 + case diffX < 0: + return -1 + } + + if v.Y != other.Y { + if v.Y == "" { + return 1 + } else if other.Y == "" { + return -1 + } else if v.Y > other.Y { + return 1 + } else { + return -1 + } + } + + diffZ := v.Z - other.Z + switch { + case diffZ > 0: + return 1 + case diffZ < 0: + return -1 + } + return 0 +} + +// Compare returns an integer comparing two version strings. +// The result will be 0 if x==y, -1 if x < y, and +1 if x > y. +// An error is returned, if version string can't be parsed. +func Compare(x, y string) (int, error) { + xv, err := NewVersion(x) + if err != nil { + return 0, err + } + yv, err := NewVersion(y) + if err != nil { + return 0, err + } + return xv.Compare(*yv), nil +} + +// MustCompare returns an integer comparing two version strings. +// The result will be 0 if x==y, -1 if x < y, and +1 if x > y. +func MustCompare(x, y string) int { + result, err := Compare(x, y) + if err != nil { + panic(err) + } + return result +} diff --git a/vendor/kmodules.xyz/client-go/discovery/lib.go b/vendor/kmodules.xyz/client-go/discovery/lib.go index de9c01bb8..dd425b63c 100644 --- a/vendor/kmodules.xyz/client-go/discovery/lib.go +++ b/vendor/kmodules.xyz/client-go/discovery/lib.go @@ -19,6 +19,8 @@ package discovery import ( "context" "fmt" + "sort" + "strings" "github.com/Masterminds/semver/v3" "github.com/pkg/errors" @@ -27,6 +29,7 @@ import ( "k8s.io/client-go/discovery" "k8s.io/client-go/kubernetes" "k8s.io/klog/v2" + "kmodules.xyz/apiversion" ) func GetVersion(client discovery.DiscoveryInterface) (string, error) { @@ -102,7 +105,7 @@ func IsPreferredAPIResource(client discovery.DiscoveryInterface, groupVersion, k continue } for _, resource := range resources.APIResources { - if resource.Kind == kind { + if resource.Kind == kind && !strings.ContainsRune(resource.Name, '/') { return true } } @@ -112,13 +115,13 @@ func IsPreferredAPIResource(client discovery.DiscoveryInterface, groupVersion, k } func ExistsGroupVersionKind(client discovery.DiscoveryInterface, groupVersion, kind string) bool { - if _, resourceList, err := client.ServerGroupsAndResources(); discovery.IsGroupDiscoveryFailedError(err) || err == nil { + if resourceList, err := client.ServerPreferredResources(); discovery.IsGroupDiscoveryFailedError(err) || err == nil { for _, resources := range resourceList { if resources.GroupVersion != groupVersion { continue } for _, resource := range resources.APIResources { - if resource.Kind == kind { + if resource.Kind == kind && !strings.ContainsRune(resource.Name, '/') { return true } } @@ -128,7 +131,7 @@ func ExistsGroupVersionKind(client discovery.DiscoveryInterface, groupVersion, k } func ExistsGroupKind(client discovery.DiscoveryInterface, group, kind string) bool { - if _, resourceList, err := client.ServerGroupsAndResources(); discovery.IsGroupDiscoveryFailedError(err) || err == nil { + if resourceList, err := client.ServerPreferredResources(); discovery.IsGroupDiscoveryFailedError(err) || err == nil { for _, resources := range resourceList { gv, err := schema.ParseGroupVersion(resources.GroupVersion) if err != nil { @@ -138,7 +141,7 @@ func ExistsGroupKind(client discovery.DiscoveryInterface, group, kind string) bo continue } for _, resource := range resources.APIResources { - if resource.Kind == kind { + if resource.Kind == kind && !strings.ContainsRune(resource.Name, '/') { return true } } @@ -154,7 +157,7 @@ func ExistsGroupKinds(client discovery.DiscoveryInterface, gk schema.GroupKind, desired[other] = false } - if _, resourceList, err := client.ServerGroupsAndResources(); discovery.IsGroupDiscoveryFailedError(err) || err == nil { + if resourceList, err := client.ServerPreferredResources(); discovery.IsGroupDiscoveryFailedError(err) || err == nil { for _, resources := range resourceList { gv, err := schema.ParseGroupVersion(resources.GroupVersion) if err != nil { @@ -279,3 +282,48 @@ func checkVersion(v *semver.Version, multiMaster bool, constraint string, blackL } return nil } + +func HasGVK(client discovery.DiscoveryInterface, groupVersion, kind string) (bool, error) { + _, resourceList, err := client.ServerGroupsAndResources() + if discovery.IsGroupDiscoveryFailedError(err) || err == nil { + for _, resources := range resourceList { + if resources.GroupVersion != groupVersion { + continue + } + for _, resource := range resources.APIResources { + if resource.Kind == kind && !strings.ContainsRune(resource.Name, '/') { + return true, nil + } + } + } + } + return false, err +} + +func ListAPIVersions(c discovery.DiscoveryInterface, group, kind string) ([]string, error) { + _, resourceList, err := c.ServerGroupsAndResources() + + out := make([]string, 0) + if discovery.IsGroupDiscoveryFailedError(err) || err == nil { + for _, resources := range resourceList { + gv, err := schema.ParseGroupVersion(resources.GroupVersion) + if err != nil { + return nil, err + } + if gv.Group != group { + continue + } + for _, resource := range resources.APIResources { + if resource.Kind == kind && !strings.ContainsRune(resource.Name, '/') { + out = append(out, gv.Version) + } + } + } + } + if len(out) > 1 { + sort.Slice(out, func(i, j int) bool { + return apiversion.MustCompare(out[i], out[j]) > 0 + }) + } + return out, nil +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 9aa340674..11ec25756 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -175,7 +175,7 @@ golang.org/x/oauth2/google/internal/externalaccount golang.org/x/oauth2/internal golang.org/x/oauth2/jws golang.org/x/oauth2/jwt -# golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 +# golang.org/x/sys v0.0.0-20220906135438-9e1f76180b77 ## explicit; go 1.17 golang.org/x/sys/internal/unsafeheader golang.org/x/sys/plan9 @@ -607,7 +607,10 @@ k8s.io/utils/net k8s.io/utils/pointer k8s.io/utils/strings/slices k8s.io/utils/trace -# kmodules.xyz/client-go v0.25.2 +# kmodules.xyz/apiversion v0.2.0 +## explicit; go 1.14 +kmodules.xyz/apiversion +# kmodules.xyz/client-go v0.25.6 ## explicit; go 1.18 kmodules.xyz/client-go kmodules.xyz/client-go/api/v1 @@ -665,7 +668,7 @@ sigs.k8s.io/structured-merge-diff/v4/value # sigs.k8s.io/yaml v1.3.0 ## explicit; go 1.12 sigs.k8s.io/yaml -# stash.appscode.dev/apimachinery v0.22.1-0.20220917042332-522f4e18711d +# stash.appscode.dev/apimachinery v0.23.0 ## explicit; go 1.18 stash.appscode.dev/apimachinery/apis stash.appscode.dev/apimachinery/apis/repositories diff --git a/vendor/stash.appscode.dev/apimachinery/apis/constants.go b/vendor/stash.appscode.dev/apimachinery/apis/constants.go index 3428bb08b..1fbf3837b 100644 --- a/vendor/stash.appscode.dev/apimachinery/apis/constants.go +++ b/vendor/stash.appscode.dev/apimachinery/apis/constants.go @@ -227,3 +227,24 @@ const ( StashVolumeSnapshotRestorerClusterRole = "stash-vs-restorer-job" StashStorageClassReaderClusterRole = "stash-sc-reader" ) + +// =================== Keys for structure logging ===================== +const ( + ObjectKey = "key" + ObjectKind = "kind" + ObjectName = "name" + ObjectNamespace = "namespace" + + KeyTargetKind = "target_kind" + KeyTargetName = "target_name" + KeyTargetNamespace = "target_namespace" + + KeyInvokerKind = "invoker_kind" + KeyInvokerName = "invoker_name" + KeyInvokerNamespace = "invoker_namespace" + + KeyRepositoryName = "repo_name" + KeyRepositoryNamespace = "repo_namespace" + + KeyReason = "reason" +) diff --git a/vendor/stash.appscode.dev/apimachinery/apis/helpers.go b/vendor/stash.appscode.dev/apimachinery/apis/helpers.go new file mode 100644 index 000000000..1ce4db773 --- /dev/null +++ b/vendor/stash.appscode.dev/apimachinery/apis/helpers.go @@ -0,0 +1,42 @@ +/* +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 "strings" + +// ResourceShortForm takes a resource kind and returns the short form of the resource. +// xref: https://kubernetes.io/docs/reference/kubectl/overview/#resource-types +func ResourceShortForm(kind string) string { + switch kind { + case KindDeployment: + return "deploy" + case KindReplicationController: + return "rc" + case KindDaemonSet: + return "ds" + case KindStatefulSet: + return "sts" + case KindPersistentVolumeClaim: + return "pvc" + case KindPod: + return "po" + case KindAppBinding: + return "app" + default: + return strings.ToLower(kind) + } +} 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 f2779a26d..c7f7ce145 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 @@ -90,7 +90,12 @@ type BackupBatchSpec struct { // TimeOut specifies the maximum duration of backup. BackupBatch will be considered Failed // if backup does not complete within this time limit. By default, Stash don't set any timeout for backup. // +optional - TimeOut string `json:"timeOut,omitempty"` + TimeOut *metav1.Duration `json:"timeOut,omitempty"` + + // RetryConfig specify a configuration for retry a backup if it fails. + // By default, Stash does not retry any failed backup. + // +optional + RetryConfig *RetryConfig `json:"retryConfig,omitempty"` } type BackupBatchStatus struct { 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 6805c10d6..b3b11aa5b 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 @@ -88,7 +88,12 @@ type BackupBlueprintSpec struct { // TimeOut specifies the maximum duration of backup. BackupSession will be considered Failed // if backup does not complete within this time limit. By default, Stash don't set any timeout for backup. // +optional - TimeOut string `json:"timeOut,omitempty"` + TimeOut *metav1.Duration `json:"timeOut,omitempty"` + + // RetryConfig specify a configuration for retry a backup if it fails. + // By default, Stash does not retry any failed backup. + // +optional + RetryConfig *RetryConfig `json:"retryConfig,omitempty"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 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 49b58e63e..ef68d567f 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 @@ -103,7 +103,12 @@ type BackupConfigurationSpec struct { // TimeOut specifies the maximum duration of backup. BackupSession will be considered Failed // if backup does not complete within this time limit. By default, Stash don't set any timeout for backup. // +optional - TimeOut string `json:"timeOut,omitempty"` + TimeOut *metav1.Duration `json:"timeOut,omitempty"` + + // RetryConfig specify a configuration for retry a backup if it fails. + // By default, Stash does not retry any failed backup. + // +optional + RetryConfig *RetryConfig `json:"retryConfig,omitempty"` } // Hooks describes actions that Stash should take in response to backup sessions. For the PostBackup 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 1c341fa74..d6bd9467e 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 @@ -50,6 +50,11 @@ type BackupSessionSpec struct { // Invoker refers to the BackupConfiguration or BackupBatch being used to invoke this backup session // +optional Invoker BackupInvokerRef `json:"invoker,omitempty"` + + // RetryLeft specifies number of retry attempts left for the session. + // If this set to non-zero, Stash will create a new BackupSession if the current one fails. + // +optional + RetryLeft int32 `json:"retryLeft,omitempty"` } // +kubebuilder:validation:Enum=Pending;Skipped;Running;Succeeded;Failed;Unknown @@ -99,7 +104,17 @@ type BackupSessionStatus struct { // SessionDeadline specifies the deadline of backup. BackupSession will be // considered Failed if backup does not complete within this deadline // +optional - SessionDeadline metav1.Time `json:"sessionDeadline,omitempty"` + SessionDeadline *metav1.Time `json:"sessionDeadline,omitempty"` + + // Retried specifies whether this session was retried or not. + // This field will exist only if the `retryConfig` has been set in the respective backup invoker. + // +optional + Retried *bool `json:"retried,omitempty"` + + // NextRetry specifies the time when Stash should retry the current failed backup. + // This field will exist only if the `retryConfig` has been set in the respective backup invoker. + // +optional + NextRetry *metav1.Time `json:"nextRetry,omitempty"` } type BackupTargetStatus struct { 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 aa3223c36..71f67879b 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 @@ -439,6 +439,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "stash.appscode.dev/apimachinery/apis/stash/v1beta1.RestoreSessionStatus": schema_apimachinery_apis_stash_v1beta1_RestoreSessionStatus(ref), "stash.appscode.dev/apimachinery/apis/stash/v1beta1.RestoreTarget": schema_apimachinery_apis_stash_v1beta1_RestoreTarget(ref), "stash.appscode.dev/apimachinery/apis/stash/v1beta1.RestoreTargetSpec": schema_apimachinery_apis_stash_v1beta1_RestoreTargetSpec(ref), + "stash.appscode.dev/apimachinery/apis/stash/v1beta1.RetryConfig": schema_apimachinery_apis_stash_v1beta1_RetryConfig(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), @@ -19990,8 +19991,13 @@ func schema_apimachinery_apis_stash_v1beta1_BackupBatchSpec(ref common.Reference "timeOut": { SchemaProps: spec.SchemaProps{ Description: "TimeOut specifies the maximum duration of backup. BackupBatch will be considered Failed if backup does not complete within this time limit. By default, Stash don't set any timeout for backup.", - Type: []string{"string"}, - Format: "", + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Duration"), + }, + }, + "retryConfig": { + SchemaProps: spec.SchemaProps{ + Description: "RetryConfig specify a configuration for retry a backup if it fails. By default, Stash does not retry any failed backup.", + Ref: ref("stash.appscode.dev/apimachinery/apis/stash/v1beta1.RetryConfig"), }, }, }, @@ -19999,7 +20005,7 @@ func schema_apimachinery_apis_stash_v1beta1_BackupBatchSpec(ref common.Reference }, }, Dependencies: []string{ - "kmodules.xyz/client-go/api/v1.ObjectReference", "kmodules.xyz/offshoot-api/api/v1.RuntimeSettings", "stash.appscode.dev/apimachinery/apis/stash/v1alpha1.RetentionPolicy", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.BackupConfigurationTemplateSpec", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.BackupHooks"}, + "k8s.io/apimachinery/pkg/apis/meta/v1.Duration", "kmodules.xyz/client-go/api/v1.ObjectReference", "kmodules.xyz/offshoot-api/api/v1.RuntimeSettings", "stash.appscode.dev/apimachinery/apis/stash/v1alpha1.RetentionPolicy", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.BackupConfigurationTemplateSpec", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.BackupHooks", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.RetryConfig"}, } } @@ -20243,8 +20249,13 @@ func schema_apimachinery_apis_stash_v1beta1_BackupBlueprintSpec(ref common.Refer "timeOut": { SchemaProps: spec.SchemaProps{ Description: "TimeOut specifies the maximum duration of backup. BackupSession will be considered Failed if backup does not complete within this time limit. By default, Stash don't set any timeout for backup.", - Type: []string{"string"}, - Format: "", + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Duration"), + }, + }, + "retryConfig": { + SchemaProps: spec.SchemaProps{ + Description: "RetryConfig specify a configuration for retry a backup if it fails. By default, Stash does not retry any failed backup.", + Ref: ref("stash.appscode.dev/apimachinery/apis/stash/v1beta1.RetryConfig"), }, }, }, @@ -20252,7 +20263,7 @@ func schema_apimachinery_apis_stash_v1beta1_BackupBlueprintSpec(ref common.Refer }, }, Dependencies: []string{ - "kmodules.xyz/objectstore-api/api/v1.Backend", "kmodules.xyz/offshoot-api/api/v1.PersistentVolumeClaim", "kmodules.xyz/offshoot-api/api/v1.RuntimeSettings", "stash.appscode.dev/apimachinery/apis/stash/v1alpha1.RetentionPolicy", "stash.appscode.dev/apimachinery/apis/stash/v1alpha1.UsagePolicy", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.BackupHooks", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.EmptyDirSettings", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.TaskRef"}, + "k8s.io/apimachinery/pkg/apis/meta/v1.Duration", "kmodules.xyz/objectstore-api/api/v1.Backend", "kmodules.xyz/offshoot-api/api/v1.PersistentVolumeClaim", "kmodules.xyz/offshoot-api/api/v1.RuntimeSettings", "stash.appscode.dev/apimachinery/apis/stash/v1alpha1.RetentionPolicy", "stash.appscode.dev/apimachinery/apis/stash/v1alpha1.UsagePolicy", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.BackupHooks", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.EmptyDirSettings", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.RetryConfig", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.TaskRef"}, } } @@ -20439,8 +20450,13 @@ func schema_apimachinery_apis_stash_v1beta1_BackupConfigurationSpec(ref common.R "timeOut": { SchemaProps: spec.SchemaProps{ Description: "TimeOut specifies the maximum duration of backup. BackupSession will be considered Failed if backup does not complete within this time limit. By default, Stash don't set any timeout for backup.", - Type: []string{"string"}, - Format: "", + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Duration"), + }, + }, + "retryConfig": { + SchemaProps: spec.SchemaProps{ + Description: "RetryConfig specify a configuration for retry a backup if it fails. By default, Stash does not retry any failed backup.", + Ref: ref("stash.appscode.dev/apimachinery/apis/stash/v1beta1.RetryConfig"), }, }, }, @@ -20448,7 +20464,7 @@ func schema_apimachinery_apis_stash_v1beta1_BackupConfigurationSpec(ref common.R }, }, Dependencies: []string{ - "kmodules.xyz/client-go/api/v1.ObjectReference", "kmodules.xyz/offshoot-api/api/v1.PersistentVolumeClaim", "kmodules.xyz/offshoot-api/api/v1.RuntimeSettings", "stash.appscode.dev/apimachinery/apis/stash/v1alpha1.RetentionPolicy", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.BackupHooks", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.BackupTarget", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.EmptyDirSettings", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.TaskRef"}, + "k8s.io/apimachinery/pkg/apis/meta/v1.Duration", "kmodules.xyz/client-go/api/v1.ObjectReference", "kmodules.xyz/offshoot-api/api/v1.PersistentVolumeClaim", "kmodules.xyz/offshoot-api/api/v1.RuntimeSettings", "stash.appscode.dev/apimachinery/apis/stash/v1alpha1.RetentionPolicy", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.BackupHooks", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.BackupTarget", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.EmptyDirSettings", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.RetryConfig", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.TaskRef"}, } } @@ -20717,6 +20733,13 @@ func schema_apimachinery_apis_stash_v1beta1_BackupSessionSpec(ref common.Referen Ref: ref("stash.appscode.dev/apimachinery/apis/stash/v1beta1.BackupInvokerRef"), }, }, + "retryLeft": { + SchemaProps: spec.SchemaProps{ + Description: "RetryLeft specifies number of retry attempts left for the session. If this set to non-zero, Stash will create a new BackupSession if the current one fails.", + Type: []string{"integer"}, + Format: "int32", + }, + }, }, }, }, @@ -20776,7 +20799,19 @@ func schema_apimachinery_apis_stash_v1beta1_BackupSessionStatus(ref common.Refer "sessionDeadline": { SchemaProps: spec.SchemaProps{ Description: "SessionDeadline specifies the deadline of backup. BackupSession will be considered Failed if backup does not complete within this deadline", - Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), + }, + }, + "retried": { + SchemaProps: spec.SchemaProps{ + Description: "Retried specifies whether this session was retried or not. This field will exist only if the `retryConfig` has been set in the respective backup invoker.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "nextRetry": { + SchemaProps: spec.SchemaProps{ + Description: "NextRetry specifies the time when Stash should retry the current failed backup. This field will exist only if the `retryConfig` has been set in the respective backup invoker.", Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), }, }, @@ -21714,15 +21749,14 @@ func schema_apimachinery_apis_stash_v1beta1_RestoreBatchSpec(ref common.Referenc "timeOut": { SchemaProps: spec.SchemaProps{ Description: "TimeOut specifies the maximum duration of restore. RestoreBatch will be considered Failed if restore does not complete within this time limit. By default, Stash don't set any timeout for restore.", - Type: []string{"string"}, - Format: "", + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Duration"), }, }, }, }, }, Dependencies: []string{ - "kmodules.xyz/client-go/api/v1.ObjectReference", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.RestoreHooks", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.RestoreTargetSpec"}, + "k8s.io/apimachinery/pkg/apis/meta/v1.Duration", "kmodules.xyz/client-go/api/v1.ObjectReference", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.RestoreHooks", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.RestoreTargetSpec"}, } } @@ -21777,7 +21811,6 @@ func schema_apimachinery_apis_stash_v1beta1_RestoreBatchStatus(ref common.Refere "sessionDeadline": { SchemaProps: spec.SchemaProps{ Description: "SessionDeadline specifies the deadline of restore process. RestoreBatch will be considered Failed if restore does not complete within this deadline", - Default: map[string]interface{}{}, Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), }, }, @@ -22049,15 +22082,14 @@ func schema_apimachinery_apis_stash_v1beta1_RestoreSessionSpec(ref common.Refere "timeOut": { SchemaProps: spec.SchemaProps{ Description: "TimeOut specifies the maximum duration of restore. RestoreSession will be considered Failed if restore does not complete within this time limit. By default, Stash don't set any timeout for restore.", - Type: []string{"string"}, - Format: "", + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Duration"), }, }, }, }, }, Dependencies: []string{ - "kmodules.xyz/client-go/api/v1.ObjectReference", "kmodules.xyz/offshoot-api/api/v1.PersistentVolumeClaim", "kmodules.xyz/offshoot-api/api/v1.RuntimeSettings", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.EmptyDirSettings", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.RestoreHooks", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.RestoreTarget", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.Rule", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.TaskRef"}, + "k8s.io/apimachinery/pkg/apis/meta/v1.Duration", "kmodules.xyz/client-go/api/v1.ObjectReference", "kmodules.xyz/offshoot-api/api/v1.PersistentVolumeClaim", "kmodules.xyz/offshoot-api/api/v1.RuntimeSettings", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.EmptyDirSettings", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.RestoreHooks", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.RestoreTarget", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.Rule", "stash.appscode.dev/apimachinery/apis/stash/v1beta1.TaskRef"}, } } @@ -22119,7 +22151,6 @@ func schema_apimachinery_apis_stash_v1beta1_RestoreSessionStatus(ref common.Refe "sessionDeadline": { SchemaProps: spec.SchemaProps{ Description: "SessionDeadline specifies the deadline of restore process. RestoreSession will be considered Failed if restore does not complete within this deadline", - Default: map[string]interface{}{}, Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), }, }, @@ -22276,6 +22307,33 @@ func schema_apimachinery_apis_stash_v1beta1_RestoreTargetSpec(ref common.Referen } } +func schema_apimachinery_apis_stash_v1beta1_RetryConfig(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "maxRetry": { + SchemaProps: spec.SchemaProps{ + Description: "MaxRetry specifies the maximum number of attempts Stash should retry. Default value: 1", + Type: []string{"integer"}, + Format: "int32", + }, + }, + "delay": { + SchemaProps: spec.SchemaProps{ + Description: "The amount of time to wait before next retry. If you don't specify this field, Stash will retry immediately. Format: 30s, 2m, 1h etc.", + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Duration"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.Duration"}, + } +} + func schema_apimachinery_apis_stash_v1beta1_Rule(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 9c1327932..1169563e3 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 @@ -70,7 +70,7 @@ type RestoreBatchSpec struct { // TimeOut specifies the maximum duration of restore. RestoreBatch will be considered Failed // if restore does not complete within this time limit. By default, Stash don't set any timeout for restore. // +optional - TimeOut string `json:"timeOut,omitempty"` + TimeOut *metav1.Duration `json:"timeOut,omitempty"` } type RestoreBatchStatus struct { @@ -90,7 +90,7 @@ type RestoreBatchStatus struct { // SessionDeadline specifies the deadline of restore process. RestoreBatch will be // considered Failed if restore does not complete within this deadline // +optional - SessionDeadline metav1.Time `json:"sessionDeadline,omitempty"` + SessionDeadline *metav1.Time `json:"sessionDeadline,omitempty"` } // +kubebuilder:validation:Enum=Pending;Succeeded;Running;Failed 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 24f3c3f4f..40e84a728 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 @@ -65,7 +65,7 @@ type RestoreSessionSpec struct { // TimeOut specifies the maximum duration of restore. RestoreSession will be considered Failed // if restore does not complete within this time limit. By default, Stash don't set any timeout for restore. // +optional - TimeOut string `json:"timeOut,omitempty"` + TimeOut *metav1.Duration `json:"timeOut,omitempty"` } type RestoreTargetSpec struct { @@ -166,7 +166,7 @@ type RestoreSessionStatus struct { // SessionDeadline specifies the deadline of restore process. RestoreSession will be // considered Failed if restore does not complete within this deadline // +optional - SessionDeadline metav1.Time `json:"sessionDeadline,omitempty"` + SessionDeadline *metav1.Time `json:"sessionDeadline,omitempty"` } type HostRestoreStats struct { 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 321036a7b..08d9f4e09 100644 --- a/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/types.go +++ b/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/types.go @@ -18,6 +18,7 @@ package v1beta1 import ( core "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ofst "kmodules.xyz/offshoot-api/api/v1" ) @@ -150,3 +151,14 @@ const ( Parallel ExecutionOrder = "Parallel" Sequential ExecutionOrder = "Sequential" ) + +type RetryConfig struct { + // MaxRetry specifies the maximum number of attempts Stash should retry. Default value: 1 + // +kubebuilder:default=1 + MaxRetry int32 `json:"maxRetry,omitempty"` + + // The amount of time to wait before next retry. If you don't specify this field, Stash will retry immediately. + // Format: 30s, 2m, 1h etc. + // +optional + Delay metav1.Duration `json:"delay,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 2bcadfad8..33a3d7a35 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 @@ -23,9 +23,10 @@ package v1beta1 import ( corev1 "k8s.io/api/core/v1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" - v1 "kmodules.xyz/client-go/api/v1" - apiv1 "kmodules.xyz/offshoot-api/api/v1" + apiv1 "kmodules.xyz/client-go/api/v1" + offshootapiapiv1 "kmodules.xyz/offshoot-api/api/v1" proberapiv1 "kmodules.xyz/prober/api/v1" ) @@ -113,6 +114,16 @@ func (in *BackupBatchSpec) DeepCopyInto(out *BackupBatchSpec) { *out = new(BackupHooks) (*in).DeepCopyInto(*out) } + if in.TimeOut != nil { + in, out := &in.TimeOut, &out.TimeOut + *out = new(v1.Duration) + **out = **in + } + if in.RetryConfig != nil { + in, out := &in.RetryConfig, &out.RetryConfig + *out = new(RetryConfig) + **out = **in + } return } @@ -131,7 +142,7 @@ func (in *BackupBatchStatus) DeepCopyInto(out *BackupBatchStatus) { *out = *in if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions - *out = make([]v1.Condition, len(*in)) + *out = make([]apiv1.Condition, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -226,7 +237,7 @@ func (in *BackupBlueprintSpec) DeepCopyInto(out *BackupBlueprintSpec) { in.TempDir.DeepCopyInto(&out.TempDir) if in.InterimVolumeTemplate != nil { in, out := &in.InterimVolumeTemplate, &out.InterimVolumeTemplate - *out = new(apiv1.PersistentVolumeClaim) + *out = new(offshootapiapiv1.PersistentVolumeClaim) (*in).DeepCopyInto(*out) } if in.Hooks != nil { @@ -239,6 +250,16 @@ func (in *BackupBlueprintSpec) DeepCopyInto(out *BackupBlueprintSpec) { *out = new(int32) **out = **in } + if in.TimeOut != nil { + in, out := &in.TimeOut, &out.TimeOut + *out = new(v1.Duration) + **out = **in + } + if in.RetryConfig != nil { + in, out := &in.RetryConfig, &out.RetryConfig + *out = new(RetryConfig) + **out = **in + } return } @@ -324,6 +345,16 @@ func (in *BackupConfigurationSpec) DeepCopyInto(out *BackupConfigurationSpec) { *out = new(int32) **out = **in } + if in.TimeOut != nil { + in, out := &in.TimeOut, &out.TimeOut + *out = new(v1.Duration) + **out = **in + } + if in.RetryConfig != nil { + in, out := &in.RetryConfig, &out.RetryConfig + *out = new(RetryConfig) + **out = **in + } return } @@ -342,7 +373,7 @@ func (in *BackupConfigurationStatus) DeepCopyInto(out *BackupConfigurationStatus *out = *in if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions - *out = make([]v1.Condition, len(*in)) + *out = make([]apiv1.Condition, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -373,7 +404,7 @@ func (in *BackupConfigurationTemplateSpec) DeepCopyInto(out *BackupConfiguration in.TempDir.DeepCopyInto(&out.TempDir) if in.InterimVolumeTemplate != nil { in, out := &in.InterimVolumeTemplate, &out.InterimVolumeTemplate - *out = new(apiv1.PersistentVolumeClaim) + *out = new(offshootapiapiv1.PersistentVolumeClaim) (*in).DeepCopyInto(*out) } if in.Hooks != nil { @@ -526,12 +557,24 @@ func (in *BackupSessionStatus) DeepCopyInto(out *BackupSessionStatus) { } if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions - *out = make([]v1.Condition, len(*in)) + *out = make([]apiv1.Condition, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } - in.SessionDeadline.DeepCopyInto(&out.SessionDeadline) + if in.SessionDeadline != nil { + in, out := &in.SessionDeadline, &out.SessionDeadline + *out = (*in).DeepCopy() + } + if in.Retried != nil { + in, out := &in.Retried, &out.Retried + *out = new(bool) + **out = **in + } + if in.NextRetry != nil { + in, out := &in.NextRetry, &out.NextRetry + *out = (*in).DeepCopy() + } return } @@ -617,7 +660,7 @@ func (in *BackupTargetStatus) DeepCopyInto(out *BackupTargetStatus) { } if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions - *out = make([]v1.Condition, len(*in)) + *out = make([]apiv1.Condition, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -805,7 +848,7 @@ func (in *FunctionSpec) DeepCopyInto(out *FunctionSpec) { } if in.RuntimeSettings != nil { in, out := &in.RuntimeSettings, &out.RuntimeSettings - *out = new(apiv1.ContainerRuntimeSettings) + *out = new(offshootapiapiv1.ContainerRuntimeSettings) (*in).DeepCopyInto(*out) } return @@ -866,7 +909,7 @@ func (in *MemberConditions) DeepCopyInto(out *MemberConditions) { out.Target = in.Target if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions - *out = make([]v1.Condition, len(*in)) + *out = make([]apiv1.Condition, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -1019,6 +1062,11 @@ func (in *RestoreBatchSpec) DeepCopyInto(out *RestoreBatchSpec) { *out = new(RestoreHooks) (*in).DeepCopyInto(*out) } + if in.TimeOut != nil { + in, out := &in.TimeOut, &out.TimeOut + *out = new(v1.Duration) + **out = **in + } return } @@ -1037,7 +1085,7 @@ func (in *RestoreBatchStatus) DeepCopyInto(out *RestoreBatchStatus) { *out = *in if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions - *out = make([]v1.Condition, len(*in)) + *out = make([]apiv1.Condition, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -1049,7 +1097,10 @@ func (in *RestoreBatchStatus) DeepCopyInto(out *RestoreBatchStatus) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - in.SessionDeadline.DeepCopyInto(&out.SessionDeadline) + if in.SessionDeadline != nil { + in, out := &in.SessionDeadline, &out.SessionDeadline + *out = (*in).DeepCopy() + } return } @@ -1095,7 +1146,7 @@ func (in *RestoreMemberStatus) DeepCopyInto(out *RestoreMemberStatus) { out.Ref = in.Ref if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions - *out = make([]v1.Condition, len(*in)) + *out = make([]apiv1.Condition, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -1196,6 +1247,11 @@ func (in *RestoreSessionSpec) DeepCopyInto(out *RestoreSessionSpec) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.TimeOut != nil { + in, out := &in.TimeOut, &out.TimeOut + *out = new(v1.Duration) + **out = **in + } return } @@ -1224,12 +1280,15 @@ func (in *RestoreSessionStatus) DeepCopyInto(out *RestoreSessionStatus) { } if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions - *out = make([]v1.Condition, len(*in)) + *out = make([]apiv1.Condition, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } - in.SessionDeadline.DeepCopyInto(&out.SessionDeadline) + if in.SessionDeadline != nil { + in, out := &in.SessionDeadline, &out.SessionDeadline + *out = (*in).DeepCopy() + } return } @@ -1261,7 +1320,7 @@ func (in *RestoreTarget) DeepCopyInto(out *RestoreTarget) { } if in.VolumeClaimTemplates != nil { in, out := &in.VolumeClaimTemplates, &out.VolumeClaimTemplates - *out = make([]apiv1.PersistentVolumeClaim, len(*in)) + *out = make([]offshootapiapiv1.PersistentVolumeClaim, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -1304,7 +1363,7 @@ func (in *RestoreTargetSpec) DeepCopyInto(out *RestoreTargetSpec) { in.TempDir.DeepCopyInto(&out.TempDir) if in.InterimVolumeTemplate != nil { in, out := &in.InterimVolumeTemplate, &out.InterimVolumeTemplate - *out = new(apiv1.PersistentVolumeClaim) + *out = new(offshootapiapiv1.PersistentVolumeClaim) (*in).DeepCopyInto(*out) } if in.Hooks != nil { @@ -1325,6 +1384,23 @@ func (in *RestoreTargetSpec) DeepCopy() *RestoreTargetSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RetryConfig) DeepCopyInto(out *RetryConfig) { + *out = *in + out.Delay = in.Delay + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RetryConfig. +func (in *RetryConfig) DeepCopy() *RetryConfig { + if in == nil { + return nil + } + out := new(RetryConfig) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Rule) DeepCopyInto(out *Rule) { *out = *in diff --git a/vendor/stash.appscode.dev/apimachinery/apis/ui/v1alpha1/groupversion_info.go b/vendor/stash.appscode.dev/apimachinery/apis/ui/v1alpha1/groupversion_info.go index 9bcca8996..4c19c3407 100644 --- a/vendor/stash.appscode.dev/apimachinery/apis/ui/v1alpha1/groupversion_info.go +++ b/vendor/stash.appscode.dev/apimachinery/apis/ui/v1alpha1/groupversion_info.go @@ -15,8 +15,8 @@ limitations under the License. */ // Package v1alpha1 contains API Schema definitions for the kubedb v1alpha1 API group -//+kubebuilder:object:generate=true -//+groupName=ui.stash.appscode.com +// +kubebuilder:object:generate=true +// +groupName=ui.stash.appscode.com package v1alpha1 import ( 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 b1b715831..1e55812c8 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 @@ -3792,6 +3792,22 @@ spec: - name - prune type: object + retryConfig: + description: RetryConfig specify a configuration for retry a backup + if it fails. By default, Stash does not retry any failed backup. + properties: + delay: + description: 'The amount of time to wait before next retry. If + you don''t specify this field, Stash will retry immediately. + Format: 30s, 2m, 1h etc.' + type: string + maxRetry: + default: 1 + description: 'MaxRetry specifies the maximum number of attempts + Stash should retry. Default value: 1' + format: int32 + type: integer + type: object runtimeSettings: description: RuntimeSettings allow to specify Resources, NodeSelector, Affinity, Toleration, ReadinessProbe etc, and used to create service 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 1432f27b2..17d4cdb6c 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 @@ -2411,6 +2411,22 @@ spec: - name - prune type: object + retryConfig: + description: RetryConfig specify a configuration for retry a backup + if it fails. By default, Stash does not retry any failed backup. + properties: + delay: + description: 'The amount of time to wait before next retry. If + you don''t specify this field, Stash will retry immediately. + Format: 30s, 2m, 1h etc.' + type: string + maxRetry: + default: 1 + description: 'MaxRetry specifies the maximum number of attempts + Stash should retry. Default value: 1' + format: int32 + type: integer + type: object runtimeSettings: description: RuntimeSettings allow to specify Resources, NodeSelector, Affinity, Toleration, ReadinessProbe etc. 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 f9cb4926a..815d62659 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 @@ -819,6 +819,22 @@ spec: - name - prune type: object + retryConfig: + description: RetryConfig specify a configuration for retry a backup + if it fails. By default, Stash does not retry any failed backup. + properties: + delay: + description: 'The amount of time to wait before next retry. If + you don''t specify this field, Stash will retry immediately. + Format: 30s, 2m, 1h etc.' + type: string + maxRetry: + default: 1 + description: 'MaxRetry specifies the maximum number of attempts + Stash should retry. Default value: 1' + format: int32 + type: integer + type: object runtimeSettings: description: RuntimeSettings allow to specify Resources, NodeSelector, Affinity, Toleration, ReadinessProbe etc. 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 d42f37e4d..3f67a7913 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 @@ -69,6 +69,12 @@ spec: - kind - name type: object + retryLeft: + description: RetryLeft specifies number of retry attempts left for + the session. If this set to non-zero, Stash will create a new BackupSession + if the current one fails. + format: int32 + type: integer type: object status: properties: @@ -120,6 +126,12 @@ spec: - type type: object type: array + nextRetry: + description: NextRetry specifies the time when Stash should retry + the current failed backup. This field will exist only if the `retryConfig` + has been set in the respective backup invoker. + format: date-time + type: string phase: description: Phase indicates the overall phase of the backup process for this BackupSession. Phase will be "Succeeded" only if phase @@ -133,6 +145,11 @@ spec: - Failed - Unknown type: string + retried: + description: Retried specifies whether this session was retried or + not. This field will exist only if the `retryConfig` has been set + in the respective backup invoker. + type: boolean sessionDeadline: description: SessionDeadline specifies the deadline of backup. BackupSession will be considered Failed if backup does not complete within this diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/conditions/backupsession.go b/vendor/stash.appscode.dev/apimachinery/pkg/conditions/backupsession.go index fed3a67ff..08a789850 100644 --- a/vendor/stash.appscode.dev/apimachinery/pkg/conditions/backupsession.go +++ b/vendor/stash.appscode.dev/apimachinery/pkg/conditions/backupsession.go @@ -387,7 +387,7 @@ func SetBackupHistoryCleanedConditionToTrue(session *invoker.BackupSessionHandle }) } -func SetBackupDeadlineExceededConditionToTrue(session *invoker.BackupSessionHandler, timeOut string) error { +func SetBackupDeadlineExceededConditionToTrue(session *invoker.BackupSessionHandler, timeOut metav1.Duration) error { return session.UpdateStatus(&v1beta1.BackupSessionStatus{ Conditions: []kmapi.Condition{ { diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/conditions/restore_invoker.go b/vendor/stash.appscode.dev/apimachinery/pkg/conditions/restore_invoker.go index dc2b9185f..01a1bf634 100644 --- a/vendor/stash.appscode.dev/apimachinery/pkg/conditions/restore_invoker.go +++ b/vendor/stash.appscode.dev/apimachinery/pkg/conditions/restore_invoker.go @@ -261,7 +261,7 @@ func SetGlobalPostRestoreHookSucceededConditionToTrueWithMsg(invoker invoker.Res }) } -func SetRestoreDeadlineExceededConditionToTrue(invoker invoker.RestoreInvoker, timeOut string) error { +func SetRestoreDeadlineExceededConditionToTrue(invoker invoker.RestoreInvoker, timeOut metav1.Duration) error { return invoker.SetCondition(nil, kmapi.Condition{ Type: v1beta1.DeadlineExceeded, Status: core.ConditionTrue, 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 99dc362d8..732fba4b3 100644 --- a/vendor/stash.appscode.dev/apimachinery/pkg/invoker/backup_invoker.go +++ b/vendor/stash.appscode.dev/apimachinery/pkg/invoker/backup_invoker.go @@ -33,6 +33,7 @@ import ( type BackupInvoker interface { MetadataHandler ConditionHandler + SessionHandler BackupExecutionOrderHandler BackupTargetHandler RepositoryGetter @@ -41,6 +42,11 @@ type BackupInvoker interface { ObjectFormatter BackupInvokerStatusHandler Summarizer + RetryHandler +} + +type SessionHandler interface { + NewSession() *v1beta1.BackupSession } type BackupExecutionOrderHandler interface { @@ -60,6 +66,7 @@ type BackupTargetHandler interface { type BackupInvokerStatusHandler interface { GetPhase() v1beta1.BackupInvokerPhase + UpdateObservedGeneration() error } type BackupTargetInfo struct { diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/invoker/backupbatch.go b/vendor/stash.appscode.dev/apimachinery/pkg/invoker/backupbatch.go index 1ca4bd69a..e7a4bd742 100644 --- a/vendor/stash.appscode.dev/apimachinery/pkg/invoker/backupbatch.go +++ b/vendor/stash.appscode.dev/apimachinery/pkg/invoker/backupbatch.go @@ -18,7 +18,10 @@ 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" @@ -35,6 +38,7 @@ import ( core_util "kmodules.xyz/client-go/core/v1" "kmodules.xyz/client-go/meta" ofst "kmodules.xyz/offshoot-api/api/v1" + runtimeClient "sigs.k8s.io/controller-runtime/pkg/client" ) type BackupBatchInvoker struct { @@ -183,7 +187,7 @@ func (inv *BackupBatchInvoker) GetDriver() v1beta1.Snapshotter { return driver } -func (inv *BackupBatchInvoker) GetTimeOut() string { +func (inv *BackupBatchInvoker) GetTimeOut() *metav1.Duration { return inv.backupBatch.Spec.TimeOut } @@ -246,11 +250,11 @@ func (inv *BackupBatchInvoker) GetHash() string { } func (inv *BackupBatchInvoker) GetObjectJSON() (string, error) { - jsonObj, err := meta.MarshalToJson(inv.backupBatch, v1beta1.SchemeGroupVersion) - if err != nil { - return "", err - } - return string(jsonObj), nil + obj := inv.backupBatch.DeepCopy() + obj.ObjectMeta = removeMetaDecorators(obj.ObjectMeta) + // remove status from the object + obj.Status = v1beta1.BackupBatchStatus{} + return marshalToJSON(obj) } func (inv *BackupBatchInvoker) GetRuntimeObject() runtime.Object { @@ -265,6 +269,20 @@ func (inv *BackupBatchInvoker) GetPhase() v1beta1.BackupInvokerPhase { return inv.backupBatch.Status.Phase } +func (inv *BackupBatchInvoker) UpdateObservedGeneration() error { + _, err := v1beta1_util.UpdateBackupBatchStatus( + context.TODO(), + inv.stashClient.StashV1beta1(), + inv.backupBatch.ObjectMeta, + func(in *v1beta1.BackupBatchStatus) (types.UID, *v1beta1.BackupBatchStatus) { + in.ObservedGeneration = inv.backupBatch.Generation + return inv.backupBatch.UID, in + }, + metav1.UpdateOptions{}, + ) + return runtimeClient.IgnoreNotFound(err) +} + func (inv *BackupBatchInvoker) GetSummary(target v1beta1.TargetRef, session kmapi.ObjectReference) *v1beta1.Summary { summary := getTargetBackupSummary(inv.stashClient, target, session) summary.Invoker = core.TypedLocalObjectReference{ @@ -274,3 +292,49 @@ func (inv *BackupBatchInvoker) GetSummary(target v1beta1.TargetRef, session kmap } return summary } + +func (inv *BackupBatchInvoker) GetRetryConfig() *v1beta1.RetryConfig { + return inv.backupBatch.Spec.RetryConfig +} + +func (inv *BackupBatchInvoker) NewSession() *v1beta1.BackupSession { + retryLimit := int32(0) + if inv.backupBatch.Spec.RetryConfig != nil { + retryLimit = inv.backupBatch.Spec.RetryConfig.MaxRetry + } + + session := &v1beta1.BackupSession{ + ObjectMeta: metav1.ObjectMeta{ + Name: meta.NameWithSuffix(inv.backupBatch.Name, fmt.Sprintf("%d", time.Now().Unix())), + Namespace: inv.backupBatch.Namespace, + OwnerReferences: []metav1.OwnerReference{}, + Labels: inv.getSessionLabels(), + }, + Spec: v1beta1.BackupSessionSpec{ + Invoker: v1beta1.BackupInvokerRef{ + APIGroup: v1beta1.SchemeGroupVersion.Group, + Kind: v1beta1.ResourceKindBackupBatch, + Name: inv.backupBatch.Name, + }, + RetryLeft: retryLimit, + }, + } + + return session +} + +func (inv *BackupBatchInvoker) getSessionLabels() map[string]string { + sl := inv.GetLabels() + + // Add invoker info + sl[apis.LabelInvokerType] = v1beta1.ResourceKindBackupBatch + sl[apis.LabelInvokerName] = inv.backupBatch.Name + + // Add target info. For batch backup, we will be adding the first member info. + target := inv.backupBatch.Spec.Members[0].Target.Ref + sl[apis.LabelTargetKind] = target.Kind + sl[apis.LabelTargetName] = target.Name + sl[apis.LabelTargetNamespace] = target.Namespace + + return sl +} diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/invoker/backupconfiguration.go b/vendor/stash.appscode.dev/apimachinery/pkg/invoker/backupconfiguration.go index c35e56994..7929ffe27 100644 --- a/vendor/stash.appscode.dev/apimachinery/pkg/invoker/backupconfiguration.go +++ b/vendor/stash.appscode.dev/apimachinery/pkg/invoker/backupconfiguration.go @@ -18,7 +18,10 @@ 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" @@ -28,12 +31,14 @@ import ( "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" core_util "kmodules.xyz/client-go/core/v1" "kmodules.xyz/client-go/meta" ofst "kmodules.xyz/offshoot-api/api/v1" + runtimeClient "sigs.k8s.io/controller-runtime/pkg/client" ) type BackupConfigurationInvoker struct { @@ -154,7 +159,7 @@ func (inv *BackupConfigurationInvoker) GetDriver() v1beta1.Snapshotter { return driver } -func (inv *BackupConfigurationInvoker) GetTimeOut() string { +func (inv *BackupConfigurationInvoker) GetTimeOut() *metav1.Duration { return inv.backupConfig.Spec.TimeOut } @@ -217,11 +222,11 @@ func (inv *BackupConfigurationInvoker) GetHash() string { } func (inv *BackupConfigurationInvoker) GetObjectJSON() (string, error) { - jsonObj, err := meta.MarshalToJson(inv.backupConfig, v1beta1.SchemeGroupVersion) - if err != nil { - return "", err - } - return string(jsonObj), nil + obj := inv.backupConfig.DeepCopy() + obj.ObjectMeta = removeMetaDecorators(obj.ObjectMeta) + // remove status from the object + obj.Status = v1beta1.BackupConfigurationStatus{} + return marshalToJSON(obj) } func (inv *BackupConfigurationInvoker) GetRetentionPolicy() v1alpha1.RetentionPolicy { @@ -232,6 +237,20 @@ func (inv *BackupConfigurationInvoker) GetPhase() v1beta1.BackupInvokerPhase { return inv.backupConfig.Status.Phase } +func (inv *BackupConfigurationInvoker) UpdateObservedGeneration() error { + _, err := v1beta1_util.UpdateBackupConfigurationStatus( + context.TODO(), + inv.stashClient.StashV1beta1(), + inv.backupConfig.ObjectMeta, + func(in *v1beta1.BackupConfigurationStatus) (types.UID, *v1beta1.BackupConfigurationStatus) { + in.ObservedGeneration = inv.backupConfig.Generation + return inv.backupConfig.UID, in + }, + metav1.UpdateOptions{}, + ) + return runtimeClient.IgnoreNotFound(err) +} + func (inv *BackupConfigurationInvoker) GetSummary(target v1beta1.TargetRef, session kmapi.ObjectReference) *v1beta1.Summary { summary := getTargetBackupSummary(inv.stashClient, target, session) summary.Invoker = core.TypedLocalObjectReference{ @@ -241,3 +260,69 @@ func (inv *BackupConfigurationInvoker) GetSummary(target v1beta1.TargetRef, sess } return summary } + +func removeMetaDecorators(old metav1.ObjectMeta) metav1.ObjectMeta { + return metav1.ObjectMeta{ + Name: old.Name, + Namespace: old.Namespace, + UID: old.UID, + Generation: old.Generation, + Labels: old.Labels, + Annotations: old.Annotations, + OwnerReferences: old.OwnerReferences, + } +} + +func marshalToJSON(obj runtime.Object) (string, error) { + jsonObj, err := meta.MarshalToJson(obj, v1beta1.SchemeGroupVersion) + if err != nil { + return "", err + } + return string(jsonObj), nil +} + +func (inv *BackupConfigurationInvoker) GetRetryConfig() *v1beta1.RetryConfig { + return inv.backupConfig.Spec.RetryConfig +} + +func (inv *BackupConfigurationInvoker) NewSession() *v1beta1.BackupSession { + retryLimit := int32(0) + if inv.backupConfig.Spec.RetryConfig != nil { + retryLimit = inv.backupConfig.Spec.RetryConfig.MaxRetry + } + + session := &v1beta1.BackupSession{ + ObjectMeta: metav1.ObjectMeta{ + Name: meta.NameWithSuffix(inv.backupConfig.Name, fmt.Sprintf("%d", time.Now().Unix())), + Namespace: inv.backupConfig.Namespace, + OwnerReferences: []metav1.OwnerReference{}, + Labels: inv.getSessionLabels(), + }, + Spec: v1beta1.BackupSessionSpec{ + Invoker: v1beta1.BackupInvokerRef{ + APIGroup: v1beta1.SchemeGroupVersion.Group, + Kind: v1beta1.ResourceKindBackupConfiguration, + Name: inv.backupConfig.Name, + }, + RetryLeft: retryLimit, + }, + } + + return session +} + +func (inv *BackupConfigurationInvoker) getSessionLabels() map[string]string { + sl := inv.GetLabels() + + // Add invoker info + sl[apis.LabelInvokerType] = v1beta1.ResourceKindBackupConfiguration + sl[apis.LabelInvokerName] = inv.backupConfig.Name + + // Add target info + target := inv.backupConfig.Spec.Target.Ref + sl[apis.LabelTargetKind] = target.Kind + sl[apis.LabelTargetName] = target.Name + sl[apis.LabelTargetNamespace] = target.Namespace + + return sl +} diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/invoker/backupsession.go b/vendor/stash.appscode.dev/apimachinery/pkg/invoker/backupsession.go index 90b12998b..e737b63f3 100644 --- a/vendor/stash.appscode.dev/apimachinery/pkg/invoker/backupsession.go +++ b/vendor/stash.appscode.dev/apimachinery/pkg/invoker/backupsession.go @@ -64,6 +64,14 @@ func (h *BackupSessionHandler) UpdateStatus(status *v1beta1.BackupSessionStatus) in.SessionDeadline = status.SessionDeadline } + if in.Retried == nil { + in.Retried = status.Retried + } + + if in.NextRetry == nil { + in.NextRetry = status.NextRetry + } + return h.backupSession.ObjectMeta.UID, in }, metav1.UpdateOptions{}, @@ -231,11 +239,7 @@ func calculateBackupTargetPhase(status v1beta1.BackupTargetStatus) v1beta1.Targe } func calculateBackupSessionPhase(status *v1beta1.BackupSessionStatus) v1beta1.BackupSessionPhase { - if kmapi.IsConditionFalse(status.Conditions, v1beta1.MetricsPushed) || - kmapi.IsConditionFalse(status.Conditions, v1beta1.BackupHistoryCleaned) || - kmapi.IsConditionFalse(status.Conditions, v1beta1.GlobalPreBackupHookSucceeded) || - kmapi.IsConditionFalse(status.Conditions, v1beta1.GlobalPostBackupHookSucceeded) || - kmapi.IsConditionTrue(status.Conditions, v1beta1.DeadlineExceeded) { + if kmapi.IsConditionFalse(status.Conditions, v1beta1.MetricsPushed) { return v1beta1.BackupSessionFailed } @@ -243,6 +247,14 @@ func calculateBackupSessionPhase(status *v1beta1.BackupSessionStatus) v1beta1.Ba return v1beta1.BackupSessionSkipped } + if kmapi.IsConditionTrue(status.Conditions, v1beta1.MetricsPushed) && + (kmapi.IsConditionTrue(status.Conditions, v1beta1.DeadlineExceeded) || + kmapi.IsConditionFalse(status.Conditions, v1beta1.BackupHistoryCleaned) || + kmapi.IsConditionFalse(status.Conditions, v1beta1.GlobalPreBackupHookSucceeded) || + kmapi.IsConditionFalse(status.Conditions, v1beta1.GlobalPostBackupHookSucceeded)) { + return v1beta1.BackupSessionFailed + } + if len(status.Targets) == 0 || isAllTargetBackupPending(status.Targets) { return v1beta1.BackupSessionPending } diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/invoker/interfaces.go b/vendor/stash.appscode.dev/apimachinery/pkg/invoker/interfaces.go index aa20cc736..07ff48fec 100644 --- a/vendor/stash.appscode.dev/apimachinery/pkg/invoker/interfaces.go +++ b/vendor/stash.appscode.dev/apimachinery/pkg/invoker/interfaces.go @@ -53,7 +53,7 @@ type DriverHandler interface { } type TimeOutGetter interface { - GetTimeOut() string + GetTimeOut() *metav1.Duration } type Eventer interface { @@ -72,3 +72,7 @@ type ObjectFormatter interface { type Summarizer interface { GetSummary(target v1beta1.TargetRef, session kmapi.ObjectReference) *v1beta1.Summary } + +type RetryHandler interface { + GetRetryConfig() *v1beta1.RetryConfig +} 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 d22f3d9f6..442c26624 100644 --- a/vendor/stash.appscode.dev/apimachinery/pkg/invoker/restore_invoker.go +++ b/vendor/stash.appscode.dev/apimachinery/pkg/invoker/restore_invoker.go @@ -69,7 +69,7 @@ type RestoreStatusHandler interface { type RestoreInvokerStatus struct { Phase v1beta1.RestorePhase SessionDuration string - SessionDeadline metav1.Time + SessionDeadline *metav1.Time Conditions []kmapi.Condition TargetStatus []v1beta1.RestoreMemberStatus } diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/invoker/restorebatch.go b/vendor/stash.appscode.dev/apimachinery/pkg/invoker/restorebatch.go index 755bca5ab..75d0064e0 100644 --- a/vendor/stash.appscode.dev/apimachinery/pkg/invoker/restorebatch.go +++ b/vendor/stash.appscode.dev/apimachinery/pkg/invoker/restorebatch.go @@ -179,7 +179,7 @@ func (inv *RestoreBatchInvoker) GetDriver() v1beta1.Snapshotter { return driver } -func (inv *RestoreBatchInvoker) GetTimeOut() string { +func (inv *RestoreBatchInvoker) GetTimeOut() *metav1.Duration { return inv.restoreBatch.Spec.TimeOut } @@ -226,11 +226,11 @@ func (inv *RestoreBatchInvoker) GetHash() string { } func (inv *RestoreBatchInvoker) GetObjectJSON() (string, error) { - jsonObj, err := meta.MarshalToJson(inv.restoreBatch, v1beta1.SchemeGroupVersion) - if err != nil { - return "", err - } - return string(jsonObj), nil + obj := inv.restoreBatch.DeepCopy() + obj.ObjectMeta = removeMetaDecorators(obj.ObjectMeta) + // remove status from the object + obj.Status = v1beta1.RestoreBatchStatus{} + return marshalToJSON(obj) } func (inv *RestoreBatchInvoker) GetRuntimeObject() runtime.Object { @@ -361,10 +361,14 @@ func upsertRestoreMemberStatus(cur []v1beta1.RestoreMemberStatus, new v1beta1.Re } func calculateRestoreBatchPhase(status *v1beta1.RestoreBatchStatus, totalTargets int) v1beta1.RestorePhase { - if kmapi.IsConditionFalse(status.Conditions, v1beta1.MetricsPushed) || - kmapi.IsConditionFalse(status.Conditions, v1beta1.GlobalPreRestoreHookSucceeded) || - kmapi.IsConditionFalse(status.Conditions, v1beta1.GlobalPostRestoreHookSucceeded) || - kmapi.IsConditionTrue(status.Conditions, v1beta1.DeadlineExceeded) { + if kmapi.IsConditionFalse(status.Conditions, v1beta1.MetricsPushed) { + return v1beta1.RestoreFailed + } + + if kmapi.IsConditionTrue(status.Conditions, v1beta1.MetricsPushed) && + (kmapi.IsConditionFalse(status.Conditions, v1beta1.GlobalPreRestoreHookSucceeded) || + kmapi.IsConditionFalse(status.Conditions, v1beta1.GlobalPostRestoreHookSucceeded) || + kmapi.IsConditionTrue(status.Conditions, v1beta1.DeadlineExceeded)) { return v1beta1.RestoreFailed } @@ -372,6 +376,11 @@ func calculateRestoreBatchPhase(status *v1beta1.RestoreBatchStatus, totalTargets return v1beta1.RestorePending } + if kmapi.IsConditionFalse(status.Conditions, v1beta1.RepositoryFound) || + kmapi.IsConditionFalse(status.Conditions, v1beta1.BackendSecretFound) { + return v1beta1.RestorePending + } + failedTargetCount := 0 unknownTargetCount := 0 successfulTargetCount := 0 @@ -402,11 +411,6 @@ func calculateRestoreBatchPhase(status *v1beta1.RestoreBatchStatus, totalTargets } } - if kmapi.IsConditionFalse(status.Conditions, v1beta1.RepositoryFound) || - kmapi.IsConditionFalse(status.Conditions, v1beta1.BackendSecretFound) { - return v1beta1.RestorePending - } - if kmapi.IsConditionFalse(status.Conditions, v1beta1.ValidationPassed) { return v1beta1.RestorePhaseInvalid } diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/invoker/restoresession.go b/vendor/stash.appscode.dev/apimachinery/pkg/invoker/restoresession.go index 19a6834c3..5f744c398 100644 --- a/vendor/stash.appscode.dev/apimachinery/pkg/invoker/restoresession.go +++ b/vendor/stash.appscode.dev/apimachinery/pkg/invoker/restoresession.go @@ -156,7 +156,7 @@ func (inv *RestoreSessionInvoker) GetDriver() v1beta1.Snapshotter { return driver } -func (inv *RestoreSessionInvoker) GetTimeOut() string { +func (inv *RestoreSessionInvoker) GetTimeOut() *metav1.Duration { return inv.restoreSession.Spec.TimeOut } @@ -203,11 +203,11 @@ func (inv *RestoreSessionInvoker) GetHash() string { } func (inv *RestoreSessionInvoker) GetObjectJSON() (string, error) { - jsonObj, err := meta.MarshalToJson(inv.restoreSession, v1beta1.SchemeGroupVersion) - if err != nil { - return "", err - } - return string(jsonObj), nil + obj := inv.restoreSession.DeepCopy() + obj.ObjectMeta = removeMetaDecorators(obj.ObjectMeta) + // remove status from the object + obj.Status = v1beta1.RestoreSessionStatus{} + return marshalToJSON(obj) } func (inv *RestoreSessionInvoker) GetRuntimeObject() runtime.Object { @@ -385,9 +385,11 @@ func checkFailureInConditions(conditions []kmapi.Condition) (bool, string) { } func calculateRestoreSessionPhase(status v1beta1.RestoreMemberStatus) v1beta1.RestorePhase { - if kmapi.IsConditionFalse(status.Conditions, v1beta1.RestoreExecutorEnsured) || - kmapi.IsConditionFalse(status.Conditions, v1beta1.PreRestoreHookExecutionSucceeded) || - kmapi.IsConditionFalse(status.Conditions, v1beta1.PostRestoreHookExecutionSucceeded) || + if kmapi.IsConditionFalse(status.Conditions, v1beta1.MetricsPushed) { + return v1beta1.RestoreFailed + } + + if kmapi.IsConditionTrue(status.Conditions, v1beta1.MetricsPushed) && kmapi.IsConditionTrue(status.Conditions, v1beta1.DeadlineExceeded) { return v1beta1.RestoreFailed } @@ -396,6 +398,13 @@ func calculateRestoreSessionPhase(status v1beta1.RestoreMemberStatus) v1beta1.Re return v1beta1.RestorePending } + 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 + } + if RestoreCompletedForAllTargets([]v1beta1.RestoreMemberStatus{status}, 1) { if !kmapi.HasCondition(status.Conditions, v1beta1.MetricsPushed) { return v1beta1.RestoreRunning @@ -405,20 +414,12 @@ func calculateRestoreSessionPhase(status v1beta1.RestoreMemberStatus) v1beta1.Re return v1beta1.RestorePhaseUnknown } - if status.Phase == v1beta1.TargetRestoreFailed || - kmapi.IsConditionFalse(status.Conditions, v1beta1.MetricsPushed) { + if status.Phase == v1beta1.TargetRestoreFailed { return v1beta1.RestoreFailed } return v1beta1.RestoreSucceeded } - 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 - } - if kmapi.IsConditionFalse(status.Conditions, v1beta1.ValidationPassed) { return v1beta1.RestorePhaseInvalid } @@ -428,6 +429,9 @@ func calculateRestoreSessionPhase(status v1beta1.RestoreMemberStatus) v1beta1.Re func RestoreCompletedForAllTargets(status []v1beta1.RestoreMemberStatus, totalTargets int) bool { for _, t := range status { + if t.Phase == v1beta1.TargetRestoreSucceeded || t.Phase == v1beta1.TargetRestoreFailed || t.Phase == v1beta1.TargetRestorePhaseUnknown { + continue + } if t.TotalHosts == nil || !restoreCompletedForAllHosts(t.Stats, *t.TotalHosts) { return false } diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/restic/config.go b/vendor/stash.appscode.dev/apimachinery/pkg/restic/config.go index cde197533..05aba116d 100644 --- a/vendor/stash.appscode.dev/apimachinery/pkg/restic/config.go +++ b/vendor/stash.appscode.dev/apimachinery/pkg/restic/config.go @@ -18,7 +18,6 @@ package restic import ( "fmt" - "io/ioutil" "os" "path/filepath" "sort" @@ -163,7 +162,7 @@ func (w *ResticWrapper) DumpEnv(path string, dumpedFile string) error { } } - if err := ioutil.WriteFile(filepath.Join(path, dumpedFile), []byte(envs), 0o600); err != nil { + if err := os.WriteFile(filepath.Join(path, dumpedFile), []byte(envs), 0o600); err != nil { return err } return nil diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/restic/output.go b/vendor/stash.appscode.dev/apimachinery/pkg/restic/output.go index cae3da7ec..bc4d5f5ff 100644 --- a/vendor/stash.appscode.dev/apimachinery/pkg/restic/output.go +++ b/vendor/stash.appscode.dev/apimachinery/pkg/restic/output.go @@ -21,7 +21,6 @@ import ( "bytes" "encoding/json" "io" - "io/ioutil" "os" "path/filepath" "regexp" @@ -69,7 +68,7 @@ func (out *BackupOutput) WriteOutput(fileName string) error { newFile = true } - if err := ioutil.WriteFile(fileName, jsonOutput, FileModeRWXAll); err != nil { // this does not make the file writable to other users + if err := os.WriteFile(fileName, jsonOutput, FileModeRWXAll); err != nil { // this does not make the file writable to other users return err } // change the file permission to make it writable to other users @@ -93,7 +92,7 @@ func (out *RestoreOutput) WriteOutput(fileName string) error { newFile = true } - if err := ioutil.WriteFile(fileName, jsonOutput, FileModeRWXAll); err != nil { // this does not make the file writable to other users + if err := os.WriteFile(fileName, jsonOutput, FileModeRWXAll); err != nil { // this does not make the file writable to other users return err } // change the file permission to make it writable to other users @@ -104,7 +103,7 @@ func (out *RestoreOutput) WriteOutput(fileName string) error { } func ReadBackupOutput(filename string) (*BackupOutput, error) { - data, err := ioutil.ReadFile(filename) + data, err := os.ReadFile(filename) if err != nil { return nil, err } @@ -119,7 +118,7 @@ func ReadBackupOutput(filename string) (*BackupOutput, error) { } func ReadRestoreOutput(filename string) (*RestoreOutput, error) { - data, err := ioutil.ReadFile(filename) + data, err := os.ReadFile(filename) if err != nil { return nil, err } diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/restic/setup.go b/vendor/stash.appscode.dev/apimachinery/pkg/restic/setup.go index 37450b069..c12159adc 100644 --- a/vendor/stash.appscode.dev/apimachinery/pkg/restic/setup.go +++ b/vendor/stash.appscode.dev/apimachinery/pkg/restic/setup.go @@ -19,7 +19,6 @@ package restic import ( "errors" "fmt" - "io/ioutil" "net/url" "os" "path/filepath" @@ -338,7 +337,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, 0o755); err != nil { + if err := os.WriteFile(filePath, v, 0o755); err != nil { return "", err } return filePath, nil