Skip to content

Commit

Permalink
Add feature flag to skip container name validation for multi-instrume…
Browse files Browse the repository at this point in the history
…ntation (#99)
  • Loading branch information
jefchien committed Feb 23, 2024
1 parent 3a4f0c9 commit 7c99e21
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions helm/templates/operator-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ spec:
- {{ printf "--auto-annotation-config=%s" (.Values.manager.autoAnnotateAutoInstrumentation | toJson) | quote }}
- "--auto-instrumentation-java-image={{ .Values.manager.autoInstrumentationImage.java.repository }}:{{ .Values.manager.autoInstrumentationImage.java.tag }}"
- "--auto-instrumentation-python-image={{ .Values.manager.autoInstrumentationImage.python.repository }}:{{ .Values.manager.autoInstrumentationImage.python.tag }}"
- "--feature-gates=operator.autoinstrumentation.multi-instrumentation,operator.autoinstrumentation.multi-instrumentation.skip-container-validation"
command:
- /manager
name: manager
Expand Down
9 changes: 9 additions & 0 deletions pkg/featuregate/featuregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ var (
featuregate.WithRegisterDescription("enables features associated to the Prometheus Operator"),
featuregate.WithRegisterFromVersion("v0.82.0"),
)

// SkipMultiInstrumentationContainerValidation is the feature gate that controls whether the operator will skip
// container name validation during pod mutation for multi-instrumentation. Enabling this feature allows multiple
// instrumentations for pods without specified container name annotations. Does not prevent specification
// annotations from being used.
SkipMultiInstrumentationContainerValidation = featuregate.GlobalRegistry().MustRegister(
"operator.autoinstrumentation.multi-instrumentation.skip-container-validation",
featuregate.StageAlpha,
featuregate.WithRegisterDescription("controls whether the operator validates the container annotations when multi-instrumentation is enabled"))
)

// Flags creates a new FlagSet that represents the available featuregate flags using the supplied featuregate registry.
Expand Down
4 changes: 4 additions & 0 deletions pkg/instrumentation/podmutator.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ func (langInsts languageInstrumentations) areContainerNamesConfiguredForMultiple
var instrWithContainers int
var allContainers []string

if featuregate.SkipMultiInstrumentationContainerValidation.IsEnabled() {
return true, nil
}

// Check for instrumentations with and without containers.
if langInsts.Java.Instrumentation != nil {
instrWithContainers += isInstrWithContainers(langInsts.Java)
Expand Down

0 comments on commit 7c99e21

Please sign in to comment.