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

Remove deprecated tlsCertFile from External scaler #6338

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ New deprecation(s):

### Breaking Changes

- TODO ([#XXX](https://github.com/kedacore/keda/issues/XXX))
**External Scaler**: Remove deprecated tlsCertFile from External scaler ([#4549](https://github.com/kedacore/keda/issues/4549))

### Other

Expand Down
26 changes: 4 additions & 22 deletions pkg/scalers/external_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ type externalPushScaler struct {

type externalScalerMetadata struct {
scalerAddress string
tlsCertFile string
originalMetadata map[string]string
triggerIndex int
caCert string
Expand Down Expand Up @@ -116,10 +115,6 @@ func parseExternalScalerMetadata(config *scalersconfig.ScalerConfig) (externalSc
return meta, fmt.Errorf("scaler Address is a required field")
}

if val, ok := config.TriggerMetadata["tlsCertFile"]; ok && val != "" {
meta.tlsCertFile = val
}

meta.originalMetadata = make(map[string]string)
if val, ok := config.AuthParams["caCert"]; ok {
meta.caCert = val
Expand Down Expand Up @@ -164,7 +159,7 @@ func (s *externalScaler) Close(context.Context) error {
func (s *externalScaler) GetMetricSpecForScaling(ctx context.Context) []v2.MetricSpec {
var result []v2.MetricSpec

grpcClient, err := getClientForConnectionPool(s.metadata, s.logger)
grpcClient, err := getClientForConnectionPool(s.metadata)
if err != nil {
s.logger.Error(err, "error building grpc connection")
return result
Expand Down Expand Up @@ -199,7 +194,7 @@ func (s *externalScaler) GetMetricSpecForScaling(ctx context.Context) []v2.Metri
// GetMetricsAndActivity returns value for a supported metric and an error if there is a problem getting the metric
func (s *externalScaler) GetMetricsAndActivity(ctx context.Context, metricName string) ([]external_metrics.ExternalMetricValue, bool, error) {
var metrics []external_metrics.ExternalMetricValue
grpcClient, err := getClientForConnectionPool(s.metadata, s.logger)
grpcClient, err := getClientForConnectionPool(s.metadata)
if err != nil {
return []external_metrics.ExternalMetricValue{}, false, err
}
Expand Down Expand Up @@ -240,7 +235,7 @@ func (s *externalPushScaler) Run(ctx context.Context, active chan<- bool) {
defer close(active)
// It's possible for the connection to get terminated anytime, we need to run this in a retry loop
runWithLog := func() {
grpcClient, err := getClientForConnectionPool(s.metadata, s.logger)
grpcClient, err := getClientForConnectionPool(s.metadata)
if err != nil {
s.logger.Error(err, "error running internalRun")
return
Expand Down Expand Up @@ -301,24 +296,11 @@ var connectionPoolMutex sync.Mutex

// getClientForConnectionPool returns a grpcClient and a done() Func. The done() function must be called once the client is no longer
// in use to clean up the shared grpc.ClientConn
func getClientForConnectionPool(metadata externalScalerMetadata, logger logr.Logger) (pb.ExternalScalerClient, error) {
func getClientForConnectionPool(metadata externalScalerMetadata) (pb.ExternalScalerClient, error) {
connectionPoolMutex.Lock()
defer connectionPoolMutex.Unlock()

buildGRPCConnection := func(metadata externalScalerMetadata) (*grpc.ClientConn, error) {
// FIXME: DEPRECATED to be removed in v2.13 https://github.com/kedacore/keda/issues/4549
if metadata.tlsCertFile != "" {
logger.V(1).Info("tlsCertFile in ScaleObject metadata will be deprecated in v2.12. Please use" +
"tlsClientCert, tlsClientKey and caCert in TriggerAuthentication instead.")
creds, err := credentials.NewClientTLSFromFile(metadata.tlsCertFile, "")
if err != nil {
return nil, err
}
return grpc.NewClient(metadata.scalerAddress,
grpc.WithDefaultServiceConfig(grpcConfig),
grpc.WithTransportCredentials(creds))
}

tlsConfig, err := util.NewTLSConfig(metadata.tlsClientCert, metadata.tlsClientKey, metadata.caCert, metadata.unsafeSsl)
if err != nil {
return nil, err
Expand Down
Loading