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

Update InfluxDB Integration to Version 2 & Simplify Dependencies #356

Closed
wants to merge 3 commits into from

Conversation

StevenSlaa
Copy link

@StevenSlaa StevenSlaa commented Oct 31, 2024

logo

Summary

This pull request updates the InfluxDB integration to use InfluxDB v2 and simplifies the Dockerfile by removing unnecessary dependencies. Key improvements and adjustments are outlined below.

Changes

  1. Update to InfluxDB v2:

    • Upgraded to the latest InfluxDB v2 release (2.7.1), which includes a new API and enhanced features.
    • Updated setup commands and environment configuration for compatibility with v2.
  2. Removal of Deprecated Components:

    • Removed Chronograf and Kapacitor, as these are no longer required with the InfluxDB v2 setup and add unnecessary complexity.
  3. Simplified Dockerfile:

    • Removed unnecessary apt packages:
      • libnginx-mod-http-lua, luarocks, lua-resty-http, nginx, and procps packages were removed as they are not required for basic InfluxDB functionality.
    • Reduced image size by limiting installed packages to only those necessary for InfluxDB.
  4. Updated Configuration:

    • Adjusted the config.json to enhance compatibility with InfluxDB v2 (removed uneccesary port configurations for v2).
    • Updated icon and logo to main accuracy of the update to InfluxDB v2.

Related Issues:

Impact

This update aligns the integration with modern InfluxDB standards, reduces Docker image size, and enhances maintainability by removing redundant components. Existing users will need to follow updated setup instructions, as InfluxDB v2 uses a different authentication mechanism and configuration.

Tests

  1. This has yet to be tested, but for some reason my fork repository is invalid. Mabye someone can tell me what's wrong.
  2. Since the authentication system is different, it may need to be changed for the add-on. Yet to be tested.

Copy link

coderabbitai bot commented Oct 31, 2024

Walkthrough

The changes involve significant updates to the InfluxDB Dockerfile and configuration file. The Dockerfile now installs InfluxDB version 2.7.1, removing previous components like Chronograf and Kapacitor, and streamlining the installation process. The configuration file has had two port mappings removed: 80/tcp and 8088/tcp, leaving only the 8086/tcp mapping for the InfluxDB server. These modifications reflect a shift in the focus and functionality of the InfluxDB container.

Changes

File Change Summary
influxdb/Dockerfile Updated InfluxDB version from 1.8.10 to 2.7.1, removed installation of Chronograf and Kapacitor, changed download URL format, and streamlined cleanup commands.
influxdb/config.yaml Removed port mappings for 80/tcp (set to null) and 8088/tcp, retaining only 8086/tcp for InfluxDB server.

Poem

In the world of data, we leap and bound,
With InfluxDB's new version, joy is found!
Ports trimmed away, the old now gone,
A cleaner path for us to carry on.
Hopping through changes, we celebrate,
A brighter future, oh, isn't it great? 🐇✨


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

Reviewing files that changed from the base of the PR and between ca0e316 and 4d72218.

⛔ Files ignored due to path filters (2)
  • influxdb/icon.png is excluded by !**/*.png
  • influxdb/logo.png is excluded by !**/*.png
📒 Files selected for processing (2)
  • influxdb/Dockerfile (1 hunks)
  • influxdb/config.yaml (0 hunks)
💤 Files with no reviewable changes (1)
  • influxdb/config.yaml
🔇 Additional comments (3)
influxdb/Dockerfile (3)

Line range hint 1-7: LGTM! Base image and shell setup follow best practices.

The base image version is recent, and the shell is properly configured with pipefail for better error handling.


Line range hint 24-52: LGTM! Labels and metadata are well-structured.

The labels follow OCI standards and include comprehensive metadata for container identification and documentation.


8-22: Verify removal of all mentioned unnecessary packages.

The PR objectives mention removing several packages (libnginx-mod-http-lua, luarocks, lua-resty-http, nginx, procps). Let's verify that these are not being installed elsewhere in the build process.

✅ Verification successful

All mentioned packages have been successfully removed

The verification confirms that none of the packages mentioned in the PR objectives (libnginx-mod-http-lua, luarocks, lua-resty-http, nginx, procps) are being installed in the Dockerfile. The only package-related operations found are:

  • An apt-get update command
  • Installation of the InfluxDB package via dpkg

This aligns with the PR objectives of removing unnecessary packages while maintaining the core InfluxDB functionality.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if any of the packages to be removed are still referenced
# Expected: No matches found

echo "Checking for references to removed packages..."
rg -i "nginx|luarocks|lua-resty|procps" --type dockerfile

Length of output: 197


Script:

#!/bin/bash
# Let's try a different approach to search for package installations
# Search for apt-get install, dpkg -i, or any package-related operations in Dockerfiles

# First, find all Dockerfiles
echo "=== Finding all Dockerfiles ==="
fd Dockerfile

echo -e "\n=== Checking package installations in Dockerfiles ==="
fd Dockerfile --exec cat {} \; | grep -i "apt-get\|dpkg\|packages\|nginx\|luarocks\|lua-resty\|procps"

Length of output: 402

Comment on lines +8 to +22
# Setup InfluxDB v2
ARG BUILD_ARCH=amd64
ARG INFLUXDB_VERSION="1.8.10"
ARG CHRONOGRAF_VERSION="1.10.2"
ARG KAPACITOR_VERSION="1.5.9-1"
ARG INFLUXDB_VERSION="2.7.1"
RUN \
apt-get update \
&& apt-get install -y --no-install-recommends \
libnginx-mod-http-lua=1:0.10.23-1 \
luarocks=3.8.0+dfsg1-1 \
nginx=1.22.1-9 \
procps=2:4.0.2-3 \
\
&& luarocks install lua-resty-http 0.15-0 \
\
&& ARCH="${BUILD_ARCH}" \
&& if [ "${BUILD_ARCH}" = "aarch64" ]; then ARCH="arm64"; fi \
&& if [ "${BUILD_ARCH}" = "armv7" ]; then ARCH="armhf"; fi \
\
&& curl -J -L -o /tmp/influxdb.deb \
"https://dl.influxdata.com/influxdb/releases/influxdb_${INFLUXDB_VERSION}_${ARCH}.deb" \
\
&& curl -J -L -o /tmp/chronograf.deb \
"https://dl.influxdata.com/chronograf/releases/chronograf_${CHRONOGRAF_VERSION}_${ARCH}.deb" \
\
&& curl -J -L -o /tmp/kapacitor.deb \
"https://dl.influxdata.com/kapacitor/releases/kapacitor_${KAPACITOR_VERSION}_${ARCH}.deb" \
"https://dl.influxdata.com/influxdb/releases/influxdb2_${INFLUXDB_VERSION}_${ARCH}.deb" \
\
&& dpkg --install /tmp/influxdb.deb \
&& dpkg --install /tmp/chronograf.deb \
&& dpkg --install /tmp/kapacitor.deb \
\
&& rm -fr \
/tmp/* \
/etc/nginx \
/var/{cache,log}/* \
/var/lib/apt/lists/* \
\
&& mkdir -p /var/log/nginx \
&& touch /var/log/nginx/error.log

&& rm -fr /tmp/* /var/lib/apt/lists/*
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 enhancing package verification and version pinning.

While the basic installation is correct, consider these security improvements:

  1. Verify the package signature or checksum
  2. Pin the apt package version explicitly

Here's how to implement these improvements:

 RUN \
     apt-get update \
+    && apt-get install -y --no-install-recommends gpg \
     && ARCH="${BUILD_ARCH}" \
     && if [ "${BUILD_ARCH}" = "aarch64" ]; then ARCH="arm64"; fi \
     && if [ "${BUILD_ARCH}" = "armv7" ]; then ARCH="armhf"; fi \
-    \
+    && curl -sL https://repos.influxdata.com/influxdb.key | gpg --dearmor > /etc/apt/trusted.gpg.d/influxdb.gpg \
+    && echo "deb [signed-by=/etc/apt/trusted.gpg.d/influxdb.gpg] https://repos.influxdata.com/debian stable main" > /etc/apt/sources.list.d/influxdb.list \
+    && apt-get update \
+    && apt-get install -y --no-install-recommends influxdb2=${INFLUXDB_VERSION} \
-    && curl -J -L -o /tmp/influxdb.deb \
-        "https://dl.influxdata.com/influxdb/releases/influxdb2_${INFLUXDB_VERSION}_${ARCH}.deb" \
-    \
-    && dpkg --install /tmp/influxdb.deb \
-    \
+    && apt-get purge -y --auto-remove gpg \
     && rm -fr /tmp/* /var/lib/apt/lists/*

Committable suggestion was skipped due to low confidence.

@sinclairpaul
Copy link
Member

How is the migration handled?

This has yet to be tested

As you have removed nginx, yet the config and services remain, it will fail to start.

@sinclairpaul
Copy link
Member

Think we will close this out, thanks for contributing.

@snzyeee
Copy link

snzyeee commented Nov 2, 2024

Hello @sinclairpaul!

May I ask you if it's ever to plan on this integration to be a newer influx version?

I'm missing some features from influxdb 2. Is it worth waiting or should I just switch to the other add-on?

Thank you in advance.

@StevenSlaa
Copy link
Author

Hi @sinclairpaul,

Thank you for your feedback on the pull request. You raise an important point regarding migration and the potential issues caused by removing nginx and the related config and services.

I completely agree that ensuring a smooth transition for users is crucial. While maintaining the older version of InfluxDB does have its merits, it could lead to more users inadvertently installing an outdated version, especially since InfluxDB v1 is currently the only version listed by default in Home Assistant. This can be misleading for beginner users who may not realize they are starting with an obsolete version.

To address these concerns, I propose the following steps:

  1. Release an Updated Version: We can introduce the InfluxDB v2 Add-on as a new version while providing clear instructions for existing users on how to upgrade.

  2. Documentation on Breaking Changes: Adding a section in the README to inform users about the breaking changes and highlight the new setup required for InfluxDB v2, mabye in the release notes so its more visible in Home Assistant

  3. Reference the Migration Guide: As suggested, we can include a link to the official migration guide (InfluxDB v1 to v2 Migration Guide) to help users understand the changes and facilitate their transition.

By the way, I do not have a experience with building Add-ons for Home Assistant, so could you clarify what you mean by your first comment?

@github-actions github-actions bot locked and limited conversation to collaborators Nov 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants