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

New IBM MQ Scaler #1254

Closed
wants to merge 18 commits into from
Closed

New IBM MQ Scaler #1254

wants to merge 18 commits into from

Conversation

jessm12
Copy link
Contributor

@jessm12 jessm12 commented Oct 14, 2020

As outlined in issue #1253:

  • Add the Scaler file and switch case for an IBM MQ scaler that scales depending on queue depth of an IBM MQ Queue.
  • Add the unit tests for this scaler.

Checklist

  • Commits are signed with Developer Certificate of Origin (DCO)
  • Tests have been added
  • A PR is opened to update the documentation on https://github.com/kedacore/keda-docs
  • Changelog has been updated

@zroubalik
Copy link
Member

Could you please fix the DCO? https://github.com/kedacore/keda/blob/v2/CONTRIBUTING.md#i-didnt-sign-my-commit-now-what (might be actually easier for you to squash all your commits into one and sign that one)

There are some linting problems, see the Static Check Details. You can always check your code before commiting by running make golangci

@@ -0,0 +1,218 @@
/**
* © Copyright IBM Corporation 2020
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The IBM Copyright shouldn't be here.

@@ -0,0 +1,121 @@
/**
* © Copyright IBM Corporation 2020
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dtto


resp, err := client.Do(req)
if err != nil {
panic(err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should just return the error rather than panicing the entire process.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ahmelsayed, we've included a potential fix for this in PR #1259

var response CommandResponse
json.Unmarshal(body, &response)

return response.CommandResponse[0].Parameters.Curdepth, nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this might panic if CommandResponse was empty, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ahmelsayed, we've included a potential fix for this in PR #1259

}
defer resp.Body.Close()

body, _ := ioutil.ReadAll(resp.Body)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: handle ioutil read error in case the body stream got closed in the interim

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ahmelsayed, we've included a potential fix for this in PR #1259

body, _ := ioutil.ReadAll(resp.Body)

var response CommandResponse
json.Unmarshal(body, &response)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: handle Unmarshal returned error in case body is not a valid JSON

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ahmelsayed, we've included a potential fix for this in PR #1259

targetQueueLengthQty := resource.NewQuantity(int64(s.metadata.targetQueueDepth), resource.DecimalSI)
externalMetric := &v2beta2.ExternalMetricSource{
Metric: v2beta2.MetricIdentifier{
Name: kedautil.NormalizeString(fmt.Sprintf("%s-%s", "IBMMQ", s.metadata.queueName)),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The metric name should be unique, that means that if you specify two or more IBM MQ scalers in one ScaledObject, each scaler should have a different metric name. I wonder if this is enough?
Is viable a usecase, where we have two MQ scalers with the same queueName but pointing to the different MQ (server)?

@jessm12 jessm12 mentioned this pull request Oct 15, 2020
4 tasks
@cpilton
Copy link
Contributor

cpilton commented Oct 15, 2020

Thanks for all your feedback so far! 👍
We’ve created a new pull request ( #1259 ) which contains a single, signed commit. We’ve also implemented the DCO bot (as well as some of the other checks) into our own repository.
We've also implemented many of your requested changes inside this request 😄

@zroubalik
Copy link
Member

Thanks for all your feedback so far! 👍
We’ve created a new pull request ( #1259 ) which contains a single, signed commit. We’ve also implemented the DCO bot (as well as some of the other checks) into our own repository.
We've also implemented many of your requested changes inside this request 😄

Great thanks! I'm closing this, let's continue on the new PR

@zroubalik zroubalik closed this Oct 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants