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

feat: add support config allow_connection and some things about read only routing #338

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

zhuatuzilo
Copy link

@zhuatuzilo zhuatuzilo commented Feb 23, 2025

Feature: add two variable in inventory:

mssql_ha_secondary_role_allow_connections - READ_ONLY or ALL or NO - default ALL

mssql_ha_read_only_routing_list - e.g. ('node-4','node-6') - if undefined or empty value , will not set read only routing list - default is undefined

See this for possible values and more info - https://learn.microsoft.com/en-us/sql/database-engine/availability-groups/windows/configure-read-only-routing-for-an-availability-group-sql-server?view=sql-server-ver16

add auto set read only routing url like 'tcp://node-4:1433', '1433' from var: mssql_tcp_port

it's work in my local, I test two example
1、the variable is defined as
mssql_ha_secondary_role_allow_connections: READ_ONLY
mssql_ha_read_only_routing_list: ('node-5','node-6')
result: as expected

2、the variable is undefined
result: allow connections be 'ALL', read only routing list be NULL, as expected

Reason: we need READ ONLY ROUTING LIST used to provide read write separation and load balance for read only (or priority of human control for read only), if need READ ONLY ROUTING LIST then must defined READ ONLY ROUTING URL at first.

SECONDARY_ROLE ( ALLOW_CONNECTION='READ_ONLY') used to verify attribute defined in the connection string on replica which is secondary role, like ApplicationIntent=ReadOnly.

Result: Users can configure an Always On availability group to support read-only routing

@spetrosi
Copy link
Collaborator

@zhuatuzilo that's a huge improvement, many thanks for your contributions.

I need to cover these new variables with tests. What would be the verification steps to test that this setup works?
In our CI we can run multihost tests - i.e. provision 1 control node and 3 managed nodes, and then build an inventory, and playbook, and run it.
We do this e.g. in https://github.com/linux-system-roles/mssql/blob/main/tests/tests_configure_ha_cluster_external.yml#L182-L263

Would you be able to come up with similar verification tasks?

value: 30s
ha_cluster_resource_clones:
- resource_id: ag_cluster
promotable: yes
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
promotable: yes
promotable: true

Copy link
Contributor

Choose a reason for hiding this comment

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

I know the README example uses yes - but this fails ansible-lint - Ansible strongly prefers the use of true/false

@richm
Copy link
Contributor

richm commented Feb 25, 2025

@zhuatuzilo thank you for the submission. Can you please explain a bit more about why a user would need to use this new feature?

@zhuatuzilo
Copy link
Author

@zhuatuzilo thank you for the submission. Can you please explain a bit more about why a user would need to use this new feature?

we need READ ONLY ROUTING LIST used to read write separation and load balance for read only (or priority of human contrl for read only), if need READ ONLY ROUTING LIST is work must defined READ ONLY ROUTING URL at first.

SECONDARY_ROLE ( ALLOW_CONNECTION='READ_ONLY') used to veify attribute defined in the connection string on replica which is secondary role,
like ApplicationIntent=ReadOnly.
see the doc from microsoft: https://learn.microsoft.com/zh-cn/sql/database-engine/availability-groups/windows/configure-read-only-routing-for-an-availability-group-sql-server?view=sql-server-ver16

@zhuatuzilo
Copy link
Author

@zhuatuzilo that's a huge improvement, many thanks for your contributions.

I need to cover these new variables with tests. What would be the verification steps to test that this setup works? In our CI we can run multihost tests - i.e. provision 1 control node and 3 managed nodes, and then build an inventory, and playbook, and run it. We do this e.g. in https://github.com/linux-system-roles/mssql/blob/main/tests/tests_configure_ha_cluster_external.yml#L182-L263

Would you be able to come up with similar verification tasks?

sorry
this is a bit difficult for me

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