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

Add support for next_query_flagIN #74

Merged
merged 9 commits into from
Sep 22, 2021
Merged

Add support for next_query_flagIN #74

merged 9 commits into from
Sep 22, 2021

Conversation

ls-michielrensen
Copy link
Contributor

SUMMARY

This PR adds support for next_query_flagIN in the proxysql_query_rules plugin

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

proxysql_query_rules

ADDITIONAL INFORMATION

next_query_flagIN allows to chain query rules which is useful for when example you want to allow a SELECT after an INSERT/UPDATE/DELETE to run on the same hostgroup (avoiding replication lag).

- name: Add insert query rule
   proxysql_query_rules:
      match_digest: "^INSERT"
      destination_hostgroup: 1,
      next_query_flagIN: 1

- name: Add update query rule
   proxysql_query_rules:
      match_digest: "^UPDATE"
      destination_hostgroup: 1,
      next_query_flagIN: 1

- name: Add delete query rules
   proxysql_query_rules:
      match_digest: "^DELETE"
      destination_hostgroup: 1,
      next_query_flagIN: 1

- name: Add insert query rules
   proxysql_query_rules:
      match_digest: ".*"
      destination_hostgroup: 1,
      next_query_flagIN: 1
      comment: Match every queries after an INSERT/UPDATE/DELETE query

With C(CASELESS) the match is case insensitive. With C(GLOBAL) the replace
is global (replaces all matches and not just the first).
For backward compatibility, only C(CASELESS) is the enabled by default.
version_added: "2.9"
Copy link
Member

Choose a reason for hiding this comment

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

version added would be 1.3.0.
can you also please add a changelog fragement @ls-michielrensen?

futhermore I'm afraid that this will break backwards compatibility with proxysql 1.x.x like #71 #73

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah it probably is not backwards compatible no, do we need to add a version constraint somewhere?

Copy link
Member

Choose a reason for hiding this comment

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

basically you can adopt like this: ca47c32
This is imo sufficient. The integration test must be updated/prepared. I'm working on that already in #73

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

@Andersson007 Andersson007 left a comment

Choose a reason for hiding this comment

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

@ls-michielrensen thanks for the PR!

I'm abstain from evaluating this changes as I'm not a specialist.

@markuman knows better:)

I would also add:

  1. Example to the EXAMPLES block
  2. Integration tests
  3. Changelog fragment as @markuman spotted
  4. Mention in the options descriptions that they are supported since ProxySQL version ..., otherwise they should be ignored or the module should fail. Not sure which approach is better

plugins/modules/proxysql_query_rules.py Outdated Show resolved Hide resolved
plugins/modules/proxysql_query_rules.py Outdated Show resolved Hide resolved
@ls-michielrensen
Copy link
Contributor Author

ls-michielrensen commented Sep 21, 2021

@ls-michielrensen thanks for the PR!

I'm abstain from evaluating this changes as I'm not a specialist.

@markuman knows better:)

I would also add:

  1. Example to the EXAMPLES blocks

Added the example from this PR description to the block

  1. Integration tests

Uh gotta figure that out (first-timer here...)

  1. Changelog fragment as @markuman spotted

Changelog fragment added

  1. Mention in the options descriptions that they are supported since ProxySQL version ..., otherwise they should be ignored or the module should fail. Not sure which approach is better

Added version constraint as suggested by @markuman in ca47c32

@ls-michielrensen
Copy link
Contributor Author

@markuman Your suggestion to add version constraints seemed to have broken the Integration tests. I guess we'll have to figure that out some other way...

@markuman
Copy link
Member

@markuman Your suggestion to add version constraints seemed to have broken the Integration tests. I guess we'll have to figure that out some other way...

No, there is something failing that is not affected by your PR

TASK [test_proxysql_replication_hostgroups : verify idempotent - change for proxysql >= 2] ***

However, as mentioned above, you can revert it, because the table also exists in 1.4.15. It was my fault.

@markuman
Copy link
Member

I see two sanity erros locally

ERROR: plugins/modules/proxysql_query_rules.py:268:82: W291: trailing whitespace
ERROR: plugins/modules/proxysql_query_rules.py:273:24: invalid-examples: EXAMPLES is not valid YAML

@ls-michielrensen
Copy link
Contributor Author

@markuman thanks, fixed the sanity failures, silly mistake on my end. Also reverted the version constraint 👍🏻

@markuman
Copy link
Member

Integration test pass locally for test_proxysql_query_rules.
Last missing peace is to append the existing integration test and test the new parameters (add/modify in check_mode, not in check_mode and idempotent).

@ls-michielrensen
Copy link
Contributor Author

@markuman thanks for double checking. Can you point me in the right direction as to how to run the integration tests locally?

@Andersson007
Copy link
Contributor

@ls-michielrensen
Copy link
Contributor Author

@Andersson007 thanks for the headsup, worked flawlessly 👍🏻
@markuman I amended the integration tests to include next_query_flagIN. The tests are passing for me locally 👍🏻

Copy link
Member

@markuman markuman left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@Andersson007 Andersson007 left a comment

Choose a reason for hiding this comment

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

LGTM from general perspective:)

@markuman markuman merged commit 922c412 into ansible-collections:main Sep 22, 2021
@ls-michielrensen ls-michielrensen deleted the add-support-for-next_query_flagIN branch September 22, 2021 13:23
@Andersson007
Copy link
Contributor

@ls-michielrensen thanks for the contribution! @markuman thanks for reviewing and merging!

@ls-michielrensen
Copy link
Contributor Author

@Andersson007 you're welcome, was a fun experience and quickly executed 👍🏻

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.

3 participants