Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Dockerfile CMD to correct instance manager binary name. #664

Closed
wants to merge 1 commit into from

Conversation

aznashwan
Copy link

@aznashwan aznashwan commented Sep 9, 2024

Which issue(s) this PR fixes:

None.
Considering the longhorn-instance-manager executable requires at least some arguments to it so everyone who's ever used this image overrode CMD, this is not really an issue in practice, it's only incorrect if you pass no arguments.

What this PR does / why we need it:

Because the current CMD arg which gets passed to tini doesn't exist, leading to this error if you run the image plainly:

$ docker run -it longhornio/longhorn-instance-manager:v1.7.0
[FATAL tini (7)] exec longhorn failed: No such file or directory

Special notes for your reviewer:

Binary built as longhorn-instance-manager here.

Binary added to Docker image under the same longhorn-instance-manager name here.

I am 95% sure the cause of this is someone just copy-pasting the Engine Dockerfile, whose binary is indeed plainly named longhorn.

Additional documentation or context

Summary by CodeRabbit

  • New Features

    • Updated the container's startup command to launch the longhorn-instance-manager, enhancing functionality.
  • Bug Fixes

    • Streamlined the installation process for development tools and dependencies, improving build reliability.
  • Chores

    • Refined the build process for various components, ensuring all necessary binaries are included.

This patch fixes the CMD in the longhorn-instance-manager container
image.

Signed-off-by: Nashwan Azhari <nazhari@cloudbasesolutions.com>
@aznashwan
Copy link
Author

I am unfortunately unsure what the commit message linter wants from me, but I'll gladly take suggestions on how to fix it.

Copy link

This PR is stale because it has been open for 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the stale label Oct 25, 2024
Copy link

coderabbitai bot commented Oct 25, 2024

Walkthrough

The changes in the Dockerfile involve modifications to the build and installation processes across three stages. The base images remain unchanged, but the installation of additional development tools has been included. The build commands for various components have been slightly adjusted, particularly for spdk. A significant update is the alteration of the container's startup command from longhorn to longhorn-instance-manager, indicating a new primary executable. The overall structure ensures that all necessary binaries are copied and verified.

Changes

File Change Summary
package/Dockerfile - Retained installation of golint.
- Streamlined repository additions and expanded package installations to include cmake, gcc, etc.
- Minor adjustments in build commands for spdk.
- Updated CMD from ["longhorn"] to ["longhorn-instance-manager"].
- Consistent copying of binaries and verification of dependencies.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Docker
    participant Components

    User->>Docker: Build Image
    Docker->>Components: Install golint
    Docker->>Components: Install cmake, gcc, etc.
    Docker->>Components: Build liblonghorn, TGT, spdk, etc.
    Docker->>Components: Copy binaries
    Docker->>User: Image Ready

    User->>Docker: Run Container
    Docker->>Components: Start longhorn-instance-manager
Loading

🐰 "In the Docker's den, changes abound,
With tools and commands, new paths are found.
From longhorn to manager, we take a leap,
Building our dreams, in code we keep.
Hops of joy, as binaries align,
In this container, everything's fine!" 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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 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

@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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between eea871e and f8ea3e0.

📒 Files selected for processing (1)
  • package/Dockerfile (1 hunks)
🔇 Additional comments (2)
package/Dockerfile (2)

Line range hint 175-176: Clarify the need for both instance manager binaries.

The Dockerfile copies two similarly named binaries:

  • /usr/local/bin/longhorn-instance-manager
  • /usr/local/bin/instance-manager

Please clarify if both are needed or if one should be removed to avoid confusion.

Let's check if they're different:

#!/bin/bash
# Description: Compare the two binaries
# Expected: If different, they serve different purposes. If identical, one might be redundant.

# Check if binaries are identical
cmp /usr/local/bin/longhorn-instance-manager /usr/local/bin/instance-manager || echo "Binaries are different"

180-180: LGTM! The CMD now correctly references the existing binary.

The change fixes the "[FATAL tini (7)] exec longhorn failed" error by updating the CMD to use the correct binary name that is copied into the image.

Let's verify the binary paths and permissions:

✅ Verification successful

The CMD change is correct and safe to use

The verification confirms that:

  1. Only longhorn-instance-manager is copied to /usr/local/bin/ in the Dockerfile
  2. There is no separate instance-manager binary being copied
  3. The CMD correctly references the binary that is actually present in the image

The original review comment's concern about two similar binaries was unfounded, as there is only one binary being copied into the image.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify binary existence and permissions
# Expected: Both commands should succeed, confirming binary exists and is executable

# Check if the binary exists and is executable
ls -l /usr/local/bin/longhorn-instance-manager
ls -l /usr/local/bin/instance-manager

Length of output: 204


Script:

#!/bin/bash
# Let's verify the existence of binaries in a different way
fd "longhorn-instance-manager|instance-manager" /usr/local/bin || echo "No files found"

# Let's also check the Dockerfile to understand the binary copying
rg "COPY.*bin.*instance-manager" package/Dockerfile

Length of output: 318

Comment on lines 179 to +180

CMD ["longhorn"]
CMD ["longhorn-instance-manager"]
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider Docker best practices improvements.

While the current change fixes the immediate issue, consider these improvements:

  1. Add a WORKDIR directive before CMD
  2. Use the full path in CMD for clarity
+WORKDIR /usr/local/bin
-CMD ["longhorn-instance-manager"]
+CMD ["/usr/local/bin/longhorn-instance-manager"]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
CMD ["longhorn"]
CMD ["longhorn-instance-manager"]
WORKDIR /usr/local/bin
CMD ["/usr/local/bin/longhorn-instance-manager"]

Copy link

github-actions bot commented Nov 5, 2024

This PR was closed because it has been stalled for 10 days with no activity.

@github-actions github-actions bot closed this Nov 5, 2024
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.

1 participant