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

Pulsar: remove deprecated trigger name #6092

Merged
merged 3 commits into from
Sep 4, 2024
Merged
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 @@ -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
Loading