Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: Pavol Loffay <p.loffay@gmail.com>
  • Loading branch information
pavolloffay committed Oct 26, 2021
1 parent 7cc730e commit e36db4a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type InstrumentationSpec struct {
Exporter `json:"exporter,omitempty"`
}

// JavaSpec defines Java SKD and instrumentation configuration.
// JavaSpec defines Java SDK and instrumentation configuration.
type JavaSpec struct {
// +optional
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
Expand Down
14 changes: 7 additions & 7 deletions pkg/instrumentation/podmutator.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ func (pm *instPodMutator) Mutate(ctx context.Context, ns corev1.Namespace, pod c
// if no annotations are found at all, just return the same pod
annValue := annotationValue(ns.ObjectMeta, pod.ObjectMeta)
if len(annValue) == 0 {
logger.V(1).Info("annotation not present in deployment, skipping sidecar injection")
logger.V(1).Info("annotation not present in deployment, skipping instrumentation injection")
return pod, nil
}

// is the annotation value 'false'? if so, we need a pod without the sidecar
// is the annotation value 'false'? if so, we need a pod without the instrumentation
if strings.EqualFold(annValue, "false") {
logger.V(1).Info("pod explicitly refuses sidecar injection, attempting to remove sidecar if it exists")
logger.V(1).Info("pod explicitly refuses instrumentation injection, attempting to remove instrumentation if it exists")
return pod, nil
}

Expand All @@ -68,17 +68,17 @@ func (pm *instPodMutator) Mutate(ctx context.Context, ns corev1.Namespace, pod c
if err != nil {
if err == errNoInstancesAvailable || err == errMultipleInstancesPossible {
// we still allow the pod to be created, but we log a message to the operator's logs
logger.Error(err, "failed to select an OpenTelemetry Instrumentation instance for this pod's sidecar")
logger.Error(err, "failed to select an OpenTelemetry Instrumentation instance for this pod")
return pod, nil
}

// something else happened, better fail here
return pod, err
}

// once it's been determined that a sidecar is desired, none exists yet, and we know which instance it should talk to,
// we should inject the sidecar.
logger.V(1).Info("injecting sidecar into pod", "otelinst-namespace", otelinst.Namespace, "otelinst-name", otelinst.Name)
// once it's been determined that instrumentation is desired, none exists yet, and we know which instance it should talk to,
// we should inject the instrumentation.
logger.V(1).Info("injecting instrumentation into pod", "otelinst-namespace", otelinst.Namespace, "otelinst-name", otelinst.Name)
return inject(pm.Logger, otelinst, pod), nil
}

Expand Down
10 changes: 5 additions & 5 deletions pkg/instrumentation/sdk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestSDKInjection(t *testing.T) {
inst: v1alpha1.Instrumentation{
Spec: v1alpha1.InstrumentationSpec{
Exporter: v1alpha1.Exporter{
Endpoint: "https://doesnotexists.io",
Endpoint: "https://collector:4318",
},
},
},
Expand All @@ -61,7 +61,7 @@ func TestSDKInjection(t *testing.T) {
},
{
Name: "OTEL_EXPORTER_OTLP_ENDPOINT",
Value: "https://doesnotexists.io",
Value: "https://collector:4318",
},
},
},
Expand All @@ -74,7 +74,7 @@ func TestSDKInjection(t *testing.T) {
inst: v1alpha1.Instrumentation{
Spec: v1alpha1.InstrumentationSpec{
Exporter: v1alpha1.Exporter{
Endpoint: "https://doesnotexists.io",
Endpoint: "https://collector:4318",
},
},
},
Expand Down Expand Up @@ -132,7 +132,7 @@ func TestInjection(t *testing.T) {
Image: "img:1",
},
Exporter: v1alpha1.Exporter{
Endpoint: "https://doesnotexists:1234",
Endpoint: "https://collector:4318",
},
},
}
Expand Down Expand Up @@ -182,7 +182,7 @@ func TestInjection(t *testing.T) {
},
{
Name: "OTEL_EXPORTER_OTLP_ENDPOINT",
Value: "https://doesnotexists:1234",
Value: "https://collector:4318",
},
{
Name: "JAVA_TOOL_OPTIONS",
Expand Down

0 comments on commit e36db4a

Please sign in to comment.