You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by "rickchengx (via GitHub)" <gi...@apache.org> on 2023/03/22 03:20:58 UTC
[GitHub] [dolphinscheduler] rickchengx opened a new pull request, #13777: [Feature-13429][Remote Logging] Add support for writing task logs to Google Cloud Storage
rickchengx opened a new pull request, #13777:
URL: https://github.com/apache/dolphinscheduler/pull/13777
<!--Thanks very much for contributing to Apache DolphinScheduler. Please review https://dolphinscheduler.apache.org/en-us/community/development/pull-request.html before opening a pull request.-->
## Purpose of the pull request
* close: #13429
* A sub-task of #13017
<!--(For example: This pull request adds checkstyle plugin).-->
## Brief change log
* Add support for writing task logs to Google Cloud Storage
* Fix the log path bug since the log full path has changed in #13673
## Verify this pull request
manually test and UT
1. run a shell task
<img width="1054" alt="截屏2023-03-22 10 45 35" src="https://user-images.githubusercontent.com/38122586/226793619-05ce2e4c-22c3-4645-8f63-49f2dca2a5b2.png">
2. check log file on GCS
<img width="1235" alt="截屏2023-03-22 10 45 02" src="https://user-images.githubusercontent.com/38122586/226793649-7eb84d5a-9aca-42d8-8ac1-baf6f3a00776.png">
--
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@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] rickchengx commented on a diff in pull request #13777: [Feature-13429][Remote Logging] Add support for writing task logs to Google Cloud Storage
Posted by "rickchengx (via GitHub)" <gi...@apache.org>.
rickchengx commented on code in PR #13777:
URL: https://github.com/apache/dolphinscheduler/pull/13777#discussion_r1151362240
##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/remote/GcsRemoteLogHandler.java:
##########
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.common.log.remote;
+
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.common.utils.PropertyUtils;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+import lombok.extern.slf4j.Slf4j;
+
+import com.google.auth.oauth2.ServiceAccountCredentials;
+import com.google.cloud.storage.Blob;
+import com.google.cloud.storage.BlobId;
+import com.google.cloud.storage.BlobInfo;
+import com.google.cloud.storage.Bucket;
+import com.google.cloud.storage.Storage;
+import com.google.cloud.storage.StorageOptions;
+
+@Slf4j
+public class GcsRemoteLogHandler implements RemoteLogHandler, Closeable {
+
+ private Storage gcsStorage;
+
+ private String bucketName;
+
+ private String credential;
+
+ private static GcsRemoteLogHandler instance;
+
+ private GcsRemoteLogHandler() {
+
+ }
+
+ public static synchronized GcsRemoteLogHandler getInstance() {
+ if (instance == null) {
+ instance = new GcsRemoteLogHandler();
+ instance.init();
+ }
+
+ return instance;
+ }
+
+ public void init() {
+ try {
+ credential = readCredentials();
+ bucketName = readBucketName();
+ gcsStorage = buildGcsStorage(credential);
+
+ checkBucketNameExists(bucketName);
+ } catch (IOException e) {
+ log.error("GCS Remote Log Handler init failed", e);
+ }
+ }
+
+ @Override
+ public void close() throws IOException {
+ try {
+ if (gcsStorage != null) {
+ gcsStorage.close();
+ }
+ } catch (Exception e) {
+ throw new IOException(e);
+ }
+ }
+
+ @Override
+ public void sendRemoteLog(String logPath) {
+ String objectName = RemoteLogUtils.getObjectNameFromLogPath(logPath);
+
+ try {
+ log.info("send remote log {} to GCS {}", logPath, objectName);
+
+ BlobInfo blobInfo = BlobInfo.newBuilder(
+ BlobId.of(bucketName, objectName)).build();
+
+ gcsStorage.create(blobInfo, Files.readAllBytes(Paths.get(logPath)));
+ } catch (Exception e) {
+ log.error("error while sending remote log {} to GCS {}", logPath, objectName, e);
+ }
+ }
+
+ @Override
+ public void getRemoteLog(String logPath) {
+ String objectName = RemoteLogUtils.getObjectNameFromLogPath(logPath);
+
+ try {
+ log.info("get remote log on GCS {} to {}", objectName, logPath);
+
+ Blob blob = gcsStorage.get(BlobId.of(bucketName, objectName));
+ blob.downloadTo(Paths.get(logPath));
+ } catch (Exception e) {
+ log.error("error while getting remote log on GCS {} to {}", objectName, logPath, e);
+ }
+ }
+
+ protected Storage buildGcsStorage(String credential) throws IOException {
+ return StorageOptions.newBuilder()
+ .setCredentials(ServiceAccountCredentials.fromStream(
+ Files.newInputStream(Paths.get(credential))))
+ .build()
+ .getService();
+ }
+
+ protected String readCredentials() {
+ return PropertyUtils.getString(Constants.REMOTE_LOGGING_GCS_CREDENTIAL);
+ }
+
+ protected String readBucketName() {
+ return PropertyUtils.getString(Constants.REMOTE_LOGGING_GCS_BUCKET_NAME);
+ }
+
+ public void checkBucketNameExists(String bucketName) {
+ if (StringUtils.isBlank(bucketName)) {
+ throw new IllegalArgumentException(Constants.REMOTE_LOGGING_GCS_BUCKET_NAME + " is blank");
+ }
+
+ boolean exist = false;
+ for (Bucket bucket : gcsStorage.list().iterateAll()) {
+ if (bucketName.equals(bucket.getName())) {
+ exist = true;
+ break;
+ }
+ }
+
+ if (!exist) {
+ throw new IllegalArgumentException(
+ "bucketName: " + bucketName + " is not exists, you need to create them by yourself");
+ } else {
Review Comment:
Thanks for your comment. The exception thrown here is the same as in the resource center (also in the `checkBucketNameExists()` OSS / GCS / S3).
I am not sure if we need to delete them all.
--
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@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] rickchengx commented on a diff in pull request #13777: [Feature-13429][Remote Logging] Add support for writing task logs to Google Cloud Storage
Posted by "rickchengx (via GitHub)" <gi...@apache.org>.
rickchengx commented on code in PR #13777:
URL: https://github.com/apache/dolphinscheduler/pull/13777#discussion_r1151363050
##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/LogUtils.java:
##########
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.common.utils;
+
+import lombok.extern.slf4j.Slf4j;
+
+import org.slf4j.LoggerFactory;
+
+import ch.qos.logback.classic.LoggerContext;
+
+@Slf4j
+public class LogUtils {
Review Comment:
Another `LogUtils` is in `dolphinscheduler-task-api` module. I'll try to put them together in `common` module.
--
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@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] Radeity commented on a diff in pull request #13777: [Feature-13429][Remote Logging] Add support for writing task logs to Google Cloud Storage
Posted by "Radeity (via GitHub)" <gi...@apache.org>.
Radeity commented on code in PR #13777:
URL: https://github.com/apache/dolphinscheduler/pull/13777#discussion_r1144215519
##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/remote/GcsRemoteLogHandler.java:
##########
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.common.log.remote;
+
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.common.utils.PropertyUtils;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+import lombok.extern.slf4j.Slf4j;
+
+import com.google.auth.oauth2.ServiceAccountCredentials;
+import com.google.cloud.storage.Blob;
+import com.google.cloud.storage.BlobId;
+import com.google.cloud.storage.BlobInfo;
+import com.google.cloud.storage.Bucket;
+import com.google.cloud.storage.Storage;
+import com.google.cloud.storage.StorageOptions;
+
+@Slf4j
+public class GcsRemoteLogHandler implements RemoteLogHandler, Closeable {
+
+ private Storage gcsStorage;
+
+ private String bucketName;
+
+ private String credential;
+
+ private static GcsRemoteLogHandler instance;
+
+ private GcsRemoteLogHandler() {
+
+ }
+
+ public static synchronized GcsRemoteLogHandler getInstance() {
+ if (instance == null) {
+ instance = new GcsRemoteLogHandler();
+ instance.init();
+ }
+
+ return instance;
+ }
+
+ public void init() {
+ try {
+ credential = readCredentials();
+ bucketName = readBucketName();
+ gcsStorage = buildGcsStorage(credential);
+
+ checkBucketNameExists(bucketName);
+ } catch (IOException e) {
+ log.error("GCS Remote Log Handler init failed", e);
+ }
+ }
+
+ @Override
+ public void close() throws IOException {
+ try {
+ if (gcsStorage != null) {
+ gcsStorage.close();
+ }
+ } catch (Exception e) {
+ throw new IOException(e);
+ }
+ }
+
+ @Override
+ public void sendRemoteLog(String logPath) {
+ String objectName = RemoteLogUtils.getObjectNameFromLogPath(logPath);
+
+ try {
+ log.info("send remote log {} to GCS {}", logPath, objectName);
+
+ BlobInfo blobInfo = BlobInfo.newBuilder(
+ BlobId.of(bucketName, objectName)).build();
+
+ gcsStorage.create(blobInfo, Files.readAllBytes(Paths.get(logPath)));
+ } catch (Exception e) {
+ log.error("error while sending remote log {} to GCS {}", logPath, objectName, e);
+ }
+ }
+
+ @Override
+ public void getRemoteLog(String logPath) {
+ String objectName = RemoteLogUtils.getObjectNameFromLogPath(logPath);
+
+ try {
+ log.info("get remote log on GCS {} to {}", objectName, logPath);
+
+ File dstFile = new File(logPath);
Review Comment:
May i ask is there any possibility logPath is a directory?
##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/remote/GcsRemoteLogHandler.java:
##########
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.common.log.remote;
+
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.common.utils.PropertyUtils;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+import lombok.extern.slf4j.Slf4j;
+
+import com.google.auth.oauth2.ServiceAccountCredentials;
+import com.google.cloud.storage.Blob;
+import com.google.cloud.storage.BlobId;
+import com.google.cloud.storage.BlobInfo;
+import com.google.cloud.storage.Bucket;
+import com.google.cloud.storage.Storage;
+import com.google.cloud.storage.StorageOptions;
+
+@Slf4j
+public class GcsRemoteLogHandler implements RemoteLogHandler, Closeable {
+
+ private Storage gcsStorage;
+
+ private String bucketName;
+
+ private String credential;
+
+ private static GcsRemoteLogHandler instance;
+
+ private GcsRemoteLogHandler() {
+
+ }
+
+ public static synchronized GcsRemoteLogHandler getInstance() {
+ if (instance == null) {
+ instance = new GcsRemoteLogHandler();
+ instance.init();
+ }
+
+ return instance;
+ }
+
+ public void init() {
+ try {
+ credential = readCredentials();
+ bucketName = readBucketName();
+ gcsStorage = buildGcsStorage(credential);
+
+ checkBucketNameExists(bucketName);
+ } catch (IOException e) {
+ log.error("GCS Remote Log Handler init failed", e);
+ }
+ }
+
+ @Override
+ public void close() throws IOException {
+ try {
+ if (gcsStorage != null) {
+ gcsStorage.close();
+ }
+ } catch (Exception e) {
+ throw new IOException(e);
+ }
+ }
+
+ @Override
+ public void sendRemoteLog(String logPath) {
+ String objectName = RemoteLogUtils.getObjectNameFromLogPath(logPath);
+
+ try {
+ log.info("send remote log {} to GCS {}", logPath, objectName);
+
+ BlobInfo blobInfo = BlobInfo.newBuilder(
+ BlobId.of(bucketName, objectName)).build();
+
+ gcsStorage.create(blobInfo, Files.readAllBytes(Paths.get(logPath)));
+ } catch (Exception e) {
+ log.error("error while sending remote log {} to GCS {}", logPath, objectName, e);
+ }
+ }
+
+ @Override
+ public void getRemoteLog(String logPath) {
+ String objectName = RemoteLogUtils.getObjectNameFromLogPath(logPath);
+
+ try {
+ log.info("get remote log on GCS {} to {}", objectName, logPath);
+
+ File dstFile = new File(logPath);
Review Comment:
May i ask is there any possibility `logPath` is a directory?
--
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@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] rickchengx commented on pull request #13777: [Feature-13429][Remote Logging] Add support for writing task logs to Google Cloud Storage
Posted by "rickchengx (via GitHub)" <gi...@apache.org>.
rickchengx commented on PR #13777:
URL: https://github.com/apache/dolphinscheduler/pull/13777#issuecomment-1498392755
Hi, @caishunfeng , could you please help review this again?
--
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@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] caishunfeng merged pull request #13777: [Feature-13429][Remote Logging] Add support for writing task logs to Google Cloud Storage
Posted by "caishunfeng (via GitHub)" <gi...@apache.org>.
caishunfeng merged PR #13777:
URL: https://github.com/apache/dolphinscheduler/pull/13777
--
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@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] rickchengx commented on a diff in pull request #13777: [Feature-13429][Remote Logging] Add support for writing task logs to Google Cloud Storage
Posted by "rickchengx (via GitHub)" <gi...@apache.org>.
rickchengx commented on code in PR #13777:
URL: https://github.com/apache/dolphinscheduler/pull/13777#discussion_r1144243280
##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/remote/GcsRemoteLogHandler.java:
##########
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.common.log.remote;
+
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.common.utils.PropertyUtils;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+import lombok.extern.slf4j.Slf4j;
+
+import com.google.auth.oauth2.ServiceAccountCredentials;
+import com.google.cloud.storage.Blob;
+import com.google.cloud.storage.BlobId;
+import com.google.cloud.storage.BlobInfo;
+import com.google.cloud.storage.Bucket;
+import com.google.cloud.storage.Storage;
+import com.google.cloud.storage.StorageOptions;
+
+@Slf4j
+public class GcsRemoteLogHandler implements RemoteLogHandler, Closeable {
+
+ private Storage gcsStorage;
+
+ private String bucketName;
+
+ private String credential;
+
+ private static GcsRemoteLogHandler instance;
+
+ private GcsRemoteLogHandler() {
+
+ }
+
+ public static synchronized GcsRemoteLogHandler getInstance() {
+ if (instance == null) {
+ instance = new GcsRemoteLogHandler();
+ instance.init();
+ }
+
+ return instance;
+ }
+
+ public void init() {
+ try {
+ credential = readCredentials();
+ bucketName = readBucketName();
+ gcsStorage = buildGcsStorage(credential);
+
+ checkBucketNameExists(bucketName);
+ } catch (IOException e) {
+ log.error("GCS Remote Log Handler init failed", e);
+ }
+ }
+
+ @Override
+ public void close() throws IOException {
+ try {
+ if (gcsStorage != null) {
+ gcsStorage.close();
+ }
+ } catch (Exception e) {
+ throw new IOException(e);
+ }
+ }
+
+ @Override
+ public void sendRemoteLog(String logPath) {
+ String objectName = RemoteLogUtils.getObjectNameFromLogPath(logPath);
+
+ try {
+ log.info("send remote log {} to GCS {}", logPath, objectName);
+
+ BlobInfo blobInfo = BlobInfo.newBuilder(
+ BlobId.of(bucketName, objectName)).build();
+
+ gcsStorage.create(blobInfo, Files.readAllBytes(Paths.get(logPath)));
+ } catch (Exception e) {
+ log.error("error while sending remote log {} to GCS {}", logPath, objectName, e);
+ }
+ }
+
+ @Override
+ public void getRemoteLog(String logPath) {
+ String objectName = RemoteLogUtils.getObjectNameFromLogPath(logPath);
+
+ try {
+ log.info("get remote log on GCS {} to {}", objectName, logPath);
+
+ File dstFile = new File(logPath);
+ if (dstFile.isDirectory()) {
+ Files.delete(dstFile.toPath());
+ } else {
+ Files.createDirectories(dstFile.getParentFile().toPath());
Review Comment:
Yes, we could delete this part, thanks for your comment.
--
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@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] codecov-commenter commented on pull request #13777: [Feature-13429][Remote Logging] Add support for writing task logs to Google Cloud Storage
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #13777:
URL: https://github.com/apache/dolphinscheduler/pull/13777#issuecomment-1478880190
## [Codecov](https://codecov.io/gh/apache/dolphinscheduler/pull/13777?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#13777](https://codecov.io/gh/apache/dolphinscheduler/pull/13777?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (661d3db) into [dev](https://codecov.io/gh/apache/dolphinscheduler/commit/69e744961b489c9553e656b8d1f6247b46884e05?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (69e7449) will **decrease** coverage by `0.17%`.
> The diff coverage is `7.24%`.
> :exclamation: Current head 661d3db differs from pull request most recent head edbcc17. Consider uploading reports for the commit edbcc17 to get more accurate results
```diff
@@ Coverage Diff @@
## dev #13777 +/- ##
============================================
- Coverage 39.02% 38.85% -0.17%
+ Complexity 4450 4424 -26
============================================
Files 1133 1135 +2
Lines 42353 42345 -8
Branches 4789 4777 -12
============================================
- Hits 16528 16453 -75
- Misses 23999 24067 +68
+ Partials 1826 1825 -1
```
| [Impacted Files](https://codecov.io/gh/apache/dolphinscheduler/pull/13777?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...e/dolphinscheduler/common/constants/Constants.java](https://codecov.io/gh/apache/dolphinscheduler/pull/13777?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvY29tbW9uL2NvbnN0YW50cy9Db25zdGFudHMuamF2YQ==) | `75.00% <ø> (ø)` | |
| [...heduler/common/log/remote/GcsRemoteLogHandler.java](https://codecov.io/gh/apache/dolphinscheduler/pull/13777?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvY29tbW9uL2xvZy9yZW1vdGUvR2NzUmVtb3RlTG9nSGFuZGxlci5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...ler/common/log/remote/RemoteLogHandlerFactory.java](https://codecov.io/gh/apache/dolphinscheduler/pull/13777?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvY29tbW9uL2xvZy9yZW1vdGUvUmVtb3RlTG9nSGFuZGxlckZhY3RvcnkuamF2YQ==) | `0.00% <0.00%> (ø)` | |
| [...apache/dolphinscheduler/common/utils/LogUtils.java](https://codecov.io/gh/apache/dolphinscheduler/pull/13777?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvY29tbW9uL3V0aWxzL0xvZ1V0aWxzLmphdmE=) | `25.00% <25.00%> (ø)` | |
| [...hinscheduler/common/log/remote/RemoteLogUtils.java](https://codecov.io/gh/apache/dolphinscheduler/pull/13777?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvY29tbW9uL2xvZy9yZW1vdGUvUmVtb3RlTG9nVXRpbHMuamF2YQ==) | `25.00% <100.00%> (+4.31%)` | :arrow_up: |
... and [54 files with indirect coverage changes](https://codecov.io/gh/apache/dolphinscheduler/pull/13777/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
--
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@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] rickchengx commented on a diff in pull request #13777: [Feature-13429][Remote Logging] Add support for writing task logs to Google Cloud Storage
Posted by "rickchengx (via GitHub)" <gi...@apache.org>.
rickchengx commented on code in PR #13777:
URL: https://github.com/apache/dolphinscheduler/pull/13777#discussion_r1151363050
##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/LogUtils.java:
##########
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.common.utils;
+
+import lombok.extern.slf4j.Slf4j;
+
+import org.slf4j.LoggerFactory;
+
+import ch.qos.logback.classic.LoggerContext;
+
+@Slf4j
+public class LogUtils {
Review Comment:
Another `LogUtils` is in `dolphinscheduler-task-api` module and it depends on some class in `dolphinscheduler-task-api` module.
--
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@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] rickchengx commented on a diff in pull request #13777: [Feature-13429][Remote Logging] Add support for writing task logs to Google Cloud Storage
Posted by "rickchengx (via GitHub)" <gi...@apache.org>.
rickchengx commented on code in PR #13777:
URL: https://github.com/apache/dolphinscheduler/pull/13777#discussion_r1151362240
##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/remote/GcsRemoteLogHandler.java:
##########
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.common.log.remote;
+
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.common.utils.PropertyUtils;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+import lombok.extern.slf4j.Slf4j;
+
+import com.google.auth.oauth2.ServiceAccountCredentials;
+import com.google.cloud.storage.Blob;
+import com.google.cloud.storage.BlobId;
+import com.google.cloud.storage.BlobInfo;
+import com.google.cloud.storage.Bucket;
+import com.google.cloud.storage.Storage;
+import com.google.cloud.storage.StorageOptions;
+
+@Slf4j
+public class GcsRemoteLogHandler implements RemoteLogHandler, Closeable {
+
+ private Storage gcsStorage;
+
+ private String bucketName;
+
+ private String credential;
+
+ private static GcsRemoteLogHandler instance;
+
+ private GcsRemoteLogHandler() {
+
+ }
+
+ public static synchronized GcsRemoteLogHandler getInstance() {
+ if (instance == null) {
+ instance = new GcsRemoteLogHandler();
+ instance.init();
+ }
+
+ return instance;
+ }
+
+ public void init() {
+ try {
+ credential = readCredentials();
+ bucketName = readBucketName();
+ gcsStorage = buildGcsStorage(credential);
+
+ checkBucketNameExists(bucketName);
+ } catch (IOException e) {
+ log.error("GCS Remote Log Handler init failed", e);
+ }
+ }
+
+ @Override
+ public void close() throws IOException {
+ try {
+ if (gcsStorage != null) {
+ gcsStorage.close();
+ }
+ } catch (Exception e) {
+ throw new IOException(e);
+ }
+ }
+
+ @Override
+ public void sendRemoteLog(String logPath) {
+ String objectName = RemoteLogUtils.getObjectNameFromLogPath(logPath);
+
+ try {
+ log.info("send remote log {} to GCS {}", logPath, objectName);
+
+ BlobInfo blobInfo = BlobInfo.newBuilder(
+ BlobId.of(bucketName, objectName)).build();
+
+ gcsStorage.create(blobInfo, Files.readAllBytes(Paths.get(logPath)));
+ } catch (Exception e) {
+ log.error("error while sending remote log {} to GCS {}", logPath, objectName, e);
+ }
+ }
+
+ @Override
+ public void getRemoteLog(String logPath) {
+ String objectName = RemoteLogUtils.getObjectNameFromLogPath(logPath);
+
+ try {
+ log.info("get remote log on GCS {} to {}", objectName, logPath);
+
+ Blob blob = gcsStorage.get(BlobId.of(bucketName, objectName));
+ blob.downloadTo(Paths.get(logPath));
+ } catch (Exception e) {
+ log.error("error while getting remote log on GCS {} to {}", objectName, logPath, e);
+ }
+ }
+
+ protected Storage buildGcsStorage(String credential) throws IOException {
+ return StorageOptions.newBuilder()
+ .setCredentials(ServiceAccountCredentials.fromStream(
+ Files.newInputStream(Paths.get(credential))))
+ .build()
+ .getService();
+ }
+
+ protected String readCredentials() {
+ return PropertyUtils.getString(Constants.REMOTE_LOGGING_GCS_CREDENTIAL);
+ }
+
+ protected String readBucketName() {
+ return PropertyUtils.getString(Constants.REMOTE_LOGGING_GCS_BUCKET_NAME);
+ }
+
+ public void checkBucketNameExists(String bucketName) {
+ if (StringUtils.isBlank(bucketName)) {
+ throw new IllegalArgumentException(Constants.REMOTE_LOGGING_GCS_BUCKET_NAME + " is blank");
+ }
+
+ boolean exist = false;
+ for (Bucket bucket : gcsStorage.list().iterateAll()) {
+ if (bucketName.equals(bucket.getName())) {
+ exist = true;
+ break;
+ }
+ }
+
+ if (!exist) {
+ throw new IllegalArgumentException(
+ "bucketName: " + bucketName + " is not exists, you need to create them by yourself");
+ } else {
Review Comment:
Thanks for your comment. I've deleted this exception.
--
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@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #13777: [Feature-13429][Remote Logging] Add support for writing task logs to Google Cloud Storage
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #13777:
URL: https://github.com/apache/dolphinscheduler/pull/13777#issuecomment-1480578827
SonarCloud Quality Gate failed. [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=13777)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=CODE_SMELL) [2 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13777&metric=new_coverage&view=list) [5.1% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13777&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13777&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13777&metric=new_duplicated_lines_density&view=list)
--
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@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] rickchengx commented on a diff in pull request #13777: [Feature-13429][Remote Logging] Add support for writing task logs to Google Cloud Storage
Posted by "rickchengx (via GitHub)" <gi...@apache.org>.
rickchengx commented on code in PR #13777:
URL: https://github.com/apache/dolphinscheduler/pull/13777#discussion_r1144248617
##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/remote/GcsRemoteLogHandler.java:
##########
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.common.log.remote;
+
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.common.utils.PropertyUtils;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+import lombok.extern.slf4j.Slf4j;
+
+import com.google.auth.oauth2.ServiceAccountCredentials;
+import com.google.cloud.storage.Blob;
+import com.google.cloud.storage.BlobId;
+import com.google.cloud.storage.BlobInfo;
+import com.google.cloud.storage.Bucket;
+import com.google.cloud.storage.Storage;
+import com.google.cloud.storage.StorageOptions;
+
+@Slf4j
+public class GcsRemoteLogHandler implements RemoteLogHandler, Closeable {
+
+ private Storage gcsStorage;
+
+ private String bucketName;
+
+ private String credential;
+
+ private static GcsRemoteLogHandler instance;
+
+ private GcsRemoteLogHandler() {
+
+ }
+
+ public static synchronized GcsRemoteLogHandler getInstance() {
+ if (instance == null) {
+ instance = new GcsRemoteLogHandler();
+ instance.init();
+ }
+
+ return instance;
+ }
+
+ public void init() {
+ try {
+ credential = readCredentials();
+ bucketName = readBucketName();
+ gcsStorage = buildGcsStorage(credential);
+
+ checkBucketNameExists(bucketName);
+ } catch (IOException e) {
+ log.error("GCS Remote Log Handler init failed", e);
+ }
+ }
+
+ @Override
+ public void close() throws IOException {
+ try {
+ if (gcsStorage != null) {
+ gcsStorage.close();
+ }
+ } catch (Exception e) {
+ throw new IOException(e);
+ }
+ }
+
+ @Override
+ public void sendRemoteLog(String logPath) {
+ String objectName = RemoteLogUtils.getObjectNameFromLogPath(logPath);
+
+ try {
+ log.info("send remote log {} to GCS {}", logPath, objectName);
+
+ BlobInfo blobInfo = BlobInfo.newBuilder(
+ BlobId.of(bucketName, objectName)).build();
+
+ gcsStorage.create(blobInfo, Files.readAllBytes(Paths.get(logPath)));
+ } catch (Exception e) {
+ log.error("error while sending remote log {} to GCS {}", logPath, objectName, e);
+ }
+ }
+
+ @Override
+ public void getRemoteLog(String logPath) {
+ String objectName = RemoteLogUtils.getObjectNameFromLogPath(logPath);
+
+ try {
+ log.info("get remote log on GCS {} to {}", objectName, logPath);
+
+ File dstFile = new File(logPath);
Review Comment:
Yes, we could delete this part, thanks for your comment.
--
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@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #13777: [Feature-13429][Remote Logging] Add support for writing task logs to Google Cloud Storage
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #13777:
URL: https://github.com/apache/dolphinscheduler/pull/13777#issuecomment-1478885923
SonarCloud Quality Gate failed. [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=13777)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=CODE_SMELL) [2 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13777&metric=new_coverage&view=list) [4.8% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13777&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13777&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13777&metric=new_duplicated_lines_density&view=list)
--
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@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] caishunfeng commented on a diff in pull request #13777: [Feature-13429][Remote Logging] Add support for writing task logs to Google Cloud Storage
Posted by "caishunfeng (via GitHub)" <gi...@apache.org>.
caishunfeng commented on code in PR #13777:
URL: https://github.com/apache/dolphinscheduler/pull/13777#discussion_r1149186958
##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/remote/GcsRemoteLogHandler.java:
##########
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.common.log.remote;
+
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.common.utils.PropertyUtils;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+import lombok.extern.slf4j.Slf4j;
+
+import com.google.auth.oauth2.ServiceAccountCredentials;
+import com.google.cloud.storage.Blob;
+import com.google.cloud.storage.BlobId;
+import com.google.cloud.storage.BlobInfo;
+import com.google.cloud.storage.Bucket;
+import com.google.cloud.storage.Storage;
+import com.google.cloud.storage.StorageOptions;
+
+@Slf4j
+public class GcsRemoteLogHandler implements RemoteLogHandler, Closeable {
+
+ private Storage gcsStorage;
+
+ private String bucketName;
+
+ private String credential;
+
+ private static GcsRemoteLogHandler instance;
+
+ private GcsRemoteLogHandler() {
+
+ }
+
+ public static synchronized GcsRemoteLogHandler getInstance() {
+ if (instance == null) {
+ instance = new GcsRemoteLogHandler();
+ instance.init();
+ }
+
+ return instance;
+ }
+
+ public void init() {
+ try {
+ credential = readCredentials();
+ bucketName = readBucketName();
+ gcsStorage = buildGcsStorage(credential);
+
+ checkBucketNameExists(bucketName);
+ } catch (IOException e) {
+ log.error("GCS Remote Log Handler init failed", e);
+ }
+ }
+
+ @Override
+ public void close() throws IOException {
+ try {
+ if (gcsStorage != null) {
+ gcsStorage.close();
+ }
+ } catch (Exception e) {
+ throw new IOException(e);
+ }
+ }
+
+ @Override
+ public void sendRemoteLog(String logPath) {
+ String objectName = RemoteLogUtils.getObjectNameFromLogPath(logPath);
+
+ try {
+ log.info("send remote log {} to GCS {}", logPath, objectName);
+
+ BlobInfo blobInfo = BlobInfo.newBuilder(
+ BlobId.of(bucketName, objectName)).build();
+
+ gcsStorage.create(blobInfo, Files.readAllBytes(Paths.get(logPath)));
+ } catch (Exception e) {
+ log.error("error while sending remote log {} to GCS {}", logPath, objectName, e);
+ }
+ }
+
+ @Override
+ public void getRemoteLog(String logPath) {
+ String objectName = RemoteLogUtils.getObjectNameFromLogPath(logPath);
+
+ try {
+ log.info("get remote log on GCS {} to {}", objectName, logPath);
+
+ Blob blob = gcsStorage.get(BlobId.of(bucketName, objectName));
+ blob.downloadTo(Paths.get(logPath));
+ } catch (Exception e) {
+ log.error("error while getting remote log on GCS {} to {}", objectName, logPath, e);
+ }
+ }
+
+ protected Storage buildGcsStorage(String credential) throws IOException {
+ return StorageOptions.newBuilder()
+ .setCredentials(ServiceAccountCredentials.fromStream(
+ Files.newInputStream(Paths.get(credential))))
+ .build()
+ .getService();
+ }
+
+ protected String readCredentials() {
+ return PropertyUtils.getString(Constants.REMOTE_LOGGING_GCS_CREDENTIAL);
+ }
+
+ protected String readBucketName() {
+ return PropertyUtils.getString(Constants.REMOTE_LOGGING_GCS_BUCKET_NAME);
+ }
+
+ public void checkBucketNameExists(String bucketName) {
+ if (StringUtils.isBlank(bucketName)) {
+ throw new IllegalArgumentException(Constants.REMOTE_LOGGING_GCS_BUCKET_NAME + " is blank");
+ }
+
+ boolean exist = false;
+ for (Bucket bucket : gcsStorage.list().iterateAll()) {
+ if (bucketName.equals(bucket.getName())) {
+ exist = true;
+ break;
+ }
+ }
+
+ if (!exist) {
+ throw new IllegalArgumentException(
+ "bucketName: " + bucketName + " is not exists, you need to create them by yourself");
+ } else {
Review Comment:
I think it does't need to throw exception here if not exist. WDYT?
##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/LogUtils.java:
##########
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.common.utils;
+
+import lombok.extern.slf4j.Slf4j;
+
+import org.slf4j.LoggerFactory;
+
+import ch.qos.logback.classic.LoggerContext;
+
+@Slf4j
+public class LogUtils {
Review Comment:
It's already exist the same name utils.
--
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@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] caishunfeng commented on pull request #13777: [Feature-13429][Remote Logging] Add support for writing task logs to Google Cloud Storage
Posted by "caishunfeng (via GitHub)" <gi...@apache.org>.
caishunfeng commented on PR #13777:
URL: https://github.com/apache/dolphinscheduler/pull/13777#issuecomment-1484986089

Hi @rickchengx please check the fail CI case.
--
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@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #13777: [Feature-13429][Remote Logging] Add support for writing task logs to Google Cloud Storage
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #13777:
URL: https://github.com/apache/dolphinscheduler/pull/13777#issuecomment-1489802949
SonarCloud Quality Gate failed. [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=13777)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=CODE_SMELL) [1 Code Smell](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13777&metric=new_coverage&view=list) [3.9% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13777&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13777&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13777&metric=new_duplicated_lines_density&view=list)
--
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@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #13777: [Feature-13429][Remote Logging] Add support for writing task logs to Google Cloud Storage
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #13777:
URL: https://github.com/apache/dolphinscheduler/pull/13777#issuecomment-1489800141
SonarCloud Quality Gate failed. [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=13777)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=CODE_SMELL) [1 Code Smell](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13777&metric=new_coverage&view=list) [3.9% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13777&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13777&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13777&metric=new_duplicated_lines_density&view=list)
--
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@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] Radeity commented on a diff in pull request #13777: [Feature-13429][Remote Logging] Add support for writing task logs to Google Cloud Storage
Posted by "Radeity (via GitHub)" <gi...@apache.org>.
Radeity commented on code in PR #13777:
URL: https://github.com/apache/dolphinscheduler/pull/13777#discussion_r1144216869
##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/remote/GcsRemoteLogHandler.java:
##########
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.common.log.remote;
+
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.common.utils.PropertyUtils;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+import lombok.extern.slf4j.Slf4j;
+
+import com.google.auth.oauth2.ServiceAccountCredentials;
+import com.google.cloud.storage.Blob;
+import com.google.cloud.storage.BlobId;
+import com.google.cloud.storage.BlobInfo;
+import com.google.cloud.storage.Bucket;
+import com.google.cloud.storage.Storage;
+import com.google.cloud.storage.StorageOptions;
+
+@Slf4j
+public class GcsRemoteLogHandler implements RemoteLogHandler, Closeable {
+
+ private Storage gcsStorage;
+
+ private String bucketName;
+
+ private String credential;
+
+ private static GcsRemoteLogHandler instance;
+
+ private GcsRemoteLogHandler() {
+
+ }
+
+ public static synchronized GcsRemoteLogHandler getInstance() {
+ if (instance == null) {
+ instance = new GcsRemoteLogHandler();
+ instance.init();
+ }
+
+ return instance;
+ }
+
+ public void init() {
+ try {
+ credential = readCredentials();
+ bucketName = readBucketName();
+ gcsStorage = buildGcsStorage(credential);
+
+ checkBucketNameExists(bucketName);
+ } catch (IOException e) {
+ log.error("GCS Remote Log Handler init failed", e);
+ }
+ }
+
+ @Override
+ public void close() throws IOException {
+ try {
+ if (gcsStorage != null) {
+ gcsStorage.close();
+ }
+ } catch (Exception e) {
+ throw new IOException(e);
+ }
+ }
+
+ @Override
+ public void sendRemoteLog(String logPath) {
+ String objectName = RemoteLogUtils.getObjectNameFromLogPath(logPath);
+
+ try {
+ log.info("send remote log {} to GCS {}", logPath, objectName);
+
+ BlobInfo blobInfo = BlobInfo.newBuilder(
+ BlobId.of(bucketName, objectName)).build();
+
+ gcsStorage.create(blobInfo, Files.readAllBytes(Paths.get(logPath)));
+ } catch (Exception e) {
+ log.error("error while sending remote log {} to GCS {}", logPath, objectName, e);
+ }
+ }
+
+ @Override
+ public void getRemoteLog(String logPath) {
+ String objectName = RemoteLogUtils.getObjectNameFromLogPath(logPath);
+
+ try {
+ log.info("get remote log on GCS {} to {}", objectName, logPath);
+
+ File dstFile = new File(logPath);
+ if (dstFile.isDirectory()) {
+ Files.delete(dstFile.toPath());
+ } else {
+ Files.createDirectories(dstFile.getParentFile().toPath());
Review Comment:
It seems like we have already created the directory in `mkdirOfLog` before.
https://github.com/apache/dolphinscheduler/blob/69e744961b489c9553e656b8d1f6247b46884e05/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/remote/RemoteLogUtils.java#L72-L75
##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/remote/GcsRemoteLogHandler.java:
##########
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.common.log.remote;
+
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.common.utils.PropertyUtils;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+import lombok.extern.slf4j.Slf4j;
+
+import com.google.auth.oauth2.ServiceAccountCredentials;
+import com.google.cloud.storage.Blob;
+import com.google.cloud.storage.BlobId;
+import com.google.cloud.storage.BlobInfo;
+import com.google.cloud.storage.Bucket;
+import com.google.cloud.storage.Storage;
+import com.google.cloud.storage.StorageOptions;
+
+@Slf4j
+public class GcsRemoteLogHandler implements RemoteLogHandler, Closeable {
+
+ private Storage gcsStorage;
+
+ private String bucketName;
+
+ private String credential;
+
+ private static GcsRemoteLogHandler instance;
+
+ private GcsRemoteLogHandler() {
+
+ }
+
+ public static synchronized GcsRemoteLogHandler getInstance() {
+ if (instance == null) {
+ instance = new GcsRemoteLogHandler();
+ instance.init();
+ }
+
+ return instance;
+ }
+
+ public void init() {
+ try {
+ credential = readCredentials();
+ bucketName = readBucketName();
+ gcsStorage = buildGcsStorage(credential);
+
+ checkBucketNameExists(bucketName);
+ } catch (IOException e) {
+ log.error("GCS Remote Log Handler init failed", e);
+ }
+ }
+
+ @Override
+ public void close() throws IOException {
+ try {
+ if (gcsStorage != null) {
+ gcsStorage.close();
+ }
+ } catch (Exception e) {
+ throw new IOException(e);
+ }
+ }
+
+ @Override
+ public void sendRemoteLog(String logPath) {
+ String objectName = RemoteLogUtils.getObjectNameFromLogPath(logPath);
+
+ try {
+ log.info("send remote log {} to GCS {}", logPath, objectName);
+
+ BlobInfo blobInfo = BlobInfo.newBuilder(
+ BlobId.of(bucketName, objectName)).build();
+
+ gcsStorage.create(blobInfo, Files.readAllBytes(Paths.get(logPath)));
+ } catch (Exception e) {
+ log.error("error while sending remote log {} to GCS {}", logPath, objectName, e);
+ }
+ }
+
+ @Override
+ public void getRemoteLog(String logPath) {
+ String objectName = RemoteLogUtils.getObjectNameFromLogPath(logPath);
+
+ try {
+ log.info("get remote log on GCS {} to {}", objectName, logPath);
+
+ File dstFile = new File(logPath);
Review Comment:
May i ask is it any possibility logPath is a directory?
--
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@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #13777: [Feature-13429][Remote Logging] Add support for writing task logs to Google Cloud Storage
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #13777:
URL: https://github.com/apache/dolphinscheduler/pull/13777#issuecomment-1478882533
SonarCloud Quality Gate failed. [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=13777)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=CODE_SMELL) [2 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13777&metric=new_coverage&view=list) [4.8% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13777&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13777&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13777&metric=new_duplicated_lines_density&view=list)
--
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@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] rickchengx commented on a diff in pull request #13777: [Feature-13429][Remote Logging] Add support for writing task logs to Google Cloud Storage
Posted by "rickchengx (via GitHub)" <gi...@apache.org>.
rickchengx commented on code in PR #13777:
URL: https://github.com/apache/dolphinscheduler/pull/13777#discussion_r1144248617
##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/remote/GcsRemoteLogHandler.java:
##########
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.common.log.remote;
+
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.common.utils.PropertyUtils;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+import lombok.extern.slf4j.Slf4j;
+
+import com.google.auth.oauth2.ServiceAccountCredentials;
+import com.google.cloud.storage.Blob;
+import com.google.cloud.storage.BlobId;
+import com.google.cloud.storage.BlobInfo;
+import com.google.cloud.storage.Bucket;
+import com.google.cloud.storage.Storage;
+import com.google.cloud.storage.StorageOptions;
+
+@Slf4j
+public class GcsRemoteLogHandler implements RemoteLogHandler, Closeable {
+
+ private Storage gcsStorage;
+
+ private String bucketName;
+
+ private String credential;
+
+ private static GcsRemoteLogHandler instance;
+
+ private GcsRemoteLogHandler() {
+
+ }
+
+ public static synchronized GcsRemoteLogHandler getInstance() {
+ if (instance == null) {
+ instance = new GcsRemoteLogHandler();
+ instance.init();
+ }
+
+ return instance;
+ }
+
+ public void init() {
+ try {
+ credential = readCredentials();
+ bucketName = readBucketName();
+ gcsStorage = buildGcsStorage(credential);
+
+ checkBucketNameExists(bucketName);
+ } catch (IOException e) {
+ log.error("GCS Remote Log Handler init failed", e);
+ }
+ }
+
+ @Override
+ public void close() throws IOException {
+ try {
+ if (gcsStorage != null) {
+ gcsStorage.close();
+ }
+ } catch (Exception e) {
+ throw new IOException(e);
+ }
+ }
+
+ @Override
+ public void sendRemoteLog(String logPath) {
+ String objectName = RemoteLogUtils.getObjectNameFromLogPath(logPath);
+
+ try {
+ log.info("send remote log {} to GCS {}", logPath, objectName);
+
+ BlobInfo blobInfo = BlobInfo.newBuilder(
+ BlobId.of(bucketName, objectName)).build();
+
+ gcsStorage.create(blobInfo, Files.readAllBytes(Paths.get(logPath)));
+ } catch (Exception e) {
+ log.error("error while sending remote log {} to GCS {}", logPath, objectName, e);
+ }
+ }
+
+ @Override
+ public void getRemoteLog(String logPath) {
+ String objectName = RemoteLogUtils.getObjectNameFromLogPath(logPath);
+
+ try {
+ log.info("get remote log on GCS {} to {}", objectName, logPath);
+
+ File dstFile = new File(logPath);
Review Comment:
We could delete this part, thanks for your comment.
--
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@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #13777: [Feature-13429][Remote Logging] Add support for writing task logs to Google Cloud Storage
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #13777:
URL: https://github.com/apache/dolphinscheduler/pull/13777#issuecomment-1480574839
SonarCloud Quality Gate failed. [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=13777)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=CODE_SMELL) [2 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13777&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13777&metric=new_coverage&view=list) [5.1% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13777&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13777&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13777&metric=new_duplicated_lines_density&view=list)
--
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@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] rickchengx commented on pull request #13777: [Feature-13429][Remote Logging] Add support for writing task logs to Google Cloud Storage
Posted by "rickchengx (via GitHub)" <gi...@apache.org>.
rickchengx commented on PR #13777:
URL: https://github.com/apache/dolphinscheduler/pull/13777#issuecomment-1487870792
>  Hi @rickchengx please check the fail CI case.
Hi, @caishunfeng , thanks a lot for your comment. I've update the pom
--
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@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org