-
Notifications
You must be signed in to change notification settings - Fork 1.4k
POC for Agent Lite: make Python and integrations optional #43629
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
Draft
iliakur
wants to merge
2
commits into
main
Choose a base branch
from
ik/AI-6095/poc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+199
−8
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
omnibus/config/software/datadog-agent-integrations-py3-lite.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| # Unless explicitly stated otherwise all files in this repository are licensed | ||
| # under the Apache License Version 2.0. | ||
| # This product includes software developed at Datadog (https:#www.datadoghq.com/). | ||
| # Copyright 2016-present Datadog, Inc. | ||
|
|
||
| require './lib/ostools.rb' | ||
| require 'json' | ||
|
|
||
| name 'datadog-agent-integrations-py3-lite' | ||
|
|
||
| license "BSD-3-Clause" | ||
| license_file "./LICENSE" | ||
|
|
||
| dependency 'datadog-agent-integrations-py3-dependencies' | ||
|
|
||
| python_version = "3.13" | ||
|
|
||
| relative_path 'integrations-core' | ||
| whitelist_file "embedded/lib/python#{python_version}/site-packages/.libsaerospike" | ||
| whitelist_file "embedded/lib/python#{python_version}/site-packages/aerospike.libs" | ||
| whitelist_file "embedded/lib/python#{python_version}/site-packages/psycopg_binary.libs" | ||
| whitelist_file "embedded/lib/python#{python_version}/site-packages/pymqi" | ||
|
|
||
| source git: 'https://github.com/DataDog/integrations-core.git' | ||
|
|
||
| integrations_core_version = ENV['INTEGRATIONS_CORE_VERSION'] | ||
| if integrations_core_version.nil? || integrations_core_version.empty? | ||
| integrations_core_version = 'master' | ||
| end | ||
| default_version integrations_core_version | ||
|
|
||
| build do | ||
| # Set the PYTHONPATH and PYTHONHOME | ||
| env = { | ||
| "PYTHONPATH" => "#{install_dir}/embedded/lib/python#{python_version}/site-packages", | ||
| "PYTHONHOME" => "#{install_dir}/embedded", | ||
| } | ||
|
|
||
| # For lite flavor, install integrations to separate directory | ||
| integrations_dir = "#{install_dir}/python-integrations" | ||
| mkdir integrations_dir | ||
| mkdir "#{integrations_dir}/lib/python#{python_version}/site-packages" | ||
|
|
||
| env["PYTHONPATH"] = "#{integrations_dir}/lib/python#{python_version}/site-packages" | ||
|
|
||
| pip_install_args = "#{windows_safe_path(install_dir)}\\embedded3\\python.exe -m pip install --no-deps --no-binary=:all:" if windows_target? | ||
| pip_install_args = "#{install_dir}/embedded/bin/pip3 install --no-deps --no-binary=:all:" unless windows_target? | ||
|
|
||
| patch :source => 'create-regex-at-runtime.patch', :env => env if ohai['platform'] == "windows" && !arm64_target? | ||
|
|
||
| # Get static requirements | ||
| env_script_path = "#{windows_safe_path(install_dir)}/embedded3/Scripts/Activate.ps1" | ||
| env_script_path = ". #{install_dir}/embedded/bin/activate" unless windows_target? | ||
|
|
||
| requirements_file = 'omnibus/config/templates/datadog-agent-integrations-py3/static_requirements.txt' | ||
|
|
||
| if windows_target? | ||
| requirements_file = 'omnibus\\config\\templates\\datadog-agent-integrations-py3\\static_requirements.txt' | ||
| end | ||
|
|
||
| erb :dest => "#{Dir.pwd}/static_requirements.txt", | ||
| :source => "#{windows_safe_path(Dir.pwd)}/#{requirements_file}.erb", | ||
| :mode => 0755, | ||
| :vars => { :python_version => python_version, :requirements => {}, :static_reqs_in_requirements => [] } | ||
|
|
||
| # Use the static requirements file to install base requirements to python-integrations dir | ||
| if windows_target? | ||
| install_cmd = "#{pip_install_args} --target #{integrations_dir}\\lib\\python#{python_version}\\site-packages" | ||
| else | ||
| install_cmd = "#{pip_install_args} --target #{integrations_dir}/lib/python#{python_version}/site-packages" | ||
| end | ||
|
|
||
| command "#{install_cmd} -r static_requirements.txt", :env => env | ||
|
|
||
| # Install integrations to separate directory | ||
| # Use smaller core set for lite flavor | ||
| core_integrations = %w[cpu disk io memory network uptime] | ||
|
|
||
| core_integrations.each do |integration| | ||
| if File.exist?("#{integration}/setup.py") | ||
| command "#{install_cmd} ./#{integration}", :env => env, :cwd => "#{project_dir}" | ||
| end | ||
| end | ||
|
|
||
| # Create marker file to indicate this is a lite integrations package | ||
| command "echo 'lite' > #{integrations_dir}/AGENT_FLAVOR" | ||
|
|
||
| # Set proper permissions | ||
| if ohai['platform'] == "windows" | ||
| command "icacls #{windows_safe_path(integrations_dir)} /T /Q /C /RESET" | ||
| else | ||
| command "find #{integrations_dir} -type f -exec chmod 644 {} +" | ||
| command "find #{integrations_dir} -type d -exec chmod 755 {} +" | ||
| end | ||
| end |
42 changes: 42 additions & 0 deletions
42
omnibus/config/software/datadog-agent-python-runtime-lite.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # Unless explicitly stated otherwise all files in this repository are licensed | ||
| # under the Apache License Version 2.0. | ||
| # This product includes software developed at Datadog (https:#www.datadoghq.com/). | ||
| # Copyright 2016-present Datadog, Inc. | ||
|
|
||
| require './lib/ostools.rb' | ||
|
|
||
| name 'datadog-agent-python-runtime-lite' | ||
|
|
||
| license "Apache-2.0" | ||
| license_file "../LICENSE" | ||
|
|
||
| # This software packages Python runtime and debugging tools for lite flavor | ||
| dependency 'python3' | ||
| dependency 'pympler' | ||
|
|
||
| build do | ||
| # For lite flavor, create separate Python runtime package | ||
| if ENV['AGENT_FLAVOR'] == 'lite' | ||
| python_runtime_dir = "#{install_dir}/python-runtime" | ||
| mkdir python_runtime_dir | ||
|
|
||
| # Copy Python runtime to separate directory | ||
| if windows_target? | ||
| copy "#{install_dir}/embedded3/*", "#{python_runtime_dir}/" | ||
| else | ||
| copy "#{install_dir}/embedded/*", "#{python_runtime_dir}/" | ||
| end | ||
|
|
||
| # Create marker file to indicate this is a lite Python runtime package | ||
| command "echo 'lite' > #{python_runtime_dir}/AGENT_FLAVOR" | ||
| command "echo 'python-runtime' > #{python_runtime_dir}/COMPONENT_TYPE" | ||
|
|
||
| # Set proper permissions | ||
| if windows_target? | ||
| command "icacls #{windows_safe_path(python_runtime_dir)} /T /Q /C /RESET" | ||
| else | ||
| command "find #{python_runtime_dir} -type f -exec chmod 644 {} +" | ||
| command "find #{python_runtime_dir} -type d -exec chmod 755 {} +" | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I'd add an accessor for this (see
ostools.rb/project_helpers.rb)