Skip to content

Revert "Revert "Enable persisting non-core integrations by default (#35636)"" #37882

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions omnibus/python-scripts/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,18 @@ def post(install_directory, storage_location, skip_flag=False):
if os.path.exists(install_directory) and os.path.exists(storage_location):
post_python_installed_packages_file = packages.post_python_installed_packages_file(storage_location)
packages.create_python_installed_packages_file(post_python_installed_packages_file)
flag_path = os.path.join(storage_location, ".install_python_third_party_deps")
if os.path.exists(flag_path) or skip_flag:
print(f"File '{flag_path}' found")

flag_path = "/etc/datadog-agent/.skip_install_python_third_party_deps"
if os.name == "nt":
flag_path = os.path.join(storage_location, ".skip_install_python_third_party_deps")

# by default, we persist third party integrations
persist_third_party_integration = True

if os.path.exists(flag_path) or not skip_flag:
persist_third_party_integration = False

if persist_third_party_integration:
diff_python_installed_packages_file = packages.diff_python_installed_packages_file(storage_location)
if os.path.exists(diff_python_installed_packages_file):
requirements_agent_release_file = packages.requirements_agent_release_file(install_directory)
Expand All @@ -28,7 +37,7 @@ def post(install_directory, storage_location, skip_flag=False):
print(f"File '{diff_python_installed_packages_file}' not found.")
return 0
else:
print(f"File '{flag_path}' not found: no third party integration will be installed.")
print(f"File '{flag_path}' found: no third party integration will be installed.")
return 0
else:
print(f"Directory '{install_directory}' and '{storage_location}' not found.")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
enhancements:
- |
Agent upgrades now persist non-core integrations by default.
This behavior can be disabled by creating a file flag under `/etc/datadog-agent/.skip_install_python_third_party_deps`.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ func (is *persistingIntegrationsSuite) AfterTest(suiteName, testName string) {
}

func TestPersistingIntegrations(t *testing.T) {

platformJSON := map[string]map[string]map[string]string{}

err := json.Unmarshal(platforms.Content, &platformJSON)
Expand Down Expand Up @@ -108,28 +107,28 @@ func TestPersistingIntegrations(t *testing.T) {
}
}

func (is *persistingIntegrationsSuite) TestIntegrationPersistsWithFileFlag() {
func (is *persistingIntegrationsSuite) TestIntegrationPersistsByDefault() {
VMclient := is.SetupTestClient()

startAgentVersion := is.SetupAgentStartVersion(VMclient)
is.InstallNVMLIntegration(VMclient)

// set the flag to install third party deps
is.EnableInstallThirdPartyDepsFlag(VMclient)
// remove the flag to skip installing third party deps if it exists
is.DisableSkipInstallThirdPartyDepsFlag(VMclient)

upgradedAgentVersion := is.UpgradeAgentVersion(VMclient)
is.Require().NotEqual(startAgentVersion, upgradedAgentVersion)
is.CheckIntegrationInstalled(VMclient)
}

func (is *persistingIntegrationsSuite) TestIntegrationDoesNotPersistWithoutFileFlag() {
func (is *persistingIntegrationsSuite) TestIntegrationDoesNotPersistWithSkipFileFlag() {
VMclient := is.SetupTestClient()

startAgentVersion := is.SetupAgentStartVersion(VMclient)
is.InstallNVMLIntegration(VMclient)

// unset the flag to install third party deps if it was set
VMclient.Host.Execute("sudo rm -f /opt/datadog-agent/.install_python_third_party_deps")
// set the flag to skip installing third party deps
is.EnableSkipInstallThirdPartyDepsFlag(VMclient)

upgradedAgentVersion := is.UpgradeAgentVersion(VMclient)
is.Require().NotEqual(startAgentVersion, upgradedAgentVersion)
Expand Down Expand Up @@ -159,8 +158,12 @@ func (is *persistingIntegrationsSuite) InstallNVMLIntegration(VMclient *common.T
is.Require().Contains(freezeRequirement, "datadog-nvml==1.0.0")
}

func (is *persistingIntegrationsSuite) EnableInstallThirdPartyDepsFlag(VMclient *common.TestClient) string {
return VMclient.Host.MustExecute("sudo touch /opt/datadog-agent/.install_python_third_party_deps")
func (is *persistingIntegrationsSuite) EnableSkipInstallThirdPartyDepsFlag(VMclient *common.TestClient) string {
return VMclient.Host.MustExecute("sudo touch /etc/datadog-agent/.skip_install_python_third_party_deps")
}

func (is *persistingIntegrationsSuite) DisableSkipInstallThirdPartyDepsFlag(VMclient *common.TestClient) (string, error) {
return VMclient.Host.Execute("sudo rm -f /etc/datadog-agent/.skip_install_python_third_party_deps")
}

func (is *persistingIntegrationsSuite) SetupAgentStartVersion(VMclient *common.TestClient) string {
Expand Down
Loading