Skip to content

Commit 3d23111

Browse files
Merge pull request #1041 from joushx/main
Migrate dynatrace integration to LD_PRELOAD and support FIPS mode
2 parents 60d41d6 + 4b1f6ca commit 3d23111

File tree

5 files changed

+27
-16
lines changed

5 files changed

+27
-16
lines changed

docs/framework-dynatrace_one_agent.md

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ The credential payload of the service may contain the following entries:
3030
| `environmentid` | Your Dynatrace environment ID is the unique identifier of your Dynatrace environment. You can find it in the deploy Dynatrace section within your environment.
3131
| `networkzone` | (Optional) Network zones are Dynatrace entities that represent your network structure. They help you to route the traffic efficiently, avoiding unnecessary traffic across data centers and network regions. Enter the network zone you wish to pass to the server during the OneAgent Download.
3232
| `skiperrors` | (Optional) The errors during agent download are skipped and the injection is disabled. Use this option at your own risk. Possible values are 'true' and 'false'. This option is disabled by default!
33+
| `enablefips`| (Optional) Enables the use of [FIPS 140 cryptographic algorithms](https://docs.dynatrace.com/docs/shortlink/oneagentctl#fips-140). Possible values are 'true' and 'false'. This option is disabled by default!
3334

3435
## Configuration
3536
For general information on configuring the buildpack, including how to specify configuration values through environment variables, refer to [Configuration and Extension][].

lib/java_buildpack/framework/dynatrace_one_agent.rb

+18-7
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,10 @@ def release
6868

6969
manifest = agent_manifest
7070

71-
@droplet.java_opts.add_agentpath(agent_path(manifest))
72-
@droplet.java_opts.add_preformatted_options('-Xshare:off')
71+
environment_variables = @droplet.environment_variables
72+
environment_variables.add_environment_variable(LD_PRELOAD, agent_path(manifest))
73+
74+
File.delete(@droplet.sandbox + 'agent/dt_fips_disabled.flag') if enable_fips?
7375

7476
dynatrace_environment_variables(manifest)
7577
end
@@ -87,6 +89,8 @@ def supports?
8789

8890
APITOKEN = 'apitoken'
8991

92+
ENABLE_FIPS = 'enablefips'
93+
9094
DT_APPLICATION_ID = 'DT_APPLICATIONID'
9195

9296
DT_CONNECTION_POINT = 'DT_CONNECTION_POINT'
@@ -99,6 +103,8 @@ def supports?
99103

100104
DT_NETWORK_ZONE = 'DT_NETWORK_ZONE'
101105

106+
LD_PRELOAD = 'LD_PRELOAD'
107+
102108
ENVIRONMENTID = 'environmentid'
103109

104110
FILTER = /dynatrace/.freeze
@@ -107,8 +113,9 @@ def supports?
107113

108114
SKIP_ERRORS = 'skiperrors'
109115

110-
private_constant :APIURL, :APITOKEN, :DT_APPLICATION_ID, :DT_CONNECTION_POINT, :DT_NETWORK_ZONE, :DT_LOGSTREAM,
111-
:DT_TENANT, :DT_TENANTTOKEN, :ENVIRONMENTID, :FILTER, :NETWORKZONE, :SKIP_ERRORS
116+
private_constant :APIURL, :APITOKEN, :ENABLE_FIPS, :DT_APPLICATION_ID, :DT_CONNECTION_POINT, :DT_NETWORK_ZONE,
117+
:DT_LOGSTREAM, :DT_TENANT, :DT_TENANTTOKEN, :LD_PRELOAD, :ENVIRONMENTID, :FILTER, :NETWORKZONE,
118+
:SKIP_ERRORS
112119

113120
def agent_download_url
114121
download_uri = "#{api_base_url(credentials)}/v1/deployment/installer/agent/unix/paas/latest?include=java" \
@@ -126,8 +133,8 @@ def agent_manifest
126133

127134
def agent_path(manifest)
128135
technologies = manifest['technologies']
129-
java_binaries = technologies['java']['linux-x86-64']
130-
loader = java_binaries.find { |bin| bin['binarytype'] == 'loader' }
136+
java_binaries = technologies['process']['linux-x86-64']
137+
loader = java_binaries.find { |bin| bin['binarytype'] == 'primary' }
131138
@droplet.sandbox + loader['path']
132139
end
133140

@@ -191,7 +198,11 @@ def logstream?
191198
end
192199

193200
def skip_errors?
194-
credentials[SKIP_ERRORS].to_b
201+
credentials[SKIP_ERRORS] == 'true'
202+
end
203+
204+
def enable_fips?
205+
credentials[ENABLE_FIPS] == 'true'
195206
end
196207

197208
def tenanttoken(manifest)

spec/fixtures/framework_dynatrace_one_agent/.java-buildpack/dynatrace_one_agent/manifest.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"technologies" : {
3-
"java" : {
3+
"process" : {
44
"linux-x86-64" : [
55
{
6-
"path": "agent/lib64/liboneagentloader.so",
7-
"binarytype" : "loader"
6+
"path": "agent/lib64/liboneagentproc.so",
7+
"binarytype" : "primary"
88
}
99
]
1010
}
132 Bytes
Binary file not shown.

spec/java_buildpack/framework/dynatrace_one_agent_spec.rb

+5-6
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,17 @@
5050

5151
component.compile
5252

53-
expect(sandbox + 'agent/lib64/liboneagentloader.so').to exist
53+
expect(sandbox + 'agent/lib64/liboneagentproc.so').to exist
5454
expect(sandbox + 'manifest.json').to exist
5555
end
5656

57-
it 'updates JAVA_OPTS with agent loader and share set to off',
57+
it 'sets LD_PRELOAD with liboneagentproc',
5858
app_fixture: 'framework_dynatrace_one_agent' do
5959

6060
component.release
6161

62-
expect(java_opts).to include('-agentpath:$PWD/.java-buildpack/dynatrace_one_agent/agent/lib64/' \
63-
'liboneagentloader.so')
64-
expect(java_opts).to include('-Xshare:off')
62+
expect(environment_variables).to include('LD_PRELOAD=$PWD/.java-buildpack/dynatrace_one_agent/agent/lib64/' \
63+
'liboneagentproc.so')
6564
end
6665

6766
it 'updates environment variables',
@@ -112,7 +111,7 @@
112111

113112
component.compile
114113

115-
expect(sandbox + 'agent/lib64/liboneagentloader.so').to exist
114+
expect(sandbox + 'agent/lib64/liboneagentproc.so').to exist
116115
expect(sandbox + 'manifest.json').to exist
117116
end
118117
end

0 commit comments

Comments
 (0)