You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@gobblin.apache.org by GitBox <gi...@apache.org> on 2020/09/26 23:44:52 UTC

[GitHub] [incubator-gobblin] shirshanka opened a new pull request #3113: [WIP] Improving logging of config file load failures

shirshanka opened a new pull request #3113:
URL: https://github.com/apache/incubator-gobblin/pull/3113


   Dear Gobblin maintainers,
   
   Please accept this PR. I understand that it will not be reviewed until I have checked off all the steps below!
   
   
   ### JIRA
   - [ ] My PR addresses the following [Gobblin JIRA](https://issues.apache.org/jira/browse/GOBBLIN/) issues and references them in the PR title. For example, "[GOBBLIN-XXX] My Gobblin PR"
       - https://issues.apache.org/jira/browse/GOBBLIN-XXX
   
   
   ### Description
   - [ ] Here are some details about my PR, including screenshots (if applicable):
   
   
   ### Tests
   - [ ] My PR adds the following unit tests __OR__ does not need testing for this extremely good reason:
   
   
   ### Commits
   - [ ] My commits all reference JIRA issues in their subject lines, and I have squashed multiple commits if they address the same issue. In addition, my commits follow the guidelines from "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)":
       1. Subject is separated from body by a blank line
       2. Subject is limited to 50 characters
       3. Subject does not end with a period
       4. Subject uses the imperative mood ("add", not "adding")
       5. Body wraps at 72 characters
       6. Body explains "what" and "why", not "how"
   
   


----------------------------------------------------------------
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.

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



[GitHub] [incubator-gobblin] asfgit closed pull request #3113: [GOBBLIN-1273] Improving handling of config file load failures

Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #3113:
URL: https://github.com/apache/incubator-gobblin/pull/3113


   


----------------------------------------------------------------
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.

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



[GitHub] [incubator-gobblin] asfgit closed pull request #3113: [GOBBLIN-1273] Improving handling of config file load failures

Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #3113:
URL: https://github.com/apache/incubator-gobblin/pull/3113


   


----------------------------------------------------------------
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.

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



[GitHub] [incubator-gobblin] sv2000 commented on a change in pull request #3113: [GOBBLIN-1273] Improving handling of config file load failures

Posted by GitBox <gi...@apache.org>.
sv2000 commented on a change in pull request #3113:
URL: https://github.com/apache/incubator-gobblin/pull/3113#discussion_r500463929



##########
File path: gobblin-utility/src/main/java/org/apache/gobblin/util/PullFileLoader.java
##########
@@ -284,43 +287,62 @@ private Config findAndLoadGlobalConfigInDirectory(Path path, Config fallback) th
    * @return The {@link Config} in path with fallback as fallback.
    * @throws IOException
    */
-  private Config loadJavaPropsWithFallback(Path propertiesPath, Config fallback) throws IOException {
+  private Config loadJavaPropsWithFallback(Path propertiesPath, Config fallback)
+      throws IOException {
 
     PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration();
-    try (InputStreamReader inputStreamReader = new InputStreamReader(this.fs.open(propertiesPath),
-        Charsets.UTF_8)) {
-      propertiesConfiguration.setDelimiterParsingDisabled(ConfigUtils.getBoolean(fallback,
-    		  PROPERTY_DELIMITER_PARSING_ENABLED_KEY, DEFAULT_PROPERTY_DELIMITER_PARSING_ENABLED_KEY));
+    try (InputStreamReader inputStreamReader = new InputStreamReader(this.fs.open(propertiesPath), Charsets.UTF_8)) {
+      propertiesConfiguration.setDelimiterParsingDisabled(ConfigUtils
+          .getBoolean(fallback, PROPERTY_DELIMITER_PARSING_ENABLED_KEY, DEFAULT_PROPERTY_DELIMITER_PARSING_ENABLED_KEY));
       propertiesConfiguration.load(inputStreamReader);
 
       Config configFromProps =
           ConfigUtils.propertiesToConfig(ConfigurationConverter.getProperties(propertiesConfiguration));
 
       return ConfigFactory.parseMap(ImmutableMap.of(ConfigurationKeys.JOB_CONFIG_FILE_PATH_KEY,
-          PathUtils.getPathWithoutSchemeAndAuthority(propertiesPath).toString()))
-          .withFallback(configFromProps)
+          PathUtils.getPathWithoutSchemeAndAuthority(propertiesPath).toString())).withFallback(configFromProps)
           .withFallback(fallback);
     } catch (ConfigurationException ce) {
+      log.error("Failed to load Java properties from file at {} due to {}", propertiesPath, ce.getLocalizedMessage());
       throw new IOException(ce);
     }
   }
 
-  private Config loadHoconConfigAtPath(Path path) throws IOException {
-    try (InputStream is = fs.open(path);
-        Reader reader = new InputStreamReader(is, Charsets.UTF_8)) {
-        return ConfigFactory.parseMap(ImmutableMap.of(ConfigurationKeys.JOB_CONFIG_FILE_PATH_KEY,
-            PathUtils.getPathWithoutSchemeAndAuthority(path).toString()))
-            .withFallback(ConfigFactory.parseReader(reader, ConfigParseOptions.defaults().setSyntax(ConfigSyntax.CONF)));
+  private Config loadHoconConfigAtPath(Path path)
+      throws IOException {
+    try (InputStream is = fs.open(path); Reader reader = new InputStreamReader(is, Charsets.UTF_8)) {
+      return ConfigFactory.parseMap(ImmutableMap
+          .of(ConfigurationKeys.JOB_CONFIG_FILE_PATH_KEY, PathUtils.getPathWithoutSchemeAndAuthority(path).toString()))
+          .withFallback(ConfigFactory.parseReader(reader, ConfigParseOptions.defaults().setSyntax(ConfigSyntax.CONF)));
+    } catch (ConfigException configException) {
+      throw wrapConfigException(path, configException);
     }
   }
 
-  private Config loadHoconConfigWithFallback(Path path, Config fallback) throws IOException {
-    try (InputStream is = fs.open(path);
-         Reader reader = new InputStreamReader(is, Charsets.UTF_8)) {
-      return ConfigFactory.parseMap(ImmutableMap.of(ConfigurationKeys.JOB_CONFIG_FILE_PATH_KEY,
-          PathUtils.getPathWithoutSchemeAndAuthority(path).toString()))
-          .withFallback(ConfigFactory.parseReader(reader, ConfigParseOptions.defaults().setSyntax(ConfigSyntax.CONF)))
-          .withFallback(fallback);
+  /**
+   * Wrap a {@link ConfigException} (which extends {@link RuntimeException} with an IOException,
+   * with a helpful message if possible
+   * @param path
+   * @param configException
+   * @return an {@link IOException} wrapping the passed in ConfigException.
+   */
+  private IOException wrapConfigException(Path path, ConfigException configException) {
+    if (configException.origin() != null) {
+      return new IOException("Failed to parse config file " + path.toString()
+          + " at lineNo:" + configException.origin().lineNumber(),configException);

Review comment:
       Nit: Add a whitespace after the ",".

##########
File path: gobblin-utility/src/main/java/org/apache/gobblin/util/PullFileLoader.java
##########
@@ -175,14 +176,14 @@ public Config apply(@Nullable Path jobFile) {
         }
 
         try {
-          return PullFileLoader.this.loadPullFile(jobFile,
-              sysProps, loadGlobalProperties);
-        } catch (IOException e) {
-          log.error("Cannot load job from {} due to {}", jobFile, ExceptionUtils.getFullStackTrace(e));
+          return PullFileLoader.this.loadPullFile(jobFile, sysProps, loadGlobalProperties);
+        } catch (IOException ie) {
+          log.error("",ie);

Review comment:
       Add white space after ",". 

##########
File path: gobblin-utility/src/main/java/org/apache/gobblin/util/PullFileLoader.java
##########
@@ -175,14 +176,14 @@ public Config apply(@Nullable Path jobFile) {
         }
 
         try {
-          return PullFileLoader.this.loadPullFile(jobFile,
-              sysProps, loadGlobalProperties);
-        } catch (IOException e) {
-          log.error("Cannot load job from {} due to {}", jobFile, ExceptionUtils.getFullStackTrace(e));
+          return PullFileLoader.this.loadPullFile(jobFile, sysProps, loadGlobalProperties);
+        } catch (IOException ie) {
+          log.error("",ie);
           return null;
         }
       }
-    });
+    }).stream().filter(x -> x!= null).collect(Collectors.toList());

Review comment:
       Add whitespaces around "!=".

##########
File path: gobblin-utility/src/main/java/org/apache/gobblin/util/PullFileLoader.java
##########
@@ -175,14 +176,14 @@ public Config apply(@Nullable Path jobFile) {
         }
 
         try {
-          return PullFileLoader.this.loadPullFile(jobFile,
-              sysProps, loadGlobalProperties);
-        } catch (IOException e) {
-          log.error("Cannot load job from {} due to {}", jobFile, ExceptionUtils.getFullStackTrace(e));
+          return PullFileLoader.this.loadPullFile(jobFile, sysProps, loadGlobalProperties);
+        } catch (IOException ie) {
+          log.error("",ie);
           return null;
         }
       }
-    });
+    }).stream().filter(x -> x!= null).collect(Collectors.toList());
+    // only return valid parsed configs

Review comment:
       Can this behavior be documented in the javadoc of the method?




----------------------------------------------------------------
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.

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



[GitHub] [incubator-gobblin] codecov-io commented on pull request #3113: [GOBBLIN-1273] Improving handling of config file load failures

Posted by GitBox <gi...@apache.org>.
codecov-io commented on pull request #3113:
URL: https://github.com/apache/incubator-gobblin/pull/3113#issuecomment-705247118


   # [Codecov](https://codecov.io/gh/apache/incubator-gobblin/pull/3113?src=pr&el=h1) Report
   > :exclamation: No coverage uploaded for pull request base (`master@06b9159`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
   > The diff coverage is `77.77%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-gobblin/pull/3113/graphs/tree.svg?width=650&height=150&src=pr&token=4MgURJ0bGc)](https://codecov.io/gh/apache/incubator-gobblin/pull/3113?src=pr&el=tree)
   
   ```diff
   @@            Coverage Diff            @@
   ##             master    #3113   +/-   ##
   =========================================
     Coverage          ?   46.01%           
     Complexity        ?     9579           
   =========================================
     Files             ?     1986           
     Lines             ?    75802           
     Branches          ?     8445           
   =========================================
     Hits              ?    34882           
     Misses            ?    37638           
     Partials          ?     3282           
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-gobblin/pull/3113?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
   |---|---|---|---|
   | [...n/java/org/apache/gobblin/util/PullFileLoader.java](https://codecov.io/gh/apache/incubator-gobblin/pull/3113/diff?src=pr&el=tree#diff-Z29iYmxpbi11dGlsaXR5L3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9nb2JibGluL3V0aWwvUHVsbEZpbGVMb2FkZXIuamF2YQ==) | `73.88% <77.77%> (ø)` | `26.00 <3.00> (?)` | |
   | [...pache/gobblin/util/executors/ForceQueuePolicy.java](https://codecov.io/gh/apache/incubator-gobblin/pull/3113/diff?src=pr&el=tree#diff-Z29iYmxpbi11dGlsaXR5L3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9nb2JibGluL3V0aWwvZXhlY3V0b3JzL0ZvcmNlUXVldWVQb2xpY3kuamF2YQ==) | `16.66% <0.00%> (ø)` | `1.00% <0.00%> (?%)` | |
   | [...bblin/writer/http/SalesForceRestWriterBuilder.java](https://codecov.io/gh/apache/incubator-gobblin/pull/3113/diff?src=pr&el=tree#diff-Z29iYmxpbi1jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9nb2JibGluL3dyaXRlci9odHRwL1NhbGVzRm9yY2VSZXN0V3JpdGVyQnVpbGRlci5qYXZh) | `72.50% <0.00%> (ø)` | `12.00% <0.00%> (?%)` | |
   | [...ion/mapreduce/orc/OrcKeyCompactorOutputFormat.java](https://codecov.io/gh/apache/incubator-gobblin/pull/3113/diff?src=pr&el=tree#diff-Z29iYmxpbi1jb21wYWN0aW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9nb2JibGluL2NvbXBhY3Rpb24vbWFwcmVkdWNlL29yYy9PcmNLZXlDb21wYWN0b3JPdXRwdXRGb3JtYXQuamF2YQ==) | `100.00% <0.00%> (ø)` | `4.00% <0.00%> (?%)` | |
   | [...ice/modules/orchestration/AzkabanClientStatus.java](https://codecov.io/gh/apache/incubator-gobblin/pull/3113/diff?src=pr&el=tree#diff-Z29iYmxpbi1tb2R1bGVzL2dvYmJsaW4tYXprYWJhbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZ29iYmxpbi9zZXJ2aWNlL21vZHVsZXMvb3JjaGVzdHJhdGlvbi9BemthYmFuQ2xpZW50U3RhdHVzLmphdmE=) | `0.00% <0.00%> (ø)` | `0.00% <0.00%> (?%)` | |
   | [...che/gobblin/util/limiter/NonRefillableLimiter.java](https://codecov.io/gh/apache/incubator-gobblin/pull/3113/diff?src=pr&el=tree#diff-Z29iYmxpbi11dGlsaXR5L3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9nb2JibGluL3V0aWwvbGltaXRlci9Ob25SZWZpbGxhYmxlTGltaXRlci5qYXZh) | `75.00% <0.00%> (ø)` | `2.00% <0.00%> (?%)` | |
   | [...cies/avro/AvroRecordTimestampLowerBoundPolicy.java](https://codecov.io/gh/apache/incubator-gobblin/pull/3113/diff?src=pr&el=tree#diff-Z29iYmxpbi1jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9nb2JibGluL3BvbGljaWVzL2F2cm8vQXZyb1JlY29yZFRpbWVzdGFtcExvd2VyQm91bmRQb2xpY3kuamF2YQ==) | `0.00% <0.00%> (ø)` | `0.00% <0.00%> (?%)` | |
   | [...in/java/org/apache/gobblin/metrics/InnerMeter.java](https://codecov.io/gh/apache/incubator-gobblin/pull/3113/diff?src=pr&el=tree#diff-Z29iYmxpbi1tZXRyaWNzLWxpYnMvZ29iYmxpbi1tZXRyaWNzLWJhc2Uvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2dvYmJsaW4vbWV0cmljcy9Jbm5lck1ldGVyLmphdmE=) | `100.00% <0.00%> (ø)` | `6.00% <0.00%> (?%)` | |
   | [...obblin/ingestion/google/webmaster/UrlTrieNode.java](https://codecov.io/gh/apache/incubator-gobblin/pull/3113/diff?src=pr&el=tree#diff-Z29iYmxpbi1tb2R1bGVzL2dvb2dsZS1pbmdlc3Rpb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2dvYmJsaW4vaW5nZXN0aW9uL2dvb2dsZS93ZWJtYXN0ZXIvVXJsVHJpZU5vZGUuamF2YQ==) | `90.62% <0.00%> (ø)` | `10.00% <0.00%> (?%)` | |
   | [...gobblin/runtime/DynamicConfigGeneratorFactory.java](https://codecov.io/gh/apache/incubator-gobblin/pull/3113/diff?src=pr&el=tree#diff-Z29iYmxpbi1ydW50aW1lL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9nb2JibGluL3J1bnRpbWUvRHluYW1pY0NvbmZpZ0dlbmVyYXRvckZhY3RvcnkuamF2YQ==) | `57.14% <0.00%> (ø)` | `1.00% <0.00%> (?%)` | |
   | ... and [1977 more](https://codecov.io/gh/apache/incubator-gobblin/pull/3113/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-gobblin/pull/3113?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-gobblin/pull/3113?src=pr&el=footer). Last update [06b9159...6a19405](https://codecov.io/gh/apache/incubator-gobblin/pull/3113?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
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.

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



[GitHub] [incubator-gobblin] shirshanka commented on pull request #3113: [GOBBLIN-1273] Improving handling of config file load failures

Posted by GitBox <gi...@apache.org>.
shirshanka commented on pull request #3113:
URL: https://github.com/apache/incubator-gobblin/pull/3113#issuecomment-705237850


   @sv2000 : addressed your comments, PTAL


----------------------------------------------------------------
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.

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