From 3bc1c26c63c0e04bc5d220c093189149a0d7d1e9 Mon Sep 17 00:00:00 2001 From: Tamal Saha Date: Thu, 24 Oct 2024 23:01:56 -0700 Subject: [PATCH] Always flush logs Signed-off-by: Tamal Saha --- cmd/kube-ui-server/main.go | 10 ++-- go.mod | 2 +- go.sum | 4 +- vendor/kmodules.xyz/client-go/Makefile | 2 +- .../client-go/client/duck/patch.go | 48 +++++++++++++++++++ .../client-go/client/duck/typed_client.go | 15 ++++-- .../client/duck/unstructured_client.go | 15 ++++-- vendor/modules.txt | 2 +- 8 files changed, 84 insertions(+), 14 deletions(-) create mode 100644 vendor/kmodules.xyz/client-go/client/duck/patch.go diff --git a/cmd/kube-ui-server/main.go b/cmd/kube-ui-server/main.go index 7c10055d41..8219e64fa9 100644 --- a/cmd/kube-ui-server/main.go +++ b/cmd/kube-ui-server/main.go @@ -30,6 +30,12 @@ import ( ) func main() { + if err := realMain(); err != nil { + klog.Fatalln("Error in kube-ui-server Main:", err) + } +} + +func realMain() error { rootCmd := cmds.NewRootCmd() logs.Init(rootCmd, true) defer logs.FlushLogs() @@ -38,7 +44,5 @@ func main() { runtime.GOMAXPROCS(runtime.NumCPU()) } - if err := rootCmd.Execute(); err != nil { - klog.Fatalln("Error in kube-ui-server Main:", err) - } + return rootCmd.Execute() } diff --git a/go.mod b/go.mod index 1ebe3c80fa..84dd4f31da 100644 --- a/go.mod +++ b/go.mod @@ -45,7 +45,7 @@ require ( k8s.io/kube-state-metrics/v2 v2.12.0 kmodules.xyz/apiversion v0.2.0 kmodules.xyz/authorizer v0.29.1 - kmodules.xyz/client-go v0.30.29 + kmodules.xyz/client-go v0.30.31 kmodules.xyz/custom-resources v0.30.0 kmodules.xyz/go-containerregistry v0.0.12 kmodules.xyz/monitoring-agent-api v0.30.2 diff --git a/go.sum b/go.sum index 3418db14e1..cd3b4a0b59 100644 --- a/go.sum +++ b/go.sum @@ -922,8 +922,8 @@ kmodules.xyz/apiversion v0.2.0 h1:vAQYqZFm4xu4pbB1cAdHbFEPES6EQkcR4wc06xdTOWk= kmodules.xyz/apiversion v0.2.0/go.mod h1:oPX8g8LvlPdPX3Yc5YvCzJHQnw3YF/X4/jdW0b1am80= kmodules.xyz/authorizer v0.29.1 h1:uByGGoryKbZcfiEAhjcK/Y345I9mygNQP7DVpkMbNQQ= kmodules.xyz/authorizer v0.29.1/go.mod h1:kZRhclL8twzyt2bQuJQJbpYww2sc+qFr8I5PPoq/sWY= -kmodules.xyz/client-go v0.30.29 h1:qiJH6inZNrjXKearnzacZZtch2sUxSWJMKntdwFUYC8= -kmodules.xyz/client-go v0.30.29/go.mod h1:CAu+JlA8RVGtj6LQHu0Q1w2mnFUajuti49c7T1AvGdM= +kmodules.xyz/client-go v0.30.31 h1:P+ZslW5QcgMnMoxo1ZMJrNNcwRwA1BiFct1JvcRQEj0= +kmodules.xyz/client-go v0.30.31/go.mod h1:CAu+JlA8RVGtj6LQHu0Q1w2mnFUajuti49c7T1AvGdM= kmodules.xyz/crd-schema-fuzz v0.29.1 h1:zJTlWYOrT5dsVVHW8HGcnR/vaWfxQfNh11QwTtkYpcs= kmodules.xyz/crd-schema-fuzz v0.29.1/go.mod h1:n708z9YQqLMP2KNLQVgBcRJw1QpSWLvpNCEi+KJDOYE= kmodules.xyz/custom-resources v0.30.0 h1:vR3CbseHMLwR4GvtcJJuRuwIV8voKqFqNii27rMcm1o= diff --git a/vendor/kmodules.xyz/client-go/Makefile b/vendor/kmodules.xyz/client-go/Makefile index 4ff50bd7ce..9c7cb06c31 100644 --- a/vendor/kmodules.xyz/client-go/Makefile +++ b/vendor/kmodules.xyz/client-go/Makefile @@ -56,7 +56,7 @@ OS := $(if $(GOOS),$(GOOS),$(shell go env GOOS)) ARCH := $(if $(GOARCH),$(GOARCH),$(shell go env GOARCH)) BASEIMAGE_PROD ?= gcr.io/distroless/static-debian12 -BASEIMAGE_DBG ?= debian:bookworm +BASEIMAGE_DBG ?= debian:12 GO_VERSION ?= 1.23 BUILD_IMAGE ?= ghcr.io/appscode/golang-dev:$(GO_VERSION) diff --git a/vendor/kmodules.xyz/client-go/client/duck/patch.go b/vendor/kmodules.xyz/client-go/client/duck/patch.go new file mode 100644 index 0000000000..968df35d94 --- /dev/null +++ b/vendor/kmodules.xyz/client-go/client/duck/patch.go @@ -0,0 +1,48 @@ +/* +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 duck + +import ( + "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +type RawPatch struct { + pt types.PatchType + data []byte +} + +var _ client.Patch = &RawPatch{} + +func NewRawPatch(obj client.Object, patch client.Patch) (client.Patch, error) { + data, err := patch.Data(obj) + if err != nil { + return nil, err + } + return &RawPatch{ + pt: patch.Type(), + data: data, + }, nil +} + +func (r *RawPatch) Type() types.PatchType { + return r.pt +} + +func (r *RawPatch) Data(obj client.Object) ([]byte, error) { + return r.data, nil +} diff --git a/vendor/kmodules.xyz/client-go/client/duck/typed_client.go b/vendor/kmodules.xyz/client-go/client/duck/typed_client.go index bcebd01e6c..b7bf936157 100644 --- a/vendor/kmodules.xyz/client-go/client/duck/typed_client.go +++ b/vendor/kmodules.xyz/client-go/client/duck/typed_client.go @@ -185,6 +185,11 @@ func (d *typedClient) Patch(ctx context.Context, obj client.Object, patch client return d.c.Patch(ctx, obj, patch, opts...) } + rawPatch, err := NewRawPatch(obj, patch) + if err != nil { + return err + } + ll, err := d.c.Scheme().New(d.rawGVK) if err != nil { return err @@ -192,8 +197,7 @@ func (d *typedClient) Patch(ctx context.Context, obj client.Object, patch client llo := ll.(client.Object) llo.SetNamespace(obj.GetNamespace()) llo.SetName(obj.GetName()) - llo.SetLabels(obj.GetLabels()) - return d.c.Patch(ctx, llo, patch, opts...) + return d.c.Patch(ctx, llo, rawPatch, opts...) } func (d *typedClient) DeleteAllOf(ctx context.Context, obj client.Object, opts ...client.DeleteAllOfOption) error { @@ -259,6 +263,11 @@ func (sw *typedStatusWriter) Patch(ctx context.Context, obj client.Object, patch return sw.client.c.Status().Patch(ctx, obj, patch, opts...) } + rawPatch, err := NewRawPatch(obj, patch) + if err != nil { + return err + } + ll, err := sw.client.c.Scheme().New(sw.client.rawGVK) if err != nil { return err @@ -267,7 +276,7 @@ func (sw *typedStatusWriter) Patch(ctx context.Context, obj client.Object, patch llo.SetNamespace(obj.GetNamespace()) llo.SetName(obj.GetName()) llo.SetLabels(obj.GetLabels()) - return sw.client.c.Status().Patch(ctx, llo, patch, opts...) + return sw.client.c.Status().Patch(ctx, llo, rawPatch, opts...) } func (d *typedClient) SubResource(subResource string) client.SubResourceClient { diff --git a/vendor/kmodules.xyz/client-go/client/duck/unstructured_client.go b/vendor/kmodules.xyz/client-go/client/duck/unstructured_client.go index 12c7bc2f2e..27ae224d5b 100644 --- a/vendor/kmodules.xyz/client-go/client/duck/unstructured_client.go +++ b/vendor/kmodules.xyz/client-go/client/duck/unstructured_client.go @@ -133,12 +133,16 @@ func (uc *unstructuredClient) Patch(ctx context.Context, obj client.Object, patc return uc.c.Patch(ctx, obj, patch, opts...) } + rawPatch, err := NewRawPatch(obj, patch) + if err != nil { + return err + } + var llo unstructured.Unstructured llo.GetObjectKind().SetGroupVersionKind(uc.rawGVK) llo.SetNamespace(obj.GetNamespace()) llo.SetName(obj.GetName()) - llo.SetLabels(obj.GetLabels()) - return uc.c.Patch(ctx, &llo, patch, opts...) + return uc.c.Patch(ctx, &llo, rawPatch, opts...) } // Get implements client.Client. @@ -254,12 +258,17 @@ func (sw *unstructuredStatusWriter) Patch(ctx context.Context, obj client.Object return sw.client.c.Status().Patch(ctx, obj, patch, opts...) } + rawPatch, err := NewRawPatch(obj, patch) + if err != nil { + return err + } + var llo unstructured.Unstructured llo.GetObjectKind().SetGroupVersionKind(sw.client.rawGVK) llo.SetNamespace(obj.GetNamespace()) llo.SetName(obj.GetName()) llo.SetLabels(obj.GetLabels()) - return sw.client.c.Status().Patch(ctx, &llo, patch, opts...) + return sw.client.c.Status().Patch(ctx, &llo, rawPatch, opts...) } func (d *unstructuredClient) SubResource(subResource string) client.SubResourceClient { diff --git a/vendor/modules.txt b/vendor/modules.txt index 777115a0be..3b6cee5706 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -2006,7 +2006,7 @@ kmodules.xyz/authorizer/apiserver kmodules.xyz/authorizer/rbac kmodules.xyz/authorizer/rbac/helpers kmodules.xyz/authorizer/rbac/validation -# kmodules.xyz/client-go v0.30.29 +# kmodules.xyz/client-go v0.30.31 ## explicit; go 1.22.0 kmodules.xyz/client-go kmodules.xyz/client-go/api/v1