mirror of
https://github.com/containers/podman.git
synced 2025-06-27 13:38:49 +08:00
Remove deprecated field ContainerState.NetworkStatusOld
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 <dcermak@suse.com>
This commit is contained in:
2
go.mod
2
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
|
||||
|
@ -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 {
|
||||
|
@ -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.
|
||||
|
@ -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()
|
||||
|
Reference in New Issue
Block a user