@@ -273,41 +273,34 @@ func (r *Adaptation) UpdatePodSandbox(ctx context.Context, req *UpdatePodSandbox
273273}
274274
275275// PodSandboxStatus relays the corresponding CRI request to plugins.
276- // If a plugin returns IP addresses, those will be returned to the caller.
277- // An error is returned if multiple plugins attempt to set the same field.
276+ // IP addresses returned by plugins are aggregated into the response: the first
277+ // non-empty primary IP becomes the response's primary IP, and all remaining IPs
278+ // (including subsequent primary IPs from other plugins) are appended to the
279+ // additional IPs list. Kubelet uses the first IP (or first dual-stack pair) and
280+ // ignores the rest, matching the standard CRI PodSandboxStatus contract.
278281func (r * Adaptation ) PodSandboxStatus (ctx context.Context , req * PodSandboxStatusRequest ) (* PodSandboxStatusResponse , error ) {
279282 r .Lock ()
280283 defer r .Unlock ()
281284 defer r .removeClosedPlugins ()
282285
283- var (
284- rsp = & PodSandboxStatusResponse {}
285- ipOwner = ""
286- additionalIpsOwner = ""
287- )
286+ rsp := & PodSandboxStatusResponse {}
288287
289288 for _ , plugin := range r .plugins {
290289 pluginRsp , err := plugin .podSandboxStatus (ctx , req )
291290 if err != nil {
292291 return nil , err
293292 }
294- if pluginRsp == nil || ( pluginRsp . Ip == "" && len ( pluginRsp . AdditionalIps ) == 0 ) {
293+ if pluginRsp == nil {
295294 continue
296295 }
297296 if pluginRsp .Ip != "" {
298- if ipOwner != "" {
299- return nil , fmt .Errorf ("plugins %q and %q both tried to set PodSandboxStatus IP address field" , ipOwner , plugin .name ())
300- }
301- rsp .Ip = pluginRsp .Ip
302- ipOwner = plugin .name ()
303- }
304- if len (pluginRsp .AdditionalIps ) > 0 {
305- if additionalIpsOwner != "" {
306- return nil , fmt .Errorf ("plugins %q and %q both tried to set PodSandboxStatus additional IP addresses field" , additionalIpsOwner , plugin .name ())
297+ if rsp .Ip == "" {
298+ rsp .Ip = pluginRsp .Ip
299+ } else {
300+ rsp .AdditionalIps = append (rsp .AdditionalIps , pluginRsp .Ip )
307301 }
308- rsp .AdditionalIps = pluginRsp .AdditionalIps
309- additionalIpsOwner = plugin .name ()
310302 }
303+ rsp .AdditionalIps = append (rsp .AdditionalIps , pluginRsp .AdditionalIps ... )
311304 }
312305
313306 return rsp , nil
0 commit comments