Skip to content

Commit

Permalink
Pulsar: remove deprecated trigger name (#6092)
Browse files Browse the repository at this point in the history
* remove deprecated trigger name in Pulsar scaler

Signed-off-by: Kun Woo Yoo <vbtkdpf148@gmail.com>

* Update CHANGELOG.md

Signed-off-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>
Signed-off-by: Kun Woo Yoo <vbtkdpf148@gmail.com>

* remove deprecated Pulsar trigger name from test

Signed-off-by: Kun Woo Yoo <vbtkdpf148@gmail.com>

---------

Signed-off-by: Kun Woo Yoo <vbtkdpf148@gmail.com>
Signed-off-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>
Co-authored-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>
  • Loading branch information
kunwooy and JorTurFer committed Sep 4, 2024
1 parent 85d4dca commit 9e51a78
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 24 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ New deprecation(s):

### Breaking Changes

- TODO ([#XXX](https://github.com/kedacore/keda/issues/XXX))
- **Pulsar Scaler**: remove `msgBacklog` trigger name ([#6059](https://github.com/kedacore/keda/issues/6059))

### Other

Expand Down
19 changes: 4 additions & 15 deletions pkg/scalers/pulsar_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ type pulsarMetadata struct {
}

const (
msgBacklogMetricName = "msgBacklog"
pulsarMetricType = "External"
defaultMsgBacklogThreshold = 10
enable = "enable"
Expand Down Expand Up @@ -133,7 +132,7 @@ func NewPulsarScaler(config *scalersconfig.ScalerConfig) (Scaler, error) {
}, nil
}

func parsePulsarMetadata(config *scalersconfig.ScalerConfig, logger logr.Logger) (pulsarMetadata, error) {
func parsePulsarMetadata(config *scalersconfig.ScalerConfig, _ logr.Logger) (pulsarMetadata, error) {
meta := pulsarMetadata{}
switch {
case config.TriggerMetadata["adminURLFromEnv"] != "":
Expand Down Expand Up @@ -182,23 +181,13 @@ func parsePulsarMetadata(config *scalersconfig.ScalerConfig, logger logr.Logger)

meta.msgBacklogThreshold = defaultMsgBacklogThreshold

// FIXME: msgBacklog support DEPRECATED to be removed in v2.14
fmt.Println(config.TriggerMetadata)
if val, ok := config.TriggerMetadata[msgBacklogMetricName]; ok {
logger.V(1).Info("\"msgBacklog\" is deprecated and will be removed in v2.14, please use \"msgBacklogThreshold\" instead")
if val, ok := config.TriggerMetadata["msgBacklogThreshold"]; ok {
t, err := strconv.ParseInt(val, 10, 64)
if err != nil {
return meta, fmt.Errorf("error parsing %s: %w", msgBacklogMetricName, err)
}
meta.msgBacklogThreshold = t
} else if val, ok := config.TriggerMetadata["msgBacklogThreshold"]; ok {
t, err := strconv.ParseInt(val, 10, 64)
if err != nil {
return meta, fmt.Errorf("error parsing %s: %w", msgBacklogMetricName, err)
return meta, fmt.Errorf("error parsing %s: %w", "msgBacklogThreshold", err)
}
meta.msgBacklogThreshold = t
}
// END FIXME

// For backwards compatibility, we need to map "tls: enable" to
if tls, ok := config.TriggerMetadata["tls"]; ok {
Expand All @@ -212,7 +201,7 @@ func parsePulsarMetadata(config *scalersconfig.ScalerConfig, logger logr.Logger)
}
auth, err := authentication.GetAuthConfigs(config.TriggerMetadata, config.AuthParams)
if err != nil {
return meta, fmt.Errorf("error parsing %s: %w", msgBacklogMetricName, err)
return meta, fmt.Errorf("error parsing %s: %w", "msgBacklogThreshold", err)
}

if auth != nil && auth.EnableOAuth {
Expand Down
9 changes: 1 addition & 8 deletions pkg/scalers/pulsar_scaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,7 @@ func TestParsePulsarMetadata(t *testing.T) {
}

var testDataMsgBacklogThreshold int64
// FIXME: msgBacklog support DEPRECATED to be removed in v2.14
if val, ok := testData.metadata["msgBacklog"]; ok {
testDataMsgBacklogThreshold, err = strconv.ParseInt(val, 10, 64)
if err != nil {
t.Errorf("error parseing msgBacklog: %v", err)
}
// END FiXME
} else if val, ok := testData.metadata["msgBacklogThreshold"]; ok {
if val, ok := testData.metadata["msgBacklogThreshold"]; ok {
testDataMsgBacklogThreshold, err = strconv.ParseInt(val, 10, 64)
if err != nil {
t.Errorf("error parseing msgBacklogThreshold: %v", err)
Expand Down

0 comments on commit 9e51a78

Please sign in to comment.