Skip to content

[fix][misc] do not require encryption on system topics - #18898

Merged
nicoloboschi merged 3 commits into
apache:masterfrom
nicoloboschi:system-topics-enc
Dec 14, 2022
Merged

[fix][misc] do not require encryption on system topics#18898
nicoloboschi merged 3 commits into
apache:masterfrom
nicoloboschi:system-topics-enc

Conversation

@nicoloboschi

@nicoloboschi nicoloboschi commented Dec 13, 2022

Copy link
Copy Markdown
Contributor

Fixes #18897

Motivation

System topics on user namespace may be subject to have encryption set on the producer side. However they can't be forced to be encrypted since the encryption keys are set on the client side. Also they don't contain sensitive data.

The two main cases that I encountered are:

  1. __change_events: if you enable topic level policies
  2. transaction side topics

Modifications

  • Always allow messages in the system topics to not be encrypted

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

@lhotari lhotari left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@lhotari

lhotari commented Dec 13, 2022

Copy link
Copy Markdown
Member

/pulsarbot rerun-failure-checks

@codecov-commenter

codecov-commenter commented Dec 13, 2022

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.

Project coverage is 47.40%. Comparing base (1be5a69) to head (e336ff6).
Report is 1982 commits behind head on master.

Files with missing lines Patch % Lines
...va/org/apache/pulsar/broker/service/ServerCnx.java 0.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##             master   #18898       +/-   ##
=============================================
+ Coverage     33.99%   47.40%   +13.40%     
- Complexity     6476    10635     +4159     
=============================================
  Files           623      703       +80     
  Lines         59103    68844     +9741     
  Branches       6147     7382     +1235     
=============================================
+ Hits          20095    32634    +12539     
+ Misses        36347    32582     -3765     
- Partials       2661     3628      +967     
Flag Coverage Δ
unittests 47.40% <33.33%> (+13.40%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
.../pulsar/broker/service/persistent/SystemTopic.java 92.30% <100.00%> (+0.64%) ⬆️
...va/org/apache/pulsar/broker/service/ServerCnx.java 50.22% <0.00%> (+3.64%) ⬆️

... and 245 files with indirect coverage changes

@michaeljmarshall michaeljmarshall left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@nicoloboschi - I support this change, but I think it needs a little more work.

This code is relevant:

public void checkEncryption() {
if (topic.isEncryptionRequired() && !isEncrypted) {
log.info("[{}] [{}] Unencrypted producer is not allowed to produce on topic [{}] anymore",
producerId, producerName, topic.getName());
disconnect();
}
}

It is used here and in the non-partitioned topic:

producer.checkPermissionsAsync().thenRun(producer::checkEncryption)));

If I am reading the code correctly, without updating the Producer#checkEncryption method, an update to a namespace policy will result in an unnecessary disconnection for producers to system topics when encryption becomes required for a namespace.

Comment thread pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Producer.java Outdated
@nicoloboschi

Copy link
Copy Markdown
Contributor Author

@nicoloboschi - I support this change, but I think it needs a little more work.

This code is relevant:

public void checkEncryption() {
if (topic.isEncryptionRequired() && !isEncrypted) {
log.info("[{}] [{}] Unencrypted producer is not allowed to produce on topic [{}] anymore",
producerId, producerName, topic.getName());
disconnect();
}
}

It is used here and in the non-partitioned topic:

producer.checkPermissionsAsync().thenRun(producer::checkEncryption)));

If I am reading the code correctly, without updating the Producer#checkEncryption method, an update to a namespace policy will result in an unnecessary disconnection for producers to system topics when encryption becomes required for a namespace.

I've implemented isEncryptionRequired to always return false so the disconnection is never triggered. or maybe I didn't get your comments 🤔

@michaeljmarshall michaeljmarshall left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM.

@nicoloboschi nicoloboschi self-assigned this Dec 14, 2022
@nicoloboschi nicoloboschi added this to the 2.12.0 milestone Dec 14, 2022
@nicoloboschi

nicoloboschi commented Dec 14, 2022

Copy link
Copy Markdown
Contributor Author

Since 2.11.0 system topics are enabled by default so I think we must include this fix in 2.11.0.
For example, transactions in namespaces with encryption required, wouldn't work at all.

@nicoloboschi nicoloboschi modified the milestones: 2.12.0, 2.11.0 Dec 14, 2022
@nicoloboschi nicoloboschi added the release/blocker Indicate the PR or issue that should block the release until it gets resolved label Dec 14, 2022
@nicoloboschi
nicoloboschi merged commit 4129583 into apache:master Dec 14, 2022
nicoloboschi added a commit to datastax/pulsar that referenced this pull request Dec 14, 2022
nicoloboschi added a commit that referenced this pull request Dec 14, 2022
@nicoloboschi
nicoloboschi deleted the system-topics-enc branch December 14, 2022 13:45
lifepuzzlefun pushed a commit to lifepuzzlefun/pulsar that referenced this pull request Jan 10, 2023
liangyepianzhou pushed a commit that referenced this pull request Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-picked/branch-2.10 cherry-picked/branch-2.11 doc-not-needed Your PR changes do not impact docs ready-to-test release/blocker Indicate the PR or issue that should block the release until it gets resolved release/2.10.4

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Not able to produce messages if transactions enabled and encryption required

6 participants