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

feat: APM config via configmap #185

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

dbudziwojskiNR
Copy link
Contributor

@dbudziwojskiNR dbudziwojskiNR commented Jan 21, 2025

Description

Type of change

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • New feature / enhancement (non-breaking change which adds functionality)
  • Security fix
  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • Documentation has been updated
  • This change requires changes in testing:
    • unit tests
    • E2E tests

Copy link

codecov bot commented Jan 22, 2025

Codecov Report

Attention: Patch coverage is 89.28571% with 3 lines in your changes missing coverage. Please review.

Project coverage is 60.88%. Comparing base (b24c32b) to head (f9dcba9).

Files with missing lines Patch % Lines
internal/apm/java.go 89.28% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #185      +/-   ##
==========================================
+ Coverage   60.54%   60.88%   +0.33%     
==========================================
  Files          36       36              
  Lines        2945     2973      +28     
==========================================
+ Hits         1783     1810      +27     
  Misses       1015     1015              
- Partials      147      148       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dbudziwojskiNR dbudziwojskiNR marked this pull request as ready for review January 24, 2025 02:36
@dbudziwojskiNR dbudziwojskiNR requested a review from a team as a code owner January 24, 2025 02:36
Copy link
Contributor

@danielstokes danielstokes left a comment

Choose a reason for hiding this comment

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

We may want to move some of this logic to something that can be reused in each injector (dotnet, java, nodejs, ..); php may have to be a special case.

internal/apm/java.go Show resolved Hide resolved
@@ -88,6 +89,35 @@ func (i *JavaInjector) Inject(ctx context.Context, inst v1beta1.Instrumentation,
container.Env[idx].Value = container.Env[idx].Value + javaJVMArgument
}

if inst.Spec.AgentConfigMap != "" {
pod.Spec.Volumes = append(pod.Spec.Volumes, corev1.Volume{
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to check the existence of the same pod your volume your injecting to ensure the volume doesn't get injected multiple times. Being called multiple times should be idempotent.

Each "mutater" has the potential to be called more than once, as different mutators may make changes, which can cause previously called mutators to be called again (no prefined order)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed!

},
})

container.VolumeMounts = append(container.VolumeMounts, corev1.VolumeMount{
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed!

Value: apmConfigPath,
})
} else {
container.Env[apmIdx].Value = apmConfigPath
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the intention to overwrite the value if it's already configured on the container?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair point. I suppose that if a customer has already provided a file we should not override their choice.

Copy link
Contributor

Choose a reason for hiding this comment

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

Does that mean this else block need to be prunned?

@dbudziwojskiNR
Copy link
Contributor Author

We may want to move some of this logic to something that can be reused in each injector (dotnet, java, nodejs, ..); php may have to be a special case.

Agreed. This is something we can look into once we begin supporting the other agents.

Copy link
Contributor

@ramkrishankumarN ramkrishankumarN left a comment

Choose a reason for hiding this comment

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

LGTM

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

Successfully merging this pull request may close these issues.

3 participants