From 4b1d211ade46ecd5f0136436d97f72a2a7330d58 Mon Sep 17 00:00:00 2001 From: mochizuki875 Date: Tue, 23 Dec 2025 15:50:14 +0000 Subject: [PATCH] make general profile default Kubernetes-commit: 8e420e0b3ac1e6c770a265eb2e69476576a58d43 --- pkg/cmd/debug/debug.go | 4 ++-- pkg/cmd/debug/debug_test.go | 32 ++++++++++++++++---------------- pkg/cmd/debug/profiles.go | 2 ++ 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/pkg/cmd/debug/debug.go b/pkg/cmd/debug/debug.go index be825507d..820b8635d 100644 --- a/pkg/cmd/debug/debug.go +++ b/pkg/cmd/debug/debug.go @@ -213,7 +213,7 @@ func (o *DebugOptions) AddFlags(cmd *cobra.Command) { cmd.Flags().BoolVar(&o.ShareProcesses, "share-processes", o.ShareProcesses, i18n.T("When used with '--copy-to', enable process namespace sharing in the copy.")) cmd.Flags().StringVar(&o.TargetContainer, "target", "", i18n.T("When using an ephemeral container, target processes in this container name.")) cmd.Flags().BoolVarP(&o.TTY, "tty", "t", o.TTY, i18n.T("Allocate a TTY for the debugging container.")) - cmd.Flags().StringVar(&o.Profile, "profile", ProfileLegacy, i18n.T(`Options are "legacy", "general", "baseline", "netadmin", "restricted" or "sysadmin".`)) + cmd.Flags().StringVar(&o.Profile, "profile", ProfileGeneral, i18n.T(`Options are "general", "baseline", "restricted", "netadmin" or "sysadmin". Defaults to general`)) cmd.Flags().StringVar(&o.CustomProfileFile, "custom", o.CustomProfileFile, i18n.T("Path to a JSON or YAML file containing a partial container spec to customize built-in debug profiles.")) } @@ -401,7 +401,7 @@ func (o *DebugOptions) Validate() error { // Warning for legacy profile if o.Profile == ProfileLegacy { - fmt.Fprintln(o.ErrOut, `--profile=legacy is deprecated and will be removed in the future. It is recommended to explicitly specify a profile, for example "--profile=general".`) + fmt.Fprintln(o.ErrOut, `--profile=legacy is deprecated and planned to be removed in v1.39. It is recommended to specify other profile, for example "--profile=general".`) //nolint:errcheck } return nil diff --git a/pkg/cmd/debug/debug_test.go b/pkg/cmd/debug/debug_test.go index cec08b796..d09fc684b 100644 --- a/pkg/cmd/debug/debug_test.go +++ b/pkg/cmd/debug/debug_test.go @@ -2620,7 +2620,7 @@ func TestCompleteAndValidate(t *testing.T) { Namespace: "test", PullPolicy: corev1.PullPolicy("Always"), ShareProcesses: true, - Profile: ProfileLegacy, + Profile: ProfileGeneral, TargetNames: []string{"mypod"}, }, }, @@ -2633,7 +2633,7 @@ func TestCompleteAndValidate(t *testing.T) { KeepInitContainers: true, Namespace: "test", ShareProcesses: true, - Profile: ProfileLegacy, + Profile: ProfileGeneral, TargetNames: []string{"mypod1", "mypod2"}, }, }, @@ -2646,7 +2646,7 @@ func TestCompleteAndValidate(t *testing.T) { KeepInitContainers: true, Namespace: "test", ShareProcesses: true, - Profile: ProfileLegacy, + Profile: ProfileGeneral, TargetNames: []string{"mypod1", "mypod2"}, }, }, @@ -2661,7 +2661,7 @@ func TestCompleteAndValidate(t *testing.T) { Interactive: true, Namespace: "test", ShareProcesses: true, - Profile: ProfileLegacy, + Profile: ProfileGeneral, TargetNames: []string{"mypod"}, TTY: true, }, @@ -2676,7 +2676,7 @@ func TestCompleteAndValidate(t *testing.T) { KeepInitContainers: true, Namespace: "test", ShareProcesses: true, - Profile: ProfileLegacy, + Profile: ProfileGeneral, TargetNames: []string{"mypod"}, }, }, @@ -2691,7 +2691,7 @@ func TestCompleteAndValidate(t *testing.T) { KeepInitContainers: true, Namespace: "test", ShareProcesses: true, - Profile: ProfileLegacy, + Profile: ProfileGeneral, TargetNames: []string{"mypod"}, TTY: true, }, @@ -2706,7 +2706,7 @@ func TestCompleteAndValidate(t *testing.T) { KeepInitContainers: true, Namespace: "test", PullPolicy: corev1.PullPolicy("Always"), - Profile: ProfileLegacy, + Profile: ProfileGeneral, ShareProcesses: true, TargetNames: []string{"mypod"}, }, @@ -2748,7 +2748,7 @@ func TestCompleteAndValidate(t *testing.T) { KeepInitContainers: true, Namespace: "test", ShareProcesses: true, - Profile: ProfileLegacy, + Profile: ProfileGeneral, TargetNames: []string{"mypod"}, TTY: true, }, @@ -2764,7 +2764,7 @@ func TestCompleteAndValidate(t *testing.T) { KeepInitContainers: true, Namespace: "test", ShareProcesses: true, - Profile: ProfileLegacy, + Profile: ProfileGeneral, TargetNames: []string{"mypod"}, }, }, @@ -2779,7 +2779,7 @@ func TestCompleteAndValidate(t *testing.T) { KeepInitContainers: true, Namespace: "test", ShareProcesses: true, - Profile: ProfileLegacy, + Profile: ProfileGeneral, TargetNames: []string{"mypod"}, }, }, @@ -2794,7 +2794,7 @@ func TestCompleteAndValidate(t *testing.T) { KeepInitContainers: true, Namespace: "test", ShareProcesses: true, - Profile: ProfileLegacy, + Profile: ProfileGeneral, TargetNames: []string{"mypod"}, }, }, @@ -2811,7 +2811,7 @@ func TestCompleteAndValidate(t *testing.T) { "app": "app-debugger", }, ShareProcesses: true, - Profile: ProfileLegacy, + Profile: ProfileGeneral, TargetNames: []string{"mypod"}, }, }, @@ -2831,7 +2831,7 @@ func TestCompleteAndValidate(t *testing.T) { "sidecar": "sidecar:debug", }, ShareProcesses: true, - Profile: ProfileLegacy, + Profile: ProfileGeneral, TargetNames: []string{"mypod"}, TTY: true, }, @@ -2848,7 +2848,7 @@ func TestCompleteAndValidate(t *testing.T) { KeepInitContainers: true, Namespace: "test", ShareProcesses: true, - Profile: ProfileLegacy, + Profile: ProfileGeneral, TargetNames: []string{"mypod"}, TTY: true, }, @@ -2870,7 +2870,7 @@ func TestCompleteAndValidate(t *testing.T) { KeepInitContainers: false, Namespace: "test", ShareProcesses: true, - Profile: ProfileLegacy, + Profile: ProfileGeneral, TargetNames: []string{"mypod"}, TTY: true, }, @@ -2911,7 +2911,7 @@ func TestCompleteAndValidate(t *testing.T) { KeepInitContainers: true, Namespace: "test", ShareProcesses: true, - Profile: ProfileLegacy, + Profile: ProfileGeneral, TargetNames: []string{"node/mynode"}, TTY: true, }, diff --git a/pkg/cmd/debug/profiles.go b/pkg/cmd/debug/profiles.go index b7e3d1786..8c0b459df 100644 --- a/pkg/cmd/debug/profiles.go +++ b/pkg/cmd/debug/profiles.go @@ -43,6 +43,8 @@ const ( // --profile flag's help text // ProfileLegacy represents the legacy debugging profile which is backwards-compatible with 1.23 behavior. + // + // Deprecated: legacyProfile is planned to be removed in v1.39. ProfileLegacy = "legacy" // ProfileGeneral contains a reasonable set of defaults tailored for each debugging journey. ProfileGeneral = "general"