summaryrefslogtreecommitdiff
path: root/pkg/domain/infra/abi
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/domain/infra/abi')
-rw-r--r--pkg/domain/infra/abi/play.go35
-rw-r--r--pkg/domain/infra/abi/pods.go58
2 files changed, 64 insertions, 29 deletions
diff --git a/pkg/domain/infra/abi/play.go b/pkg/domain/infra/abi/play.go
index 6ea20a4f2..12786afcd 100644
--- a/pkg/domain/infra/abi/play.go
+++ b/pkg/domain/infra/abi/play.go
@@ -661,9 +661,10 @@ func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podY
opts = append(opts, libpod.WithSdNotifyMode(sdNotifyMode))
+ var proxy *notifyproxy.NotifyProxy
// Create a notify proxy for the container.
if sdNotifyMode != "" && sdNotifyMode != define.SdNotifyModeIgnore {
- proxy, err := notifyproxy.New("")
+ proxy, err = notifyproxy.New("")
if err != nil {
return nil, err
}
@@ -675,6 +676,9 @@ func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podY
if err != nil {
return nil, err
}
+ if proxy != nil {
+ proxy.AddContainer(ctr)
+ }
containers = append(containers, ctr)
}
@@ -774,21 +778,26 @@ func (ic *ContainerEngine) getImageAndLabelInfo(ctx context.Context, cwd string,
}
// Handle kube annotations
- for k, v := range annotations {
- switch k {
- // Auto update annotation without container name will apply to
- // all containers within the pod
- case autoupdate.Label, autoupdate.AuthfileLabel:
- labels[k] = v
- // Auto update annotation with container name will apply only
- // to the specified container
- case fmt.Sprintf("%s/%s", autoupdate.Label, container.Name),
- fmt.Sprintf("%s/%s", autoupdate.AuthfileLabel, container.Name):
- prefixAndCtr := strings.Split(k, "/")
- labels[prefixAndCtr[0]] = v
+ setLabel := func(label string) {
+ var result string
+ ctrSpecific := fmt.Sprintf("%s/%s", label, container.Name)
+ for k, v := range annotations {
+ switch k {
+ case label:
+ result = v
+ case ctrSpecific:
+ labels[label] = v
+ return
+ }
+ }
+ if result != "" {
+ labels[label] = result
}
}
+ setLabel(autoupdate.Label)
+ setLabel(autoupdate.AuthfileLabel)
+
return pulledImage, labels, nil
}
diff --git a/pkg/domain/infra/abi/pods.go b/pkg/domain/infra/abi/pods.go
index 03c8082c4..68f2fa125 100644
--- a/pkg/domain/infra/abi/pods.go
+++ b/pkg/domain/infra/abi/pods.go
@@ -505,23 +505,49 @@ func (ic *ContainerEngine) PodPs(ctx context.Context, options entities.PodPSOpti
return reports, nil
}
-func (ic *ContainerEngine) PodInspect(ctx context.Context, options entities.PodInspectOptions) (*entities.PodInspectReport, error) {
- var (
- pod *libpod.Pod
- err error
- )
- // Look up the pod.
+func (ic *ContainerEngine) PodInspect(ctx context.Context, nameOrIDs []string, options entities.InspectOptions) ([]*entities.PodInspectReport, []error, error) {
if options.Latest {
- pod, err = ic.Libpod.GetLatestPod()
- } else {
- pod, err = ic.Libpod.LookupPod(options.NameOrID)
- }
- if err != nil {
- return nil, fmt.Errorf("unable to look up requested container: %w", err)
+ pod, err := ic.Libpod.GetLatestPod()
+ if err != nil {
+ return nil, nil, err
+ }
+ inspect, err := pod.Inspect()
+ if err != nil {
+ return nil, nil, err
+ }
+
+ return []*entities.PodInspectReport{
+ {
+ InspectPodData: inspect,
+ },
+ }, nil, nil
}
- inspect, err := pod.Inspect()
- if err != nil {
- return nil, err
+
+ var errs []error
+ podReport := make([]*entities.PodInspectReport, 0, len(nameOrIDs))
+ for _, name := range nameOrIDs {
+ pod, err := ic.Libpod.LookupPod(name)
+ if err != nil {
+ // ErrNoSuchPod is non-fatal, other errors will be
+ // treated as fatal.
+ if errors.Is(err, define.ErrNoSuchPod) {
+ errs = append(errs, fmt.Errorf("no such pod %s", name))
+ continue
+ }
+ return nil, nil, err
+ }
+
+ inspect, err := pod.Inspect()
+ if err != nil {
+ // ErrNoSuchPod is non-fatal, other errors will be
+ // treated as fatal.
+ if errors.Is(err, define.ErrNoSuchPod) {
+ errs = append(errs, fmt.Errorf("no such pod %s", name))
+ continue
+ }
+ return nil, nil, err
+ }
+ podReport = append(podReport, &entities.PodInspectReport{InspectPodData: inspect})
}
- return &entities.PodInspectReport{InspectPodData: inspect}, nil
+ return podReport, errs, nil
}