libpod: remove LegacyExecSessions

This have been deprecated in podman 1.9, it is safe to assume they are
no longer used by anyone one a recent version.

If someone would update from the old version to 6+ they would run into
much more issues already so this can be safely dropped IMO.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger
2026-06-23 16:40:57 +02:00
committed by Matt Heon
parent 596cdd008c
commit b41517d8d4
3 changed files with 14 additions and 46 deletions

View File

@@ -165,10 +165,6 @@ type ContainerState struct {
// ExecSessions contains all exec sessions that are associated with this
// container.
ExecSessions map[string]*ExecSession `json:"newExecSessions,omitempty"`
// LegacyExecSessions are legacy exec sessions from older versions of
// Podman.
// These are DEPRECATED and will be removed in a future release.
LegacyExecSessions map[string]*legacyExecSession `json:"execSessions,omitempty"`
// NetNS is the path or name of the NetNS
NetNS string `json:"netns,omitempty"`
// NetworkStatus contains the network Status for all networks

View File

@@ -153,14 +153,6 @@ func (e *ExecSession) Inspect() (*define.InspectExecSession, error) {
return output, nil
}
// legacyExecSession contains information on an active exec session. It is a
// holdover from a previous Podman version and is DEPRECATED.
type legacyExecSession struct {
ID string `json:"id"`
Command []string `json:"command"`
PID int `json:"pid"`
}
func (c *Container) verifyExecConfig(config *ExecConfig) error {
if config == nil {
return fmt.Errorf("must provide a configuration to ExecCreate: %w", define.ErrInvalidArg)
@@ -957,11 +949,6 @@ func (c *Container) getExecSessionPID(sessionID string) (int, string, error) {
if ok {
return session.PID, session.PIDData, nil
}
oldSession, ok := c.state.LegacyExecSessions[sessionID]
if ok {
return oldSession.PID, "", nil
}
return -1, "", fmt.Errorf("no exec session with ID %s found in container %s: %w", sessionID, c.ID(), define.ErrNoSuchExecSession)
}
@@ -971,12 +958,6 @@ func (c *Container) getExecSessionPID(sessionID string) (int, string, error) {
// function performs further checks to return an accurate list.
func (c *Container) getKnownExecSessions() []string {
knownSessions := []string{}
// First check legacy sessions.
// TODO: This is DEPRECATED and will be removed in a future major
// release.
for sessionID := range c.state.LegacyExecSessions {
knownSessions = append(knownSessions, sessionID)
}
// Next check new exec sessions, but only if in running state
for sessionID, session := range c.state.ExecSessions {
if session.State == define.ExecStateRunning {
@@ -990,7 +971,6 @@ func (c *Container) getKnownExecSessions() []string {
// getActiveExecSessions checks if there are any active exec sessions in the
// current container. Returns an array of active exec sessions.
// Will continue through errors where possible.
// Currently handles both new and legacy, deprecated exec sessions.
func (c *Container) getActiveExecSessions() ([]string, error) {
activeSessions := []string{}
knownSessions := c.getKnownExecSessions()
@@ -1008,28 +988,22 @@ func (c *Container) getActiveExecSessions() ([]string, error) {
continue
}
if !alive {
_, isLegacy := c.state.LegacyExecSessions[id]
if isLegacy {
delete(c.state.LegacyExecSessions, id)
needSave = true
} else {
session := c.state.ExecSessions[id]
exitCode, err := c.readExecExitCode(session.ID())
if err != nil {
if lastErr != nil {
logrus.Errorf("Checking container %s exec sessions: %v", c.ID(), lastErr)
}
lastErr = err
session := c.state.ExecSessions[id]
exitCode, err := c.readExecExitCode(session.ID())
if err != nil {
if lastErr != nil {
logrus.Errorf("Checking container %s exec sessions: %v", c.ID(), lastErr)
}
session.ExitCode = exitCode
session.PID = 0
session.PIDData = ""
session.State = define.ExecStateStopped
c.newExecDiedEvent(session.ID(), exitCode)
needSave = true
lastErr = err
}
session.ExitCode = exitCode
session.PID = 0
session.PIDData = ""
session.State = define.ExecStateStopped
c.newExecDiedEvent(session.ID(), exitCode)
needSave = true
if err := c.cleanupExecBundle(id); err != nil {
if lastErr != nil {
logrus.Errorf("Checking container %s exec sessions: %v", c.ID(), lastErr)
@@ -1085,7 +1059,6 @@ func (c *Container) removeAllExecSessions() error {
}
}
c.state.ExecSessions = nil
c.state.LegacyExecSessions = nil
return lastErr
}

View File

@@ -636,7 +636,6 @@ func resetContainerState(state *ContainerState) {
state.State = define.ContainerStateConfigured
}
state.ExecSessions = make(map[string]*ExecSession)
state.LegacyExecSessions = nil
state.BindMounts = make(map[string]string)
state.RestartPolicyMatch = false
state.RestartCount = 0