-
Notifications
You must be signed in to change notification settings - Fork 418
Fix: kafka-connect connectors deployment in serial mode #2161
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -448,40 +448,21 @@ | |
| - not ansible_check_mode | ||
| tags: health_check | ||
|
|
||
| # Set a host fact with the direct cluster parent group | ||
| # Host of the same cluster have the same group.id | ||
| - name: Set parent Cluster | ||
| vars: | ||
| keywords: | ||
| - kafka_connect | ||
| - kafka_connect_parallel | ||
| - kafka_connect_serial | ||
| - kafka_broker | ||
| - kafka_broker_parallel | ||
| - kafka_broker_serial | ||
| - kafka_rest | ||
| - kafka_rest_parallel | ||
| - kafka_rest_serial | ||
| - control_center_next_gen | ||
| - control_center_next_gen_parallel | ||
| - control_center_next_gen_serial | ||
| - ksql | ||
| - ksql_parallel | ||
| - ksql_serial | ||
| - schema_registry | ||
| - kafka_controller | ||
| - kafka_controller_parallel | ||
| - kafka_controller_serial | ||
| set_fact: | ||
| parent_kafka_connect_cluster_group: "{{ (group_names | difference(keywords))[0] | default('kafka_connect') }}" | ||
| parent_kafka_connect_cluster_id: "{{ kafka_connect_final_properties['group.id'] }}" | ||
|
|
||
| # TODO needs to be ran over kafka-connect subgroups (i.e. multiple kafka-connect clusters in same inventory) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would like to discuss with someone about how to implement this subgroup in this or higher level. |
||
| - name: Register Cluster | ||
| include_tasks: register_cluster.yml | ||
| when: | ||
| - rbac_enabled | ||
| - inventory_hostname == ansible_play_hosts_all[0] # for serial mode playbook | ||
| run_once: true | ||
|
|
||
| # TODO needs to be ran over kafka-connect subgroups (i.e. multiple kafka-connect clusters in same inventory) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would like to discuss with someone about how to implement this subgroup in this or higher level. |
||
| - name: Deploy Connectors | ||
| include_tasks: deploy_connectors.yml | ||
| when: | ||
| - kafka_connect_connectors is defined | ||
| - inventory_hostname == ansible_play_hosts_all[0] # for serial mode playbook | ||
| run_once: true | ||
|
|
||
| - name: Delete temporary keys/certs when keystore and trustore is provided | ||
| file: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,6 @@ | |
| import_role: | ||
| name: common | ||
| tasks_from: rbac_setup.yml | ||
| when: rbac_enabled | ||
| vars: | ||
| copy_certs: false | ||
| delegated_to_localhost: "{{ external_mds_enabled|bool }}" | ||
|
|
@@ -25,17 +24,22 @@ | |
| # For single cluster delegating this task to broker as in case of cert based token retrival only broker can get a super user token using its certs | ||
| # For Centralized MDS other clusters can't delegate to MDS cluster as that cluster may not have permissions to ssh into MDS, thus delegate to localhost | ||
|
|
||
| - name: Fetch Kafka Connect Cluster Groups | ||
| - name: Lookup cluster hosts | ||
| vars: | ||
| - connect_cluster_workers: [] | ||
| set_fact: | ||
| active_kafka_connect_groups: "{{ (((active_kafka_connect_groups | default([])) + hostvars[item].group_names) | difference('kafka_connect'+'kafka_connect_parallel'+'kafka_connect_serial'+ 'kafka_broker'+ 'kafka_broker_parallel'+'kafka_broker_serial'+'ksql'+ 'ksql_parallel'+'ksql_serial'+'control_center_next_gen'+'control_center_next_gen_parallel'+'control_center_next_gen_serial'+'schema_registry'+'kafka_rest'+'kafka_rest_parallel'+'kafka_rest_serial'+'kafka_controller'+'kafka_controller_parallel'+'kafka_controller_serial')) | default(['kafka_connect'], true) }}" | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment: original code has same issue as explained in https://github.com/confluentinc/cp-ansible/pull/2161/files#r2185136443 . |
||
| with_items: "{{ ansible_play_hosts }}" | ||
| connect_cluster_workers: "{{ connect_cluster_workers + [ { 'host': hostvars[item]['ansible_host'], 'port': kafka_connect_rest_port } ] }}" | ||
| loop: "{{ groups['kafka_connect'] }}" | ||
|
|
||
| - name: Register Kafka Connect Cluster | ||
| vars: | ||
| cluster_host_delegates: "{{ active_kafka_connect_groups | map('extract', groups, 0)| list }}" | ||
| cluster_group: "{{ hostvars[item].parent_kafka_connect_cluster_group }}" | ||
| cluster_name: "{{ hostvars[item].kafka_connect_cluster_name }}" | ||
| cluster_id: "{{ hostvars[item].parent_kafka_connect_cluster_id }}" | ||
| cluster_register_request: | ||
| - clusterName: "{{ kafka_connect_cluster_name }}" | ||
| protocol: "{{ kafka_connect_http_protocol | upper }}" | ||
| scope: | ||
| kafka-cluster: "{{ kafka_cluster_id }}" | ||
| connect-cluster: "{{ kafka_connect_final_properties['group.id'] }}" | ||
| hosts: "{{ connect_cluster_workers }}" | ||
| uri: | ||
| url: "{{mds_bootstrap_server_urls.split(',')[0]}}/security/1.0/registry/clusters" | ||
| method: POST | ||
|
|
@@ -46,27 +50,9 @@ | |
| client_cert: "{{ kafka_connect_cert_path if send_client_cert|bool else omit }}" | ||
| client_key: "{{ kafka_connect_key_path if send_client_cert|bool else omit }}" | ||
| body_format: json | ||
| body: > | ||
| [ | ||
| { | ||
| "clusterName": "{{cluster_name}}", | ||
| "scope": { | ||
| "clusters": { | ||
| "kafka-cluster": "{{kafka_cluster_id}}", | ||
| "connect-cluster": "{{cluster_id}}" | ||
| } | ||
| }, | ||
| "hosts": [ {% for inv_host in groups[cluster_group] %}{% if loop.index > 1%},{% endif %}{ "host": "{{hostvars[inv_host]|confluent.platform.resolve_hostname}}", "port": {% if hostvars[inv_host].kafka_connect_rest_port is defined %} {{hostvars[inv_host].kafka_connect_rest_port}} {% else %} {{kafka_connect_rest_port}} {% endif %} }{% endfor %} ], | ||
| "protocol": "{{kafka_connect_http_protocol | upper}}" | ||
| } | ||
| ] | ||
| body: "{{ cluster_register_request | to_json }}" | ||
| status_code: 204 | ||
| register: output | ||
| until: output.status == 204 | ||
| retries: "{{ mds_retries }}" | ||
| delay: 10 | ||
| when: | ||
| - hostvars[item].get("rbac_enabled", false)|bool | ||
| - hostvars[item].kafka_connect_cluster_name is defined | ||
| - hostvars[item].parent_kafka_connect_cluster_id is defined | ||
| with_items: "{{ cluster_host_delegates }}" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment: we have investigated and this seems to be not working as it is expected to work. The
difference()function expects an(array, array)as input, but here it consumes(array, string). It doesn't fail, because it implicitly convertsstrto array of characters.