Skip to content

Commit

Permalink
Remove script volume
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-lozoya committed Nov 21, 2024
1 parent e4d886a commit a66e0ce
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions src/apm/dotnetedgewindows.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,29 @@ func (i DotnetEdgeWindowsInjector) Inject(ctx context.Context, inst v1alpha2.Ins
container := &pod.Spec.Containers[firstContainer]

// check if CORECLR_NEWRELIC_HOME env var is already set in the container
if getIndexOfEnv(container.Env, envdotnetEdgeWindowsNewrelicHome) > -1 {
// if it is already set, then we assume that .NET newrelic-instrumentation is already configured for this container
if getIndexOfEnv(container.Env, envDotnetWindowsNewrelicHome) > -1 {
return pod, errors.New("CORECLR_NEWRELIC_HOME environment variable is already set in the container")
}

// check if CORECLR_NEWRELIC_HOME env var is already set in the .NET instrumentation spec
// if it is already set, then we assume that .NET newrelic-instrumentation is already configured for this container
if getIndexOfEnv(inst.Spec.Agent.Env, envDotnetWindowsNewrelicHome) > -1 {
return pod, errors.New("CORECLR_NEWRELIC_HOME environment variable is already set in the .NET instrumentation spec")
}

// check if NEWRELIC_HOME env var is already set in the container
if getIndexOfEnv(container.Env, envdotnetEdgeFrameworkWindowsNewrelicHome) > -1 {
// if it is already set, then we assume that .NET newrelic-instrumentation is already configured for this container
if getIndexOfEnv(container.Env, envDotnetFrameworkWindowsNewrelicHome) > -1 {
return pod, errors.New("NEWRELIC_HOME environment variable is already set in the container")
}

// check if NEWRELIC_HOME env var is already set in the .NET instrumentation spec
// if it is already set, then we assume that .NET newrelic-instrumentation is already configured for this container
if getIndexOfEnv(inst.Spec.Agent.Env, envDotnetFrameworkWindowsNewrelicHome) > -1 {
return pod, errors.New("NEWRELIC_HOME environment variable is already set in the .NET instrumentation spec")
}

// inject .NET instrumentation spec env vars.
for _, env := range inst.Spec.Agent.Env {
idx := getIndexOfEnv(container.Env, env.Name)
Expand Down Expand Up @@ -135,23 +149,11 @@ func (i DotnetEdgeWindowsInjector) Inject(ctx context.Context, inst v1alpha2.Ins
},
})
}
if isPodVolumeMissing(pod, "scripts-volume") {
hostPathType := corev1.HostPathDirectory
pod.Spec.Volumes = append(pod.Spec.Volumes, corev1.Volume{
Name: "scripts-volume",
VolumeSource: corev1.VolumeSource{
HostPath: &corev1.HostPathVolumeSource{
Path: "C:\\inetpub\\wwwroot\\Scripts",
Type: &hostPathType,
},
},
})
}

pod.Spec.InitContainers = append(pod.Spec.InitContainers, corev1.Container{
Name: dotnetEdgeWindowsInitContainerName,
Image: inst.Spec.Agent.Image,
Command: []string{"cmd", "/C", "xcopy C:\\instrumentation C:\\newrelic-instrumentation /E /I /H /Y && xcopy C:\\instrumentation\\BeforeSetup.ps1 C:\\inetpub\\wwwroot\\Scripts\\BeforeSetup.ps1 /Y"},
Command: []string{"cmd", "/C", "xcopy C:\\instrumentation C:\\newrelic-instrumentation /E /I /H /Y"},
VolumeMounts: []corev1.VolumeMount{
{
Name: volumeName,
Expand Down

0 comments on commit a66e0ce

Please sign in to comment.