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

Поддержка 1cedtcli и переход на базовый образ с JDK 17 для EDT 2024.1.0+ #53

Conversation

ovcharenko-di
Copy link

@ovcharenko-di ovcharenko-di commented Nov 10, 2024

  1. при сборке образа добавил установку 1cedtcli в PATH (если этот файл существует)
  2. скорректировал скрипты сборки EDT:
  • если версия EDT 2024 и выше, в качестве базового образа используется azul/zulu-openjdk 17
  • по умолчанию базовый образ берется не из локального registry, а из интернета

ВНИМАНИЕ! Не проверял сборку агента EDT под k8s и под Windows

Summary by CodeRabbit

  • New Features

    • Enhanced Docker build scripts to dynamically select base images and tags based on the EDT version.
    • Improved installation process for the 1cedtcli component within the Dockerfile.
  • Bug Fixes

    • Streamlined the Dockerfile to simplify image sourcing and improve error handling.
  • Documentation

    • Updated comments and logic in scripts for better clarity on version handling and installation processes.

Copy link

coderabbitai bot commented Nov 10, 2024

Walkthrough

The pull request introduces modifications to several scripts and a Dockerfile to implement conditional logic for selecting base images and tags based on the EDT_VERSION variable. Scripts build-edt-k8s-agent.sh, build-edt-swarm-agent.bat, and build-edt-swarm-agent.sh are updated to assign BASE_IMAGE and BASE_TAG based on version checks. The Dockerfile is simplified by removing the Docker registry URL and includes additional logic for handling the installation of the 1cedtcli component. These changes enhance the flexibility and maintainability of the build process.

Changes

File Change Summary
build-edt-k8s-agent.sh Added conditional logic for BASE_IMAGE and BASE_TAG based on EDT_VERSION. Updated Docker build command to use new variables.
build-edt-swarm-agent.bat Implemented logic to determine BASE_IMAGE and BASE_TAG based on EDT_MAJOR_VERSION. Updated Docker build commands accordingly.
build-edt-swarm-agent.sh Added conditionals for BASE_IMAGE and BASE_TAG based on EDT_VERSION. Integrated new variables into Docker build command.
edt/Dockerfile Simplified base image declaration. Added logic to conditionally install 1cedtcli. Updated PATH to include 1cedtcli.

Possibly related PRs

Poem

In the land of code where rabbits play,
New images bloom with each passing day.
With tags that dance in the versioned air,
Our builds grow stronger, with love and care.
So hop along, dear friends, don’t delay,
For the scripts are ready, let’s build away! 🐇✨


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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 52ef0df and c4b1067.

📒 Files selected for processing (4)
  • build-edt-k8s-agent.sh (2 hunks)
  • build-edt-swarm-agent.bat (2 hunks)
  • build-edt-swarm-agent.sh (2 hunks)
  • edt/Dockerfile (2 hunks)
🔇 Additional comments (6)
build-edt-swarm-agent.bat (2)

20-21: LGTM: Error handling is properly implemented.

The error check is consistent with the script's error handling pattern.


41-42: Verify availability of the base images.

The script now uses dynamic base images (azul/zulu-openjdk:17.0.13-jdk or eclipse-temurin:11). Please ensure these images are:

  1. Publicly available
  2. Compatible with your build environment
  3. Stable and maintained
build-edt-k8s-agent.sh (1)

49-50: Verify base image availability and k8s compatibility.

The addition of dynamic base image selection requires verification:

  1. Ensure both base images are accessible in all deployment environments
  2. Test k8s agent builds with both JDK versions

Let's verify the image availability:

Consider adding:

  1. Image availability checks before the build process
  2. A test matrix in CI to verify k8s agent functionality with both JDK versions
build-edt-swarm-agent.sh (1)

49-50: Verify the impact of base image changes across all builds.

The new base image configuration is only applied to the EDT image build but not to the oscript-downloader or edt-agent builds. This might lead to version incompatibility issues.

Let's verify the Dockerfile configurations:

Consider:

  1. Adding validation for BASE_IMAGE and BASE_TAG variables
  2. Documenting the JDK version requirements for each component
  3. Ensuring consistent base image usage across all interdependent containers
edt/Dockerfile (2)

77-77: LGTM! PATH environment variable is correctly configured

The PATH update properly includes both components while preserving the existing PATH value.


41-41: Consider adding base image validation for EDT 2024.1.0+

While the flexible base image configuration is good, the requirement to use azul/zulu-openjdk 17 for EDT 2024.1.0+ isn't enforced in the Dockerfile. Consider adding a build-time validation.

Here's a script to verify the base image settings in the build scripts:

Comment on lines 11 to 18
for /f "delims=." %%a in ("%EDT_VERSION%") do set EDT_MAJOR_VERSION=%aa
if %EDT_MAJOR_VERSION% GEQ "2024" (
set BASE_IMAGE="azul/zulu-openjdk"
set BASE_TAG="17.0.13-jdk"
) else (
set BASE_IMAGE="eclipse-temurin"
set BASE_TAG="11"
)
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add input validation and error handling for version extraction.

The version extraction logic needs additional safeguards:

  1. EDT_VERSION validation is missing
  2. No error handling for the version extraction
  3. The comparison assumes proper version format

Consider this improved implementation:

-for /f "delims=." %%a in ("%EDT_VERSION%") do set EDT_MAJOR_VERSION=%aa
-if %EDT_MAJOR_VERSION% GEQ "2024" (
+if "%EDT_VERSION%"=="" (
+    echo Error: EDT_VERSION is not set
+    goto end
+)
+
+for /f "delims=." %%a in ("%EDT_VERSION%") do (
+    set EDT_MAJOR_VERSION=%%a
+    if "%%a"=="" (
+        echo Error: Failed to extract major version from %EDT_VERSION%
+        goto end
+    )
+)
+
+if %EDT_MAJOR_VERSION% GEQ "2024" (
📝 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
for /f "delims=." %%a in ("%EDT_VERSION%") do set EDT_MAJOR_VERSION=%aa
if %EDT_MAJOR_VERSION% GEQ "2024" (
set BASE_IMAGE="azul/zulu-openjdk"
set BASE_TAG="17.0.13-jdk"
) else (
set BASE_IMAGE="eclipse-temurin"
set BASE_TAG="11"
)
if "%EDT_VERSION%"=="" (
echo Error: EDT_VERSION is not set
goto end
)
for /f "delims=." %%a in ("%EDT_VERSION%") do (
set EDT_MAJOR_VERSION=%%a
if "%%a"=="" (
echo Error: Failed to extract major version from %EDT_VERSION%
goto end
)
)
if %EDT_MAJOR_VERSION% GEQ "2024" (
set BASE_IMAGE="azul/zulu-openjdk"
set BASE_TAG="17.0.13-jdk"
) else (
set BASE_IMAGE="eclipse-temurin"
set BASE_TAG="11"
)

Comment on lines 17 to 24
#Если версия EDT >= 2024.1.0, использовать JDK 17
if [[ "$(printf "%s\n" "$EDT_VERSION" "2024" | sort -V | head -n 1)" == "2024" ]]; then
BASE_IMAGE="azul/zulu-openjdk"
BASE_TAG="17.0.13-jdk"
else
BASE_IMAGE="eclipse-temurin"
BASE_TAG="11"
fi
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve version check implementation and add validation.

The current version check has several areas for improvement:

  1. The check "$EDT_VERSION" "2024" will match any version starting with "2024", not specifically 2024.1.0+
  2. There's no validation that EDT_VERSION is set

Consider this improved implementation:

-#Если версия EDT >= 2024.1.0, использовать JDK 17
-if [[ "$(printf "%s\n" "$EDT_VERSION" "2024" | sort -V | head -n 1)" == "2024" ]]; then
+# Use JDK 17 for EDT version >= 2024.1.0
+if [ -z "$EDT_VERSION" ]; then
+  echo "EDT_VERSION is not set"
+  exit 1
+fi
+
+if [[ "$(printf "%s\n" "$EDT_VERSION" "2024.1.0" | sort -V | head -n 1)" == "2024.1.0" ]]; then
   BASE_IMAGE="azul/zulu-openjdk"
   BASE_TAG="17.0.13-jdk"
 else
   BASE_IMAGE="eclipse-temurin"
   BASE_TAG="11"
 fi
📝 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
#Если версия EDT >= 2024.1.0, использовать JDK 17
if [[ "$(printf "%s\n" "$EDT_VERSION" "2024" | sort -V | head -n 1)" == "2024" ]]; then
BASE_IMAGE="azul/zulu-openjdk"
BASE_TAG="17.0.13-jdk"
else
BASE_IMAGE="eclipse-temurin"
BASE_TAG="11"
fi
# Use JDK 17 for EDT version >= 2024.1.0
if [ -z "$EDT_VERSION" ]; then
echo "EDT_VERSION is not set"
exit 1
fi
if [[ "$(printf "%s\n" "$EDT_VERSION" "2024.1.0" | sort -V | head -n 1)" == "2024.1.0" ]]; then
BASE_IMAGE="azul/zulu-openjdk"
BASE_TAG="17.0.13-jdk"
else
BASE_IMAGE="eclipse-temurin"
BASE_TAG="11"
fi

Comment on lines 17 to 24
#Если версия EDT >= 2024.1.0, использовать JDK 17
if [[ "$(printf "%s\n" "$EDT_VERSION" "2024" | sort -V | head -n 1)" == "2024" ]]; then
BASE_IMAGE="azul/zulu-openjdk"
BASE_TAG="17.0.13-jdk"
else
BASE_IMAGE="eclipse-temurin"
BASE_TAG="11"
fi
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve version comparison logic and documentation.

The current version comparison has several issues:

  1. It only checks the year part (2024) instead of the full version (2024.1.0)
  2. The comment is in Russian which may affect maintainability

Consider this improved implementation:

-#Если версия EDT >= 2024.1.0, использовать JDK 17
-if [[ "$(printf "%s\n" "$EDT_VERSION" "2024" | sort -V | head -n 1)" == "2024" ]]; then
+# Use JDK 17 for EDT version >= 2024.1.0
+if [[ "$(printf "%s\n" "$EDT_VERSION" "2024.1.0" | sort -V | head -n 1)" == "2024.1.0" ]]; then
   BASE_IMAGE="azul/zulu-openjdk"
   BASE_TAG="17.0.13-jdk"
 else
   BASE_IMAGE="eclipse-temurin"
   BASE_TAG="11"
 fi
📝 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
#Если версия EDT >= 2024.1.0, использовать JDK 17
if [[ "$(printf "%s\n" "$EDT_VERSION" "2024" | sort -V | head -n 1)" == "2024" ]]; then
BASE_IMAGE="azul/zulu-openjdk"
BASE_TAG="17.0.13-jdk"
else
BASE_IMAGE="eclipse-temurin"
BASE_TAG="11"
fi
# Use JDK 17 for EDT version >= 2024.1.0
if [[ "$(printf "%s\n" "$EDT_VERSION" "2024.1.0" | sort -V | head -n 1)" == "2024.1.0" ]]; then
BASE_IMAGE="azul/zulu-openjdk"
BASE_TAG="17.0.13-jdk"
else
BASE_IMAGE="eclipse-temurin"
BASE_TAG="11"
fi

Comment on lines +73 to +75
&& mv $(dirname $(find /opt/1C/1CE -name ring)) /opt/1C/1CE/components/1c-enterprise-ring \
#1cedtcli отсутствует в EDT версии <2023.1.0
&& if [ -n "$(find /opt/1C/1CE -name 1cedtcli)" ]; then mv $(dirname $(find /opt/1C/1CE -name 1cedtcli)) /opt/1C/1CE/components/1cedtcli; fi
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Optimize component installation and add error handling

The current implementation has several areas for improvement:

  1. The find command is executed multiple times
  2. No error handling for the ring component move
  3. Silent failures possible in the conditional move

Consider this more robust implementation:

-  && mv $(dirname $(find /opt/1C/1CE -name ring)) /opt/1C/1CE/components/1c-enterprise-ring \
-  #1cedtcli отсутствует в EDT версии <2023.1.0
-  && if [ -n "$(find /opt/1C/1CE -name 1cedtcli)" ]; then mv $(dirname $(find /opt/1C/1CE -name 1cedtcli)) /opt/1C/1CE/components/1cedtcli; fi
+  && RING_PATH=$(find /opt/1C/1CE -name ring) \
+  && if [ -z "$RING_PATH" ]; then echo "Error: ring component not found" && exit 1; fi \
+  && mv "$(dirname "$RING_PATH")" /opt/1C/1CE/components/1c-enterprise-ring \
+  # 1cedtcli is only available in EDT version 2023.1.0 and above \
+  && CEDTCLI_PATH=$(find /opt/1C/1CE -name 1cedtcli) \
+  && if [ -n "$CEDTCLI_PATH" ]; then \
+       mv "$(dirname "$CEDTCLI_PATH")" /opt/1C/1CE/components/1cedtcli \
+     || { echo "Error moving 1cedtcli component"; exit 1; }; \
+     fi
📝 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
&& mv $(dirname $(find /opt/1C/1CE -name ring)) /opt/1C/1CE/components/1c-enterprise-ring \
#1cedtcli отсутствует в EDT версии <2023.1.0
&& if [ -n "$(find /opt/1C/1CE -name 1cedtcli)" ]; then mv $(dirname $(find /opt/1C/1CE -name 1cedtcli)) /opt/1C/1CE/components/1cedtcli; fi
&& RING_PATH=$(find /opt/1C/1CE -name ring) \
&& if [ -z "$RING_PATH" ]; then echo "Error: ring component not found" && exit 1; fi \
&& mv "$(dirname "$RING_PATH")" /opt/1C/1CE/components/1c-enterprise-ring \
# 1cedtcli is only available in EDT version 2023.1.0 and above \
&& CEDTCLI_PATH=$(find /opt/1C/1CE -name 1cedtcli) \
&& if [ -n "$CEDTCLI_PATH" ]; then \
mv "$(dirname "$CEDTCLI_PATH")" /opt/1C/1CE/components/1cedtcli \
|| { echo "Error moving 1cedtcli component"; exit 1; }; \
fi

build-edt-k8s-agent.sh Outdated Show resolved Hide resolved
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

🧹 Outside diff range and nitpick comments (2)
build-edt-swarm-agent.bat (1)

Line range hint 11-42: Consider operational impacts of base image changes.

The switch to different base images (azul/zulu-openjdk for EDT 2024+ and eclipse-temurin for earlier versions) has several implications:

  1. As mentioned in the PR objectives, k8s compatibility needs testing
  2. Different base images might have different security implications
  3. Image size and layer caching efficiency might be affected
  4. CI/CD pipelines might need updates to handle both base images

Consider:

  • Adding documentation about the base image requirements
  • Creating a test matrix for different environments
  • Implementing image size monitoring
build-edt-swarm-agent.sh (1)

49-50: Consider using distinct variable names for different images.

The variables BASE_IMAGE and BASE_TAG are used for both the downloader image (lines 36-37) and the EDT image. This could lead to confusion and maintenance issues. Consider using more specific variable names like EDT_BASE_IMAGE and EDT_BASE_TAG to clearly distinguish their purpose.

-    --build-arg BASE_IMAGE=$BASE_IMAGE \
-    --build-arg BASE_TAG=$BASE_TAG \
+    --build-arg BASE_IMAGE=$EDT_BASE_IMAGE \
+    --build-arg BASE_TAG=$EDT_BASE_TAG \

And update the conditional block accordingly:

 if [[ "$(printf "%s\n" "$EDT_VERSION" "2024" | sort -V | head -n 1)" == "2024" ]]; then
-  BASE_IMAGE="azul/zulu-openjdk"
-  BASE_TAG="17"
+  EDT_BASE_IMAGE="azul/zulu-openjdk"
+  EDT_BASE_TAG="17"
 else
-  BASE_IMAGE="eclipse-temurin"
-  BASE_TAG="11"
+  EDT_BASE_IMAGE="eclipse-temurin"
+  EDT_BASE_TAG="11"
 fi
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between c4b1067 and db9003d.

📒 Files selected for processing (3)
  • build-edt-k8s-agent.sh (2 hunks)
  • build-edt-swarm-agent.bat (2 hunks)
  • build-edt-swarm-agent.sh (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • build-edt-k8s-agent.sh
🔇 Additional comments (4)
build-edt-swarm-agent.bat (2)

11-18: ⚠️ Potential issue

Add input validation and error handling for version extraction.

The version extraction and comparison logic needs additional safeguards:

  1. No validation if EDT_VERSION is set or empty
  2. No error handling for version extraction failures
  3. String comparison with "2024" could be problematic with different version formats

The previous review comment about adding input validation remains valid. Additionally, consider adding logging to help with troubleshooting:

+if "%EDT_VERSION%"=="" (
+    echo Error: EDT_VERSION environment variable is not set
+    goto end
+)
+
+echo Processing EDT version: %EDT_VERSION%
 for /f "delims=." %%a in ("%EDT_VERSION%") do set EDT_MAJOR_VERSION=%%a
+if "%EDT_MAJOR_VERSION%"=="" (
+    echo Error: Failed to extract major version from %EDT_VERSION%
+    goto end
+)
+
+echo Detected major version: %EDT_MAJOR_VERSION%
 if %EDT_MAJOR_VERSION% GEQ "2024" (
+    echo Using JDK 17 base image for EDT 2024+
   set BASE_IMAGE="azul/zulu-openjdk"
   set BASE_TAG="17"
 ) else (
+    echo Using JDK 11 base image for EDT pre-2024
   set BASE_IMAGE="eclipse-temurin"
   set BASE_TAG="11"
 )

41-42: 🛠️ Refactor suggestion

Improve Docker build argument handling and verification.

The build argument handling needs improvements:

  1. Variables should be quoted to handle potential spaces
  2. Base image existence should be verified before building
-    --build-arg BASE_IMAGE=%BASE_IMAGE% ^
-    --build-arg BASE_TAG=%BASE_TAG% ^
+    --build-arg BASE_IMAGE="%BASE_IMAGE%" ^
+    --build-arg BASE_TAG="%BASE_TAG%" ^

Add verification before building:

build-edt-swarm-agent.sh (2)

17-24: Previous review comment is still applicable.

The version comparison logic and documentation issues highlighted in the previous review remain unaddressed.


Line range hint 1-1: Verify 1cedtcli implementation in Dockerfile.

The PR objective mentions adding 1cedtcli to PATH, but this implementation is not visible in the build script. Let's verify the implementation in the Dockerfile.

✅ Verification successful

1cedtcli is properly implemented in the Dockerfile

The Dockerfile correctly handles the 1cedtcli tool by:

  • Moving it to /opt/1C/1CE/components/1cedtcli if found in EDT installation
  • Adding it to the PATH environment variable
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check how 1cedtcli is handled in the Dockerfile
# Test: Look for 1cedtcli-related changes in the Dockerfile
rg -A 5 "1cedtcli" edt/Dockerfile

Length of output: 315

build-edt-swarm-agent.bat Show resolved Hide resolved
@nixel2007
Copy link
Member

Спасибо!

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

Successfully merging this pull request may close these issues.

2 participants