8000 fix(ContainerList): group containers missing engineName by axel7083 · Pull Request #13554 · podman-desktop/podman-desktop · GitHub
[go: up one dir, main page]

Skip to content

Conversation

axel7083
Copy link
Contributor

What does this PR do?

Update ContainerUtils to properly provide the engineName when creating ContainerGroupInfoUI objects

Screenshot / video of UI

Before After
Image image

What issues does this PR fix or reference?

Fixes #13553

How to test this PR?

  • Tests are covering the bug fix or the new feature

Signed-off-by: axel7083 <42176370+axel7083@users.noreply.github.com>
@axel7083 axel7083 requested review from benoitf and a team as code owners August 11, 2025 09:54
@axel7083 axel7083 requested review from cdrage and gastoner and removed request for a team August 11, 2025 09:54
Copy link
Contributor
coderabbitai bot commented Aug 11, 2025
📝 Walkthrough

Walkthrough

This PR adds engineName support and propagation across container data and group UI models. It updates ContainerInfo, ContainerGroupPartInfoUI, and ContainerGroupInfoUI to include an optional engineName. Container grouping logic in container-utils now forwards engineName for COMPOSE, POD, and STANDALONE cases, and sets engineName on aggregated group objects. Tests were updated to supply and assert engineName propagation for compose and pod scenarios.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Assessment against linked issues

Objective Addressed Explanation
Ensure pods and compose groups have engineName set for environment column usage (#13553)

Possibly related PRs

Suggested reviewers

  • dgolovin
  • benoitf
  • axel7083
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag 8000 @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor
@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @axel7083 - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
codecov bot commented Aug 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Contributor
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🔭 Outside diff range comments (2)
packages/renderer/src/lib/container/container-utils.ts (2)

127-131: Bug: optional chaining misuse may cause runtime error in getOpeningUrls

If Ports is undefined, containerInfo.Ports?.filter(...) returns undefined, and the subsequent .map(...) calls will throw. Reuse getPorts to avoid this.

-  getOpeningUrls(containerInfo: ContainerInfo): string[] {
-    return containerInfo.Ports?.filter(port => port.PublicPort)
-      .map(port => port.PublicPort)
-      .map(port => `http://localhost:${port}`);
-  }
+  getOpeningUrls(containerInfo: ContainerInfo): string[] {
+    return this.getPorts(containerInfo)
+      .map(port => port.PublicPort)
+      .map(port => `http://localhost:${port}`);
+  }

215-222: Include engineId in the Standalone group for uniformity

The ContainerGroupPartInfoUI objects for COMPOSE and POD both include engineId, but the STANDALONE branch does not. Downstream components (e.g. ContainerDetailsSummary.svelte) expect groupInfo.engineId, so we should add it here.

• File: packages/renderer/src/lib/container/container-utils.ts
Location: return block for ContainerGroupInfoTypeUI.STANDALONE (≈ lines 215–222)

     return {
       name: this.getName(containerInfo),
       type: ContainerGroupInfoTypeUI.STANDALONE,
       status: (containerInfo.Status ?? '').toUpperCase(),
       engineType: containerInfo.engineType,
       id: containerInfo.Id, // since the container is standalone, let's use its ID as groupInfo#id
+      engineId: containerInfo.engineId,
       engineName: containerInfo.engineName,
     };

This ensures all group types expose engineId consistently and avoids undefined references in consumers.

🧹 Nitpick comments (2)
packages/renderer/src/lib/container/container-utils.spec.ts (1)

447-466: Add a standalone-group test for engineName propagation

For completeness, add a test ensuring standalone groups also carry engineName from the container. Example:

+test('standalone container group should propagate engineName', async () => {
+  const containerInfo = {
+    Id: 'standalone1',
+    Image: 'docker.io/library/busybox:latest',
+    Names: ['/standalone1'],
+    State: 'RUNNING',
+    ImageID: 'sha256:dummy-sha256',
+    engineId: 'podman',
+    engineName: 'podman',
+    Labels: {},
+  } as unknown as ContainerInfo;
+
+  const [containerUI] = [containerUtils.getContainerInfoUI(containerInfo)];
+  const groups = containerUtils.getContainerGroups([containerUI]);
+  expect(groups).toHaveLength(1);
+  const group = groups[0];
+  expect(group.type).toBe(ContainerGroupInfoTypeUI.STANDALONE);
+  expect(group.engineName).toBe('podman');
+});

I can add this test in the right spot if you confirm the preferred location.

packages/renderer/src/lib/container/container-utils.ts (1)

100-102: Minor: simplify getPorts by removing identity map

-  return containerInfo.Ports?.filter(port => port.PublicPort).map(port => port) || [];
+  return containerInfo.Ports?.filter(port => port.PublicPort) ?? [];
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d417fb8 and 269dad5.

📒 Files selected for processing (2)
  • packages/renderer/src/lib/container/container-utils.spec.ts (6 hunks)
  • packages/renderer/src/lib/container/container-utils.ts (4 hunks)
🔇 Additional comments (7)
packages/renderer/src/lib/container/container-utils.spec.ts (4)

162-162: Compose tests: engineName added to inputs — LGTM

Including engineName: 'podman' in both compose containers is correct and ensures the group engineName can be asserted deterministically.

Also applies to: 171-171


182-182: Compose group engineName assertion — LGTM

Asserting group.engineName === 'podman' covers the regression and validates propagation.


199-199: Pod tests: engineName added to inputs — LGTM

Setting engineName: 'podman' on both pod containers is appropriate for verifying group propagation.

Also applies to: 208-208


218-218: Pod group engineName assertion — LGTM

Assertion confirms propagation for pods; aligns with the bug fix.

packages/renderer/src/lib/container/container-utils.ts (3)

196-197: Compose group: propagate engineName — LGTM

Including engineName here fixes the missing environment for compose groups and matches how id is already disambiguated by engineId.


209-211: Pod group: propagate engineName — LGTM

Propagation looks correct and aligns with the UI’s switch to engineName.


250-251: getContainerGroups: propagate engineName — LGTM

Carrying engineName into ContainerGroupInfoUI ensures UI visibility for Pods/Compose. Good.

Copy link
Contributor
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🔭 Outside diff range comments (3)
packages/renderer/src/lib/container/container-utils.ts (3)

191-197: Propagate engineName with a safe fallback for COMPOSE groups

If any source doesn’t set engineName, environment could still be empty. Use a fallback to engineType to keep UI populated.

Apply:

       type: ContainerGroupInfoTypeUI.COMPOSE,
       engineId: containerInfo.engineId,
       engineType: containerInfo.engineType,
-      engineName: containerInfo.engineName,
+      engineName: containerInfo.engineName ?? containerInfo.engineType,

215-222: Standalone groups: add engineName fallback

Keeps environment info populated if engineName is missing.

Apply:

       type: ContainerGroupInfoTypeUI.STANDALONE,
       status: (containerInfo.Status ?? '').toUpperCase(),
       engineType: containerInfo.engineType,
       id: containerInfo.Id, // since the container is standalone, let's use its ID as groupInfo#id
-      engineName: containerInfo.engineName,
+      engineName: containerInfo.engineName ?? containerInfo.engineType,

241-253: Group aggregation: handle missing engineName gracefully

On creating a non-standalone group, fall back from group.engineName to the first container’s engineName, then to group.engineType. This ensures every group has an engineName value.

Apply this change in
packages/renderer/src/lib/container/container-utils.ts (inside ContainerUtils.getContainerGroups):

           engineId: group.engineId,
           engineType: group.engineType,
-          engineName: group.engineName,
+          engineName: group.engineName
+            ?? container.engineName
+            ?? group.engineType,
           allContainersCount: 0,
           containers: [],

group.engineName remains the primary source
container.engineName (the current ContainerInfo) covers cases where the group lacks an engineName
group.engineType (e.g. 'podman' | 'docker') is the final fallback

🧹 Nitpick comments (3)
packages/renderer/src/lib/container/container-utils.spec.ts (2)

162-163: Good: asserting engineName propagation for COMPOSE groups

The additions validate the fix by ensuring engineName flows into group results. Consider adding a STANDALONE case to assert engineName is preserved there as well, to prevent regressions.

Also applies to: 171-172, 182-183


199-200: Good: asserting engineName propagation for POD groups

Solid coverage. Optional: add a test where two pods share the same name across different engines to ensure groups remain distinct and engineName is correct (see code comment in container-utils.ts about POD id uniqueness).

Also applies to: 208-209, 218-219

packages/renderer/src/lib/container/container-utils.ts (1)

203-211: Two tweaks for POD groups: (1) engineName fallback, (2) id uniqueness across engines

  • Add a fallback for engineName (same rationale as COMPOSE).
  • To avoid cross-engine collisions, consider prefixing pod id with engineId (compose already does this).

Apply:

-        id: podInfo.id,
+        id: `${containerInfo.engineId}:${podInfo.id}`,
         status: (podInfo.status ?? '').toUpperCase(),
         engineId: containerInfo.engineId,
         engineType: containerInfo.engineType,
-        engineName: containerInfo.engineName,
+        engineName: containerInfo.engineName ?? containerInfo.engineType,
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d417fb8 and 269dad5.

📒 Files selected for processing (2)
  • packages/renderer/src/lib/container/container-utils.spec.ts (6 hunks)
  • packages/renderer/src/lib/container/container-utils.ts (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: unit tests / macos-15
  • GitHub Check: unit tests / windows-2025
  • GitHub Check: smoke e2e tests (development)
  • GitHub Check: smoke e2e tests (production)

Copy link
Contributor
@gastoner gastoner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM on Linux

@axel7083 axel7083 merged commit 23277a1 into podman-desktop:main Aug 12, 2025
25 of 38 checks passed
@podman-desktop-bot podman-desktop-bot added this to the 1.21.0 milestone Aug 12, 2025
@benoitf
Copy link
Collaborator
benoitf commented Aug 12, 2025

thanks @axel7083

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug(ContainerList): container groups do not have environment set
4 participants
0