@@ -51,20 +51,8 @@ func init() {
5151 Requires : []plugin.Type {
5252 plugins .WarningPlugin ,
5353 },
54- ConfigMigration : func (ctx context.Context , configVersion int , pluginConfigs map [string ]interface {}) error {
55- if configVersion >= version .ConfigVersion {
56- return nil
57- }
58- c , ok := pluginConfigs [string (plugins .GRPCPlugin )+ ".cri" ]
59- if ! ok {
60- return nil
61- }
62- conf := c .(map [string ]interface {})
63- migrateConfig (conf )
64- pluginConfigs [string (plugins .CRIServicePlugin )+ ".runtime" ] = conf
65- return nil
66- },
67- InitFn : initCRIRuntime ,
54+ ConfigMigration : configMigration ,
55+ InitFn : initCRIRuntime ,
6856 })
6957}
7058
@@ -198,12 +186,79 @@ func setGLogLevel() error {
198186 return nil
199187}
200188
201- func migrateConfig (conf map [string ]interface {}) {
202- containerdConf , ok := conf ["containerd" ]
189+ func configMigration (ctx context.Context , configVersion int , pluginConfigs map [string ]interface {}) error {
190+ if configVersion >= version .ConfigVersion {
191+ return nil
192+ }
193+ src , ok := pluginConfigs [string (plugins .GRPCPlugin )+ ".cri" ].(map [string ]interface {})
194+ if ! ok {
195+ return nil
196+ }
197+ dst , ok := pluginConfigs [string (plugins .CRIServicePlugin )+ ".runtime" ].(map [string ]interface {})
198+ if ! ok {
199+ dst = make (map [string ]interface {})
200+ }
201+ migrateConfig (dst , src )
202+ pluginConfigs [string (plugins .CRIServicePlugin )+ ".runtime" ] = dst
203+ return nil
204+ }
205+
206+ func migrateConfig (dst , src map [string ]interface {}) {
207+ for k , v := range src {
208+ switch k {
209+ case "containerd" :
210+ // skip (handled separately below)
211+ continue
212+ case
213+ "sandbox_image" ,
214+ "registry" ,
215+ "image_decryption" ,
216+ "max_concurrent_downloads" ,
217+ "image_pull_progress_timeout" ,
218+ "image_pull_with_sync_fs" ,
219+ "stats_collect_period" :
220+ // skip (moved to cri image service plugin)
221+ continue
222+ case
223+ "disable_tcp_service" ,
224+ "stream_server_address" ,
225+ "stream_server_port" ,
226+ "stream_idle_timeout" ,
227+ "enable_tls_streaming" ,
228+ "x509_key_pair_streaming" :
229+ // skip (moved to cri ServerConfig)
230+ continue
231+ default :
232+ if _ , ok := dst [k ]; ! ok {
233+ dst [k ] = v
234+ }
235+ }
236+ }
237+
238+ // migrate cri containerd configs
239+ containerdConf , ok := src ["containerd" ].(map [string ]interface {})
203240 if ! ok {
204241 return
205242 }
206- runtimesConf , ok := containerdConf .(map [string ]interface {})["runtimes" ]
243+ newContainerdConf , ok := dst ["containerd" ].(map [string ]interface {})
244+ if ! ok {
245+ newContainerdConf = map [string ]interface {}{}
246+ }
247+ for k , v := range containerdConf {
248+ switch k {
249+ case "snapshotter" , "disable_snapshot_annotations" , "discard_unpacked_layers" :
250+ // skip (moved to cri image service plugin)
251+ continue
252+ default :
253+ if _ , ok := newContainerdConf [k ]; ! ok {
254+ newContainerdConf [k ] = v
255+ }
256+ }
257+ }
258+ dst ["containerd" ] = newContainerdConf
259+
260+ // migrate runtimes configs
261+ runtimesConf , ok := newContainerdConf ["runtimes" ]
207262 if ! ok {
208263 return
209264 }
@@ -212,6 +267,7 @@ func migrateConfig(conf map[string]interface{}) {
212267 if sandboxMode , ok := runtimeConf ["sandbox_mode" ]; ok {
213268 if _ , ok := runtimeConf ["sandboxer" ]; ! ok {
214269 runtimeConf ["sandboxer" ] = sandboxMode
270+ delete (runtimeConf , "sandbox_mode" )
215271 }
216272 }
217273 }
0 commit comments