Skip to content

Commit 713e146

Browse files
committed
fix data race condition
1 parent a883fe6 commit 713e146

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

cmd/gateway/commands.go

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,6 @@ const (
4444
endpointPickerEnableSecureVerifyFlag = "endpoint-picker-enable-secure-verify"
4545
)
4646

47-
// common flags.
48-
var (
49-
endpointPickerDisableTLS bool
50-
endpointPickerEnableSecureVerify bool
51-
)
52-
5347
// usageReportParams holds the parameters for building the usage report configuration for PLUS.
5448
type usageReportParams struct {
5549
SecretName stringValidatingValue
@@ -170,6 +164,9 @@ func createControllerCommand() *cobra.Command {
170164
nginxDockerSecrets = stringSliceValidatingValue{
171165
validator: validateResourceName,
172166
}
167+
168+
endpointPickerDisableTLS bool
169+
endpointPickerEnableSecureVerify bool
173170
)
174171

175172
usageReportParams := usageReportParams{
@@ -451,7 +448,7 @@ func createControllerCommand() *cobra.Command {
451448
"traffic to AI workloads.",
452449
)
453450

454-
addEPPConnectionFlags(cmd)
451+
addEPPConnectionFlags(cmd, endpointPickerDisableTLS, endpointPickerEnableSecureVerify)
455452

456453
cmd.Flags().Var(
457454
&nginxDockerSecrets,
@@ -770,6 +767,7 @@ func createSleepCommand() *cobra.Command {
770767
}
771768

772769
func createEndpointPickerCommand() *cobra.Command {
770+
var endpointPickerDisableTLS, endpointPickerEnableSecureVerify bool
773771
cmd := &cobra.Command{
774772
Use: "endpoint-picker",
775773
Short: "Shim server for communication between NGINX and the Gateway API Inference Extension Endpoint Picker",
@@ -783,22 +781,22 @@ func createEndpointPickerCommand() *cobra.Command {
783781
},
784782
}
785783

786-
addEPPConnectionFlags(cmd)
784+
addEPPConnectionFlags(cmd, endpointPickerDisableTLS, endpointPickerEnableSecureVerify)
787785

788786
return cmd
789787
}
790788

791-
func addEPPConnectionFlags(cmd *cobra.Command) {
789+
func addEPPConnectionFlags(cmd *cobra.Command, disableTLS, enableSecureVerify bool) {
792790
cmd.Flags().BoolVar(
793-
&endpointPickerDisableTLS,
791+
&disableTLS,
794792
endpointPickerDisableTLSFlag,
795793
false,
796794
"Disables TLS when connecting to the EndpointPicker. "+
797795
"Set to true only for development/testing or when using a service mesh for encryption.",
798796
)
799797

800798
cmd.Flags().BoolVar(
801-
&endpointPickerEnableSecureVerify,
799+
&enableSecureVerify,
802800
endpointPickerEnableSecureVerifyFlag,
803801
false,
804802
"Enables server certificate verification when connecting to the EndpointPicker, if TLS is enabled. "+

0 commit comments

Comments
 (0)