mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
[Bugfix] Fix Operator Debug mode (#1208)
This commit is contained in:
parent
01dab4aa29
commit
f585136505
4 changed files with 50 additions and 24 deletions
|
@ -41,6 +41,7 @@
|
|||
- (Bugfix) Prevent Runtime update restarts
|
||||
- (Bugfix) Change member port discovery
|
||||
- (Feature) Do not change external service ports
|
||||
- (Bugfix) Fix Operator Debug mode
|
||||
|
||||
## [1.2.20](https://github.com/arangodb/kube-arangodb/tree/1.2.20) (2022-10-25)
|
||||
- (Feature) Add action progress
|
||||
|
|
|
@ -38,11 +38,18 @@ rules:
|
|||
- apiGroups: ["backup.arangodb.com"]
|
||||
resources: ["arangobackuppolicies", "arangobackups"]
|
||||
verbs: ["get", "list", "watch"]
|
||||
{{- if .Values.rbac.extensions.debug }}
|
||||
- apiGroups: ["events.k8s.io"]
|
||||
resources: ["pods/log"]
|
||||
verbs: ["list"]
|
||||
- apiGroups: [""]
|
||||
resources: ["pods/log"]
|
||||
verbs: ["get", "ist"]
|
||||
{{- end }}
|
||||
{{- if .Values.rbac.extensions.monitoring }}
|
||||
- apiGroups: ["monitoring.coreos.com"]
|
||||
resources: ["servicemonitors"]
|
||||
verbs: ["get", "create", "delete", "update", "list", "watch", "patch"]
|
||||
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
|
@ -61,4 +61,5 @@ rbac:
|
|||
extensions:
|
||||
monitoring: true
|
||||
acs: true
|
||||
at: true
|
||||
at: true
|
||||
debug: false
|
61
cmd/debug.go
61
cmd/debug.go
|
@ -22,6 +22,7 @@ package cmd
|
|||
|
||||
import (
|
||||
"compress/gzip"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
@ -50,32 +51,48 @@ var debugPackageInput struct {
|
|||
}
|
||||
|
||||
func debugPackageFunc(cmd *cobra.Command, _ []string) error {
|
||||
out := os.Stdout
|
||||
|
||||
if debugPackageInput.Output != "-" {
|
||||
f, err := os.OpenFile("./out.tar.gz", os.O_TRUNC|os.O_WRONLY|os.O_CREATE, 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
out = f
|
||||
if debugPackageInput.Output == "-" {
|
||||
return debugPackageStdOut(cmd)
|
||||
}
|
||||
|
||||
return debugPackageFile(cmd)
|
||||
}
|
||||
|
||||
func debugPackageStdOut(cmd *cobra.Command) (returnError error) {
|
||||
return debugPackageGZip(cmd, os.Stdout)
|
||||
}
|
||||
|
||||
func debugPackageFile(cmd *cobra.Command) (returnError error) {
|
||||
out, err := os.OpenFile("./out.tar.gz", os.O_TRUNC|os.O_WRONLY|os.O_CREATE, 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if err := out.Close(); err != nil {
|
||||
if returnError == nil {
|
||||
returnError = err
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
return debugPackageGZip(cmd, out)
|
||||
}
|
||||
|
||||
func debugPackageGZip(cmd *cobra.Command, out io.Writer) (returnError error) {
|
||||
gw := gzip.NewWriter(out)
|
||||
|
||||
if err := debug_package.GenerateD(cmd, gw); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := gw.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if debugPackageInput.Output != "-" {
|
||||
if err := out.Close(); err != nil {
|
||||
return err
|
||||
defer func() {
|
||||
if err := gw.Close(); err != nil {
|
||||
if returnError == nil {
|
||||
returnError = err
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
return nil
|
||||
return debugPackageRaw(cmd, gw)
|
||||
}
|
||||
|
||||
func debugPackageRaw(cmd *cobra.Command, gw io.Writer) error {
|
||||
return debug_package.GenerateD(cmd, gw)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue