Skip to content

Do not enable TopicAccessValidator if Kafka has unsupported authorizedOperations#2888

Merged
Sergio Peña (spena) merged 7 commits into
confluentinc:5.3.xfrom
spena:kafka_2.2_authorized
May 29, 2019
Merged

Do not enable TopicAccessValidator if Kafka has unsupported authorizedOperations#2888
Sergio Peña (spena) merged 7 commits into
confluentinc:5.3.xfrom
spena:kafka_2.2_authorized

Conversation

@spena

@spena Sergio Peña (spena) commented May 28, 2019

Copy link
Copy Markdown
Member

Description

This PR avoids enabling the TopicAccessValidator if the Kafka broker version does not support the authorizedOperations API.

The authorizedOperations API is a new method added in Kafka 2.3. If KSQL runs on Kafka 2.2 or lower, this API will return NULL causing a NPE in KSQL and denying any operation executed on a Kafka 2.2 environment.

To avoid the NPE issue, KSQL avoids enabling the topic validator instead. Look at the TopicAccessValidatorFactory which checks if the authorizedOperations from the Cluster is Null.

See apache/kafka#6812

Testing done

Added unit tests.
Run local tests with Kafka 2.2. Warning message is printed:
[2019-05-29 14:14:32,512] WARN The Kafka broker has an authorization service enabled, but the Kafka version does not support authorizedOperations(). KSQL topic authorization checks will not be enabled. (io.confluent.ksql.engine.TopicAccessValidatorFactory:48)

Reviewer checklist

  • Ensure docs are updated if necessary. (eg. if a user visible feature is being added or changed).
  • Ensure relevant issues are linked (description should include text like "Fixes #")

@spena Sergio Peña (spena) added this to the 5.3 milestone May 28, 2019
@spena
Sergio Peña (spena) requested review from a team and Rohan (rodesai) May 28, 2019 21:37
@spena Sergio Peña (spena) self-assigned this May 28, 2019
return new AuthorizationTopicAccessValidator();
}

LOG.info("The Kafka broker has an authorization service enabled, but the Kafka "

@rodesai Rohan (rodesai) May 28, 2019

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we should log this at warning level. The resulting behavior is likely not what the user intended. Might be good to get Michael Drogalis (@MichaelDrogalis) take on what the behavior should be - maybe it would be better to just hard-fail and require the user to either upgrade Kafka or not configure the validator.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The topic access validator is used mostly to provide better permission error messages when the KSQL user won't be able to execute a persistent query on KSQL. I don't think a warning message is a correct level for that case (I am not against about it, though). However, failing KSQL because is not using the correct version of Kafka might be out of scope of our current release. Do we have a compatibility list of Kafka versions that KSQL should support?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we have a compatibility list of Kafka versions that KSQL should support?
Not that I'm aware of, no.

I agree with Sergio Peña (@spena) that it's probably a bit late to introduce a code-path to hard-fail here -- though switching the log level up to warn does feel like the right play to me. Sergio Peña (@spena) Can you expand a bit about why you think info is right here? Maybe I'm missing some nuance.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I feel it's not a warn because if permission checks are not available, KSQL will still fail further in the code without providing good error messages. However, it is harmless to switch the level to warn now that I am thinking about it. I will do the switch and update this PR.

@vcrfxia Victoria Xia (vcrfxia) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks Sergio Peña (@spena) -- LGTM.

@vcrfxia
Victoria Xia (vcrfxia) requested a review from a team May 29, 2019 21:23

@agavra Almog Gavra (agavra) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM - one question inline

);

return authorizedOperations.authorizedOperations().get() != null;
} catch (Exception e) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

do we need to check for ClusterAuthorizationException like we do above?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't think so. By the time this method is called, the TopicAccessValidatorFactory already checked if the user is authorized to access the cluster.

@spena
Sergio Peña (spena) merged commit d1a1bbf into confluentinc:5.3.x May 29, 2019
@spena
Sergio Peña (spena) deleted the kafka_2.2_authorized branch May 29, 2019 23:26
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.

5 participants