From 5c7f7454681b405bb52917a30dab4384e97f5fb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20=C4=8Cerm=C3=A1k?= Date: Tue, 12 Dec 2023 16:21:20 +0100 Subject: [PATCH] Remove deprecated field ContainerState.NetworkStatusOld MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This field drags in a dependency on CNI and thereby blocks us from disabling CNI support via a build tag [NO NEW TESTS NEEDED] Signed-off-by: Dan Čermák --- go.mod | 2 +- libpod/container.go | 42 ++---------------------------- libpod/container_internal.go | 2 -- libpod/container_internal_linux.go | 1 - 4 files changed, 3 insertions(+), 44 deletions(-) diff --git a/go.mod b/go.mod index 4a97addba3..8d6eb6fd46 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,6 @@ require ( github.com/buger/goterm v1.0.4 github.com/checkpoint-restore/checkpointctl v1.1.0 github.com/checkpoint-restore/go-criu/v7 v7.0.0 - github.com/containernetworking/cni v1.1.2 github.com/containernetworking/plugins v1.4.0 github.com/containers/buildah v1.33.2-0.20231121195905-d1a1c53c8e1c github.com/containers/common v0.57.1-0.20231206135104-b647eb3a5eea @@ -97,6 +96,7 @@ require ( github.com/containerd/log v0.1.0 // indirect github.com/containerd/stargz-snapshotter/estargz v0.15.1 // indirect github.com/containerd/typeurl/v2 v2.1.1 // indirect + github.com/containernetworking/cni v1.1.2 // indirect github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01 // indirect github.com/containers/luksy v0.0.0-20231030195837-b5a7f79da98b // indirect github.com/coreos/go-oidc/v3 v3.7.0 // indirect diff --git a/libpod/container.go b/libpod/container.go index 9bd8028367..95d3f85e51 100644 --- a/libpod/container.go +++ b/libpod/container.go @@ -13,8 +13,6 @@ import ( "strings" "time" - types040 "github.com/containernetworking/cni/pkg/types/040" - "github.com/containers/common/libnetwork/cni" "github.com/containers/common/libnetwork/types" "github.com/containers/common/pkg/config" "github.com/containers/common/pkg/secrets" @@ -176,13 +174,6 @@ type ContainerState struct { LegacyExecSessions map[string]*legacyExecSession `json:"execSessions,omitempty"` // NetNS is the path or name of the NetNS NetNS string `json:"netns,omitempty"` - // NetworkStatusOld contains the configuration results for all networks - // the pod is attached to. Only populated if we created a network - // namespace for the container, and the network namespace is currently - // active. - // These are DEPRECATED and will be removed in a future release. - // This field is only used for backwarts compatibility. - NetworkStatusOld []*types040.Result `json:"networkResults,omitempty"` // NetworkStatus contains the network Status for all networks // the container is attached to. Only populated if we created a network // namespace for the container, and the network namespace is currently @@ -1374,39 +1365,10 @@ func (c *Container) GetNetworkStatus() (map[string]types.StatusBlock, error) { return c.getNetworkStatus(), nil } -// getNetworkStatus get the current network status from the state. If the container -// still uses the old network status it is converted to the new format. This function +// getNetworkStatus get the current network status from the state. This function // should be used instead of reading c.state.NetworkStatus directly. func (c *Container) getNetworkStatus() map[string]types.StatusBlock { - if c.state.NetworkStatus != nil { - return c.state.NetworkStatus - } - if c.state.NetworkStatusOld != nil { - networks, err := c.networks() - if err != nil { - return nil - } - if len(networks) != len(c.state.NetworkStatusOld) { - return nil - } - result := make(map[string]types.StatusBlock, len(c.state.NetworkStatusOld)) - i := 0 - // Note: NetworkStatusOld does not contain the network names so we get them extra - // We cannot guarantee the same order but after a state refresh it should work - for netName := range networks { - status, err := cni.CNIResultToStatus(c.state.NetworkStatusOld[i]) - if err != nil { - return nil - } - result[netName] = status - i++ - } - c.state.NetworkStatus = result - _ = c.save() - - return result - } - return nil + return c.state.NetworkStatus } func (c *Container) NamespaceMode(ns spec.LinuxNamespaceType, ctrSpec *spec.Spec) string { diff --git a/libpod/container_internal.go b/libpod/container_internal.go index 387aea7b8e..3fa50f5e1d 100644 --- a/libpod/container_internal.go +++ b/libpod/container_internal.go @@ -643,7 +643,6 @@ func resetContainerState(state *ContainerState) { state.StartupHCFailureCount = 0 state.NetNS = "" state.NetworkStatus = nil - state.NetworkStatusOld = nil } // Refresh refreshes the container's state after a restart. @@ -694,7 +693,6 @@ func (c *Container) refresh() error { c.lock = lock c.state.NetworkStatus = nil - c.state.NetworkStatusOld = nil // Rewrite the config if necessary. // Podman 4.0 uses a new port format in the config. diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go index d70b9c78a6..2d392d313b 100644 --- a/libpod/container_internal_linux.go +++ b/libpod/container_internal_linux.go @@ -176,7 +176,6 @@ func (c *Container) cleanupNetwork() error { c.state.NetNS = "" c.state.NetworkStatus = nil - c.state.NetworkStatusOld = nil if c.valid { return c.save()