@@ -5,14 +5,11 @@ package libpod
5
5
import (
6
6
"fmt"
7
7
"os"
8
- "path/filepath"
9
8
"strconv"
10
9
"syscall"
11
10
12
- "github.com/containers/podman/v5/libpod/define"
13
11
"github.com/containers/podman/v5/pkg/rootless"
14
12
"github.com/containers/podman/v5/pkg/util"
15
- "github.com/sirupsen/logrus"
16
13
)
17
14
18
15
func (r * Runtime ) stopPauseProcess () error {
@@ -41,80 +38,3 @@ func (r *Runtime) stopPauseProcess() error {
41
38
}
42
39
return nil
43
40
}
44
-
45
- // Migrate stops the rootless pause process and performs any necessary database
46
- // migrations that are required. It can also migrate all containers to a new OCI
47
- // runtime, if requested.
48
- func (r * Runtime ) Migrate (newRuntime string ) error {
49
- // Acquire the alive lock and hold it.
50
- // Ensures that we don't let other Podman commands run while we are
51
- // rewriting things in the DB.
52
- aliveLock , err := r .getRuntimeAliveLock ()
53
- if err != nil {
54
- return fmt .Errorf ("retrieving alive lock: %w" , err )
55
- }
56
- aliveLock .Lock ()
57
- defer aliveLock .Unlock ()
58
-
59
- if ! r .valid {
60
- return define .ErrRuntimeStopped
61
- }
62
-
63
- runningContainers , err := r .GetRunningContainers ()
64
- if err != nil {
65
- return err
66
- }
67
-
68
- allCtrs , err := r .state .AllContainers (false )
69
- if err != nil {
70
- return err
71
- }
72
-
73
- logrus .Infof ("Stopping all containers" )
74
- for _ , ctr := range runningContainers {
75
- fmt .Printf ("stopped %s\n " , ctr .ID ())
76
- if err := ctr .Stop (); err != nil {
77
- return fmt .Errorf ("cannot stop container %s: %w" , ctr .ID (), err )
78
- }
79
- }
80
-
81
- // Did the user request a new runtime?
82
- runtimeChangeRequested := newRuntime != ""
83
- var requestedRuntime OCIRuntime
84
- if runtimeChangeRequested {
85
- runtime , exists := r .ociRuntimes [newRuntime ]
86
- if ! exists {
87
- return fmt .Errorf ("change to runtime %q requested but no such runtime is defined: %w" , newRuntime , define .ErrInvalidArg )
88
- }
89
- requestedRuntime = runtime
90
- }
91
-
92
- for _ , ctr := range allCtrs {
93
- needsWrite := false
94
-
95
- // Reset pause process location
96
- oldLocation := filepath .Join (ctr .state .RunDir , "conmon.pid" )
97
- if ctr .config .ConmonPidFile == oldLocation {
98
- logrus .Infof ("Changing conmon PID file for %s" , ctr .ID ())
99
- ctr .config .ConmonPidFile = filepath .Join (ctr .config .StaticDir , "conmon.pid" )
100
- needsWrite = true
101
- }
102
-
103
- // Reset runtime
104
- if runtimeChangeRequested && ctr .config .OCIRuntime != newRuntime {
105
- logrus .Infof ("Resetting container %s runtime to runtime %s" , ctr .ID (), newRuntime )
106
- ctr .config .OCIRuntime = newRuntime
107
- ctr .ociRuntime = requestedRuntime
108
-
109
- needsWrite = true
110
- }
111
-
112
- if needsWrite {
113
- if err := r .state .RewriteContainerConfig (ctr , ctr .config ); err != nil {
114
- return fmt .Errorf ("rewriting config for container %s: %w" , ctr .ID (), err )
115
- }
116
- }
117
- }
118
-
119
- return r .stopPauseProcess ()
120
- }
0 commit comments