-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-12374: Add missing config sasl.mechanism.controller.protocol #10199
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
Changes from 4 commits
29327ba
462019c
c13ac91
6603350
23389e7
48122c6
b03cccf
d96813b
6e6b32b
e58e5c9
b479327
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 |
|---|---|---|
|
|
@@ -96,4 +96,59 @@ def test_simple_run(self, producer_version, security_protocol = 'PLAINTEXT', sas | |
| num_produced = self.producer.num_acked | ||
| assert num_produced == self.num_messages, "num_produced: %d, num_messages: %d" % (num_produced, self.num_messages) | ||
|
|
||
| @cluster(num_nodes=4) | ||
| @matrix(inter_broker_security_protocol=['PLAINTEXT', 'SSL'], metadata_quorum=[quorum.remote_raft]) | ||
| @matrix(inter_broker_security_protocol=['SASL_SSL'], inter_broker_sasl_mechanism=['PLAIN', 'GSSAPI'], | ||
| metadata_quorum=[quorum.remote_raft]) | ||
| def test_multiple_raft_security_protocols( | ||
| self, inter_broker_security_protocol, inter_broker_sasl_mechanism='GSSAPI', metadata_quorum=quorum.remote_raft): | ||
| """ | ||
| Test for remote Raft cases that we can start VerifiableProducer on the current branch snapshot version, and | ||
| verify that we can produce a small number of messages. The inter-controller and broker-to-controller | ||
| security protocols are defined to be different (which differs from the above test, where they were the same). | ||
| """ | ||
| self.kafka.security_protocol = self.kafka.interbroker_security_protocol = inter_broker_security_protocol | ||
| self.kafka.client_sasl_mechanism = self.kafka.interbroker_sasl_mechanism = inter_broker_sasl_mechanism | ||
| controller_quorum = self.kafka.controller_quorum | ||
| sasl_mechanism = 'PLAIN' if inter_broker_sasl_mechanism == 'GSSAPI' else 'GSSAPI' | ||
| if inter_broker_security_protocol == 'PLAINTEXT': | ||
| controller_security_protocol = 'SSL' | ||
| intercontroller_security_protocol = 'SASL_SSL' | ||
| elif inter_broker_security_protocol == 'SSL': | ||
| controller_security_protocol = 'SASL_SSL' | ||
| intercontroller_security_protocol = 'PLAINTEXT' | ||
| else: # inter_broker_security_protocol == 'SASL_SSL' | ||
| controller_security_protocol = 'PLAINTEXT' | ||
| intercontroller_security_protocol = 'SSL' | ||
| controller_quorum.controller_security_protocol = controller_security_protocol | ||
| controller_quorum.controller_sasl_mechanism = sasl_mechanism | ||
| controller_quorum.intercontroller_security_protocol = intercontroller_security_protocol | ||
| controller_quorum.intercontroller_sasl_mechanism = sasl_mechanism | ||
| self.kafka.start() | ||
|
|
||
| node = self.producer.nodes[0] | ||
| node.version = KafkaVersion(str(DEV_BRANCH)) | ||
| self.producer.start() | ||
| wait_until(lambda: self.producer.num_acked > 5, timeout_sec=15, | ||
| err_msg="Producer failed to start in a reasonable amount of time.") | ||
|
|
||
| # using version.vstring (distutils.version.LooseVersion) is a tricky way of ensuring | ||
| # that this check works with DEV_BRANCH | ||
| # When running VerifiableProducer 0.8.X, both the current branch version and 0.8.X should show up because of the | ||
| # way verifiable producer pulls in some development directories into its classpath | ||
| # | ||
| # If the test fails here because 'ps .. | grep' couldn't find the process it means | ||
| # the login and grep that is_version() performs is slower than | ||
| # the time it takes the producer to produce its messages. | ||
| # Easy fix is to decrease throughput= above, the good fix is to make the producer | ||
| # not terminate until explicitly killed in this case. | ||
| if node.version <= LATEST_0_8_2: | ||
| assert is_version(node, [node.version.vstring, DEV_BRANCH.vstring], logger=self.logger) | ||
| else: | ||
|
Contributor
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. This stuff can probably be removed. Remote Raft isn't supported on older versions, and the comment appears above anyway. |
||
| assert is_version(node, [node.version.vstring], logger=self.logger) | ||
|
|
||
| self.producer.wait() | ||
| num_produced = self.producer.num_acked | ||
| assert num_produced == self.num_messages, "num_produced: %d, num_messages: %d" % (num_produced, self.num_messages) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -145,7 +145,8 @@ class SecurityConfig(TemplateRenderer): | |
| def __init__(self, context, security_protocol=None, interbroker_security_protocol=None, | ||
| client_sasl_mechanism=SASL_MECHANISM_GSSAPI, interbroker_sasl_mechanism=SASL_MECHANISM_GSSAPI, | ||
| zk_sasl=False, zk_tls=False, template_props="", static_jaas_conf=True, jaas_override_variables=None, | ||
| listener_security_config=ListenerSecurityConfig(), tls_version=None): | ||
| listener_security_config=ListenerSecurityConfig(), tls_version=None, | ||
| raft_sasl_mechanisms=[], raft_tls=False): | ||
| """ | ||
| Initialize the security properties for the node and copy | ||
| keystore and truststore to the remote node if the transport protocol | ||
|
|
@@ -173,8 +174,9 @@ def __init__(self, context, security_protocol=None, interbroker_security_protoco | |
| if interbroker_security_protocol is None: | ||
| interbroker_security_protocol = security_protocol | ||
| self.interbroker_security_protocol = interbroker_security_protocol | ||
| self.has_sasl = self.is_sasl(security_protocol) or self.is_sasl(interbroker_security_protocol) or zk_sasl | ||
| self.has_ssl = self.is_ssl(security_protocol) or self.is_ssl(interbroker_security_protocol) or zk_tls | ||
| self.raft_sasl_mechanisms = raft_sasl_mechanisms | ||
| self.has_sasl = self.is_sasl(security_protocol) or self.is_sasl(interbroker_security_protocol) or zk_sasl or raft_sasl_mechanisms | ||
| self.has_ssl = self.is_ssl(security_protocol) or self.is_ssl(interbroker_security_protocol) or zk_tls or raft_tls | ||
| self.zk_sasl = zk_sasl | ||
| self.zk_tls = zk_tls | ||
| self.static_jaas_conf = static_jaas_conf | ||
|
|
@@ -250,14 +252,16 @@ def setup_sasl(self, node): | |
| 'is_ibm_jdk': any('IBM' in line for line in java_version), | ||
| 'SecurityConfig': SecurityConfig, | ||
| 'client_sasl_mechanism': self.client_sasl_mechanism, | ||
| 'enabled_sasl_mechanisms': self.enabled_sasl_mechanisms | ||
| 'enabled_sasl_mechanisms': self.enabled_sasl_mechanisms, | ||
| 'usable_sasl_mechanisms': self.usable_sasl_mechanisms | ||
| } | ||
| ) | ||
| else: | ||
| jaas_conf = self.properties['sasl.jaas.config'] | ||
|
|
||
| if self.static_jaas_conf: | ||
| node.account.create_file(SecurityConfig.JAAS_CONF_PATH, jaas_conf) | ||
| print(jaas_conf) | ||
|
Contributor
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. Will revert this unintentional change |
||
| node.account.create_file(SecurityConfig.ADMIN_CLIENT_AS_BROKER_JAAS_CONF_PATH, | ||
| self.render_jaas_config( | ||
| "admin_client_as_broker_jaas.conf", | ||
|
|
@@ -343,6 +347,17 @@ def interbroker_sasl_mechanism(self): | |
| def enabled_sasl_mechanisms(self): | ||
| return set([self.client_sasl_mechanism, self.interbroker_sasl_mechanism]) | ||
|
|
||
| @property | ||
| def usable_sasl_mechanisms(self): | ||
| """ | ||
| Differs from enabled_sasl_mechanisms in that it also includes SASL mechanisms that | ||
| are used for Raft communication | ||
| :return: enabled_sasl_mechanisms plus any mechanisms that are used for Raft communication | ||
| """ | ||
| retval = set([self.client_sasl_mechanism, self.interbroker_sasl_mechanism] + self.raft_sasl_mechanisms) | ||
| print(retval) | ||
|
Contributor
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. will revert |
||
| return retval | ||
|
|
||
| @property | ||
| def has_sasl_kerberos(self): | ||
| return self.has_sasl and (SecurityConfig.SASL_MECHANISM_GSSAPI in self.enabled_sasl_mechanisms) | ||
|
|
||
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.
Should probably say what KIP-631 says, which is "SASL mechanism used for communication with controllers.
Default is GSSAPI." It is used by Raft controllers to talk to other controllers, after all (assuming we are using SASL for inter-controller communication). Will fix.