From d9294f06b57b35a43c8c0390a7e6ab565577a606 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 20 Jan 2024 21:21:54 +0100 Subject: [PATCH] info: remove printSecurityOptionsWarnings, printServerWarnings Docker Engine 1.13 (API v1.25) added an option to set a custom default seccomp profile on the daemon (see [moby/moby@b237189]). A warning was added on the client-side if a non-default profile was set. Docker Engine 23.0 (API v1.42) added warnings about non-default seccomp profiles to the "info" response ([moby/moby@04f932a]), and the client was updated to skip generating client-side warnings for API v1.42 and up in [docker/cli@8964595]. These warnings are purely informational, and given that Docker Engine versions before 23.0 have reached EOL, and any current version of the Engine now returns the Warnings, it should be safe to remove the client-side fall back logic. This patch removes the client-side fall back code for warnings that was added in 8964595692766444fb84445931889677af5f55eb. [moby/moby@b237189]: https://github.com/moby/moby/commit/b237189e6c8a4f97be59f08c63cdcb1f2f4680a8 [moby/moby@04f932a]: https://github.com/moby/moby/commit/04f932ac862c05a5af2a5950b5e1744100b14eea [docker/cli@8964595]: https://github.com/docker/cli/commit/8964595692766444fb84445931889677af5f55eb Signed-off-by: Sebastiaan van Stijn --- cli/command/system/info.go | 39 ++++---------------------------------- 1 file changed, 4 insertions(+), 35 deletions(-) diff --git a/cli/command/system/info.go b/cli/command/system/info.go index 8027475725..6d6416460a 100644 --- a/cli/command/system/info.go +++ b/cli/command/system/info.go @@ -21,7 +21,6 @@ import ( "github.com/docker/cli/templates" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/system" - "github.com/docker/docker/api/types/versions" "github.com/docker/docker/registry" "github.com/docker/go-units" "github.com/spf13/cobra" @@ -380,7 +379,10 @@ func prettyPrintServerInfo(streams command.Streams, info *dockerInfo) []error { } fprintln(output) - printServerWarnings(streams.Err(), info) + for _, w := range info.Warnings { + fprintln(streams.Err(), w) + } + return errs } @@ -454,39 +456,6 @@ func printSwarmInfo(output io.Writer, info system.Info) { } } -func printServerWarnings(stdErr io.Writer, info *dockerInfo) { - if versions.LessThan(info.ClientInfo.APIVersion, "1.42") { - printSecurityOptionsWarnings(stdErr, *info.Info) - } - if len(info.Warnings) > 0 { - fprintln(stdErr, strings.Join(info.Warnings, "\n")) - } -} - -// printSecurityOptionsWarnings prints warnings based on the security options -// returned by the daemon. -// -// Deprecated: warnings are now generated by the daemon, and returned in -// info.Warnings. This function is used to provide backward compatibility with -// daemons that do not provide these warnings. No new warnings should be added -// here. -func printSecurityOptionsWarnings(stdErr io.Writer, info system.Info) { - if info.OSType == "windows" { - return - } - kvs, _ := system.DecodeSecurityOptions(info.SecurityOptions) - for _, so := range kvs { - if so.Name != "seccomp" { - continue - } - for _, o := range so.Options { - if o.Key == "profile" && o.Value != "default" && o.Value != "builtin" { - _, _ = fmt.Fprintln(stdErr, "WARNING: You're not using the default seccomp profile") - } - } - } -} - func formatInfo(output io.Writer, info dockerInfo, format string) error { if format == formatter.JSONFormatKey { format = formatter.JSONFormat