You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "kfaraz (via GitHub)" <gi...@apache.org> on 2023/05/08 11:24:33 UTC

[GitHub] [druid] kfaraz opened a new pull request, #14223: Do not allow retention rules to be null

kfaraz opened a new pull request, #14223:
URL: https://github.com/apache/druid/pull/14223

   ## Changes
   
   - Give a proper error message when retention rules are passed as null/empty to the `POST coordinator/v1/rules` API
   - Empty rules are allowed at the datasource level but not at the cluster level
   - Add validation to ensure that `druid.manager.rules.defaultRule` is always set correctly
   - Minor style refactors
   
   #### Release note
   - Rules defined at the datasource level cannot be null
   - Rules defined at the cluster level cannot be null or empty
   
   <hr>
   
   This PR has:
   
   - [ ] been self-reviewed.
      - [ ] using the [concurrency checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md) (Remove this item if the PR doesn't have any relation to concurrency.)
   - [ ] added documentation for new or modified features or behaviors.
   - [x] a release note entry in the PR description.
   - [ ] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
   - [ ] added or updated version, license, or notice information in [licenses.yaml](https://github.com/apache/druid/blob/master/dev/license.md)
   - [x] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
   - [x] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for [code coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md) is met.
   - [ ] added integration tests.
   - [ ] been tested in a test Druid cluster.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] AmatyaAvadhanula commented on a diff in pull request #14223: Do not allow retention rules to be null

Posted by "AmatyaAvadhanula (via GitHub)" <gi...@apache.org>.
AmatyaAvadhanula commented on code in PR #14223:
URL: https://github.com/apache/druid/pull/14223#discussion_r1190636310


##########
server/src/main/java/org/apache/druid/metadata/SQLMetadataRuleManager.java:
##########
@@ -362,6 +325,12 @@ public List<Rule> getRulesWithDefault(final String dataSource)
   @Override
   public boolean overrideRule(final String dataSource, final List<Rule> newRules, final AuditInfo auditInfo)
   {
+    if (newRules == null) {
+      throw new IAE("Rules cannot be null.");
+    } else if (newRules.isEmpty() && config.getDefaultRule().equals(dataSource)) {

Review Comment:
   I see, so the defaultRule in the config corresponds to the datasource's name in the default load rules.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] kfaraz commented on a diff in pull request #14223: Do not allow retention rules to be null

Posted by "kfaraz (via GitHub)" <gi...@apache.org>.
kfaraz commented on code in PR #14223:
URL: https://github.com/apache/druid/pull/14223#discussion_r1190600438


##########
server/src/main/java/org/apache/druid/metadata/SQLMetadataRuleManager.java:
##########
@@ -362,6 +325,12 @@ public List<Rule> getRulesWithDefault(final String dataSource)
   @Override
   public boolean overrideRule(final String dataSource, final List<Rule> newRules, final AuditInfo auditInfo)
   {
+    if (newRules == null) {
+      throw new IAE("Rules cannot be null.");
+    } else if (newRules.isEmpty() && config.getDefaultRule().equals(dataSource)) {

Review Comment:
   Oh wait, I think the IAE thrown in the next line explains it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] AmatyaAvadhanula commented on a diff in pull request #14223: Do not allow retention rules to be null

Posted by "AmatyaAvadhanula (via GitHub)" <gi...@apache.org>.
AmatyaAvadhanula commented on code in PR #14223:
URL: https://github.com/apache/druid/pull/14223#discussion_r1190635082


##########
server/src/test/java/org/apache/druid/metadata/SQLMetadataRuleManagerTest.java:
##########
@@ -250,23 +257,17 @@ public void testRemoveRulesOlderThanWithNonExistenceDatasourceAndNewerThanTimest
   {
     List<Rule> rules = ImmutableList.of(
         new IntervalLoadRule(
-            Intervals.of("2015-01-01/2015-02-01"), ImmutableMap.of(
-            DruidServer.DEFAULT_TIER,
-            DruidServer.DEFAULT_NUM_REPLICANTS
+            Intervals.of("2015-01-01/2015-02-01"),
+            ImmutableMap.of(DruidServer.DEFAULT_TIER, DruidServer.DEFAULT_NUM_REPLICANTS)
         )
-        )
-    );
-    AuditInfo auditInfo = new AuditInfo("test_author", "test_comment", "127.0.0.1");
-    ruleManager.overrideRule(
-        "test_dataSource",
-        rules,
-        auditInfo
     );
+    ruleManager.overrideRule(DATASOURCE, rules, createAuditInfo("udpate rules"));

Review Comment:
   nit: udpate -> update



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] kfaraz merged pull request #14223: Do not allow retention rules to be null

Posted by "kfaraz (via GitHub)" <gi...@apache.org>.
kfaraz merged PR #14223:
URL: https://github.com/apache/druid/pull/14223


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] AmatyaAvadhanula commented on a diff in pull request #14223: Do not allow retention rules to be null

Posted by "AmatyaAvadhanula (via GitHub)" <gi...@apache.org>.
AmatyaAvadhanula commented on code in PR #14223:
URL: https://github.com/apache/druid/pull/14223#discussion_r1190598397


##########
server/src/main/java/org/apache/druid/metadata/SQLMetadataRuleManager.java:
##########
@@ -362,6 +325,12 @@ public List<Rule> getRulesWithDefault(final String dataSource)
   @Override
   public boolean overrideRule(final String dataSource, final List<Rule> newRules, final AuditInfo auditInfo)
   {
+    if (newRules == null) {
+      throw new IAE("Rules cannot be null.");
+    } else if (newRules.isEmpty() && config.getDefaultRule().equals(dataSource)) {

Review Comment:
   Could you please explain this condition: `config.getDefaultRule().equals(dataSource)`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] kfaraz commented on a diff in pull request #14223: Do not allow retention rules to be null

Posted by "kfaraz (via GitHub)" <gi...@apache.org>.
kfaraz commented on code in PR #14223:
URL: https://github.com/apache/druid/pull/14223#discussion_r1190599800


##########
server/src/main/java/org/apache/druid/metadata/SQLMetadataRuleManager.java:
##########
@@ -362,6 +325,12 @@ public List<Rule> getRulesWithDefault(final String dataSource)
   @Override
   public boolean overrideRule(final String dataSource, final List<Rule> newRules, final AuditInfo auditInfo)
   {
+    if (newRules == null) {
+      throw new IAE("Rules cannot be null.");
+    } else if (newRules.isEmpty() && config.getDefaultRule().equals(dataSource)) {

Review Comment:
   The `defaultRule` corresponds to the cluster level default. I will add a comment here explaining it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] kfaraz commented on a diff in pull request #14223: Do not allow retention rules to be null

Posted by "kfaraz (via GitHub)" <gi...@apache.org>.
kfaraz commented on code in PR #14223:
URL: https://github.com/apache/druid/pull/14223#discussion_r1190636811


##########
server/src/main/java/org/apache/druid/metadata/SQLMetadataRuleManager.java:
##########
@@ -362,6 +325,12 @@ public List<Rule> getRulesWithDefault(final String dataSource)
   @Override
   public boolean overrideRule(final String dataSource, final List<Rule> newRules, final AuditInfo auditInfo)
   {
+    if (newRules == null) {
+      throw new IAE("Rules cannot be null.");
+    } else if (newRules.isEmpty() && config.getDefaultRule().equals(dataSource)) {

Review Comment:
   Added a javadoc for `getDefaultRule`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] AmatyaAvadhanula commented on a diff in pull request #14223: Do not allow retention rules to be null

Posted by "AmatyaAvadhanula (via GitHub)" <gi...@apache.org>.
AmatyaAvadhanula commented on code in PR #14223:
URL: https://github.com/apache/druid/pull/14223#discussion_r1190634987


##########
server/src/test/java/org/apache/druid/metadata/SQLMetadataRuleManagerTest.java:
##########
@@ -276,36 +277,29 @@ public void testRemoveRulesOlderThanWithNonExistenceDatasourceAndNewerThanTimest
     ruleManager.poll();
     allRules = ruleManager.getAllRules();
     Assert.assertEquals(1, allRules.size());
-    Assert.assertEquals(1, allRules.get("test_dataSource").size());
+    Assert.assertEquals(1, allRules.get(DATASOURCE).size());
   }
 
   @Test
   public void testRemoveRulesOlderThanWithActiveDatasourceShouldNotDelete() throws Exception
   {
     List<Rule> rules = ImmutableList.of(
         new IntervalLoadRule(
-            Intervals.of("2015-01-01/2015-02-01"), ImmutableMap.of(
-            DruidServer.DEFAULT_TIER,
-            DruidServer.DEFAULT_NUM_REPLICANTS
-        )
+            Intervals.of("2015-01-01/2015-02-01"),
+            ImmutableMap.of(DruidServer.DEFAULT_TIER, DruidServer.DEFAULT_NUM_REPLICANTS)
         )
     );
-    AuditInfo auditInfo = new AuditInfo("test_author", "test_comment", "127.0.0.1");
-    ruleManager.overrideRule(
-        "test_dataSource",
-        rules,
-        auditInfo
-    );
+    ruleManager.overrideRule(DATASOURCE, rules, createAuditInfo("udpate rules"));

Review Comment:
   nit: udpate -> update



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org