Browse code

Revert "API: /info: remove BridgeNfIptables, BridgeNfIp6tables fields"

This reverts commit 5d2006256f15f7252c11bd72d632de26a8b2ff06, which
caused some issues in the docker/cli formatting code that needs some
investigating.

Let's (temporarily) revert this while we look what's wrong.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2025/04/11 21:47:10
Showing 5 changed files
... ...
@@ -122,13 +122,6 @@ func (s *systemRouter) getInfo(ctx context.Context, w http.ResponseWriter, r *ht
122 122
 			info.ContainerdCommit.Expected = info.ContainerdCommit.ID //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.49.
123 123
 			info.RuncCommit.Expected = info.RuncCommit.ID             //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.49.
124 124
 			info.InitCommit.Expected = info.InitCommit.ID             //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.49.
125
-
126
-			// These fields are omitted in > API 1.49, and always false
127
-			// older API versions.
128
-			info.ExtraFields = map[string]any{
129
-				"BridgeNfIptables":  json.RawMessage("false"),
130
-				"BridgeNfIp6tables": json.RawMessage("false"),
131
-			}
132 125
 		}
133 126
 		if versions.GreaterThanOrEqualTo(version, "1.42") {
134 127
 			info.KernelMemory = false
... ...
@@ -1,11 +1,6 @@
1
-// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
2
-//go:build go1.22
3
-
4 1
 package system
5 2
 
6 3
 import (
7
-	"encoding/json"
8
-
9 4
 	"github.com/docker/docker/api/types/container"
10 5
 	"github.com/docker/docker/api/types/registry"
11 6
 	"github.com/docker/docker/api/types/swarm"
... ...
@@ -34,6 +29,8 @@ type Info struct {
34 34
 	CPUSet             bool
35 35
 	PidsLimit          bool
36 36
 	IPv4Forwarding     bool
37
+	BridgeNfIptables   bool `json:"BridgeNfIptables"`  // Deprecated: netfilter module is now loaded on-demand and no longer during daemon startup, making this field obsolete. This field is always false and will be removed in the next release.
38
+	BridgeNfIP6tables  bool `json:"BridgeNfIp6tables"` // Deprecated: netfilter module is now loaded on-demand and no longer during daemon startup, making this field obsolete. This field is always false and will be removed in the next release.
37 39
 	Debug              bool
38 40
 	NFd                int
39 41
 	OomKillDisable     bool
... ...
@@ -86,26 +83,6 @@ type Info struct {
86 86
 	// messages for the user, and are not intended to be parsed / used for
87 87
 	// other purposes, as they do not have a fixed format.
88 88
 	Warnings []string
89
-
90
-	// ExtraFields is for internal use to include deprecated fields on older API versions.
91
-	ExtraFields map[string]any `json:"-"`
92
-}
93
-
94
-// MarshalJSON implements a custom marshaler to include legacy fields
95
-// in API responses.
96
-func (sc *Info) MarshalJSON() ([]byte, error) {
97
-	type tmp Info
98
-	base, err := json.Marshal((*tmp)(sc))
99
-	if err != nil {
100
-		return nil, err
101
-	}
102
-	var merged map[string]any
103
-	_ = json.Unmarshal(base, &merged)
104
-
105
-	for k, v := range sc.ExtraFields {
106
-		merged[k] = v
107
-	}
108
-	return json.Marshal(merged)
109 89
 }
110 90
 
111 91
 // ContainerdInfo holds information about the containerd instance used by the daemon.
... ...
@@ -29,9 +29,6 @@ keywords: "API, Docker, rcli, REST, documentation"
29 29
 * Deprecated: The `ContainerdCommit.Expected`, `RuncCommit.Expected`, and
30 30
   `InitCommit.Expected` fields in the `GET /info` endpoint were deprecated
31 31
   in API v1.48, and are now omitted in API v1.49.
32
-* Deprecated: The `BridgeNfIptables` and `BridgeNfIp6tables` fields in the
33
-  `GET /info` response were deprecated in API v1.48, and are now omitted
34
-  in API v1.49.
35 32
 
36 33
 ## v1.48 API changes
37 34
 
... ...
@@ -3,13 +3,9 @@
3 3
 package system // import "github.com/docker/docker/integration/system"
4 4
 
5 5
 import (
6
-	"encoding/json"
7
-	"io"
8
-	"net/http"
9 6
 	"testing"
10 7
 
11 8
 	"github.com/docker/docker/client"
12
-	"github.com/docker/docker/testutil/request"
13 9
 	"gotest.tools/v3/assert"
14 10
 	is "gotest.tools/v3/assert/cmp"
15 11
 )
... ...
@@ -51,56 +47,3 @@ func TestInfoBinaryCommits(t *testing.T) {
51 51
 		assert.Check(t, is.Equal(info.RuncCommit.Expected, info.RuncCommit.ID)) //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.49.
52 52
 	})
53 53
 }
54
-
55
-func TestInfoLegacyFields(t *testing.T) {
56
-	ctx := setupTest(t)
57
-
58
-	const notPresent = "expected field to not be present"
59
-
60
-	tests := []struct {
61
-		name           string
62
-		url            string
63
-		expectedFields map[string]any
64
-	}{
65
-		{
66
-			name: "api v1.48 legacy bridge-nftables",
67
-			url:  "/v1.48/info",
68
-			expectedFields: map[string]any{
69
-				"BridgeNfIp6tables": false,
70
-				"BridgeNfIptables":  false,
71
-			},
72
-		},
73
-		{
74
-			name: "api v1.49 legacy bridge-nftables",
75
-			url:  "/v1.49/info",
76
-			expectedFields: map[string]any{
77
-				"BridgeNfIp6tables": notPresent,
78
-				"BridgeNfIptables":  notPresent,
79
-			},
80
-		},
81
-	}
82
-	for _, tc := range tests {
83
-		t.Run(tc.name, func(t *testing.T) {
84
-			res, _, err := request.Get(ctx, tc.url)
85
-			assert.NilError(t, err)
86
-			assert.Equal(t, res.StatusCode, http.StatusOK)
87
-			body, err := io.ReadAll(res.Body)
88
-			assert.NilError(t, err)
89
-
90
-			actual := map[string]any{}
91
-			err = json.Unmarshal(body, &actual)
92
-			assert.NilError(t, err, string(body))
93
-
94
-			for field, expectedValue := range tc.expectedFields {
95
-				if expectedValue == notPresent {
96
-					_, found := actual[field]
97
-					assert.Assert(t, !found, "field %s should not be present", field)
98
-				} else {
99
-					_, found := actual[field]
100
-					assert.Assert(t, found, "field %s should be present", field)
101
-					assert.Check(t, is.DeepEqual(actual[field], expectedValue))
102
-				}
103
-			}
104
-		})
105
-	}
106
-}
... ...
@@ -24,6 +24,16 @@ type SysInfo struct {
24 24
 	// Whether IPv4 forwarding is supported or not, if this was disabled, networking will not work
25 25
 	IPv4ForwardingDisabled bool
26 26
 
27
+	// Whether bridge-nf-call-iptables is supported or not
28
+	//
29
+	// Deprecated: netfilter module is now loaded on-demand and no longer during daemon startup, making this field obsolete. This field is always false and will be removed in the next release.
30
+	BridgeNFCallIPTablesDisabled bool
31
+
32
+	// Whether bridge-nf-call-ip6tables is supported or not
33
+	//
34
+	// Deprecated: netfilter module is now loaded on-demand and no longer during daemon startup, making this field obsolete. This field is always false and will be removed in the next release.
35
+	BridgeNFCallIP6TablesDisabled bool
36
+
27 37
 	// Whether the cgroup has the mountpoint of "devices" or not
28 38
 	CgroupDevicesEnabled bool
29 39