Skip to content

Conversation

@ruanwenjun
Copy link
Member

@ruanwenjun ruanwenjun commented Jun 12, 2024

Purpose of the pull request

close #16140
close #16072

Brief change log

  • Refactor the storage api
  • Refactor the storage service
  • Add IT for LocalStorage/HdfsStorage/S3Storage
  • Remove some mock UT, this is meaningless.
  • Fix fetch file content and update file content will cut 3000 lines.

Verify this pull request

Verify by e2e(s3 case) / IT(local hdfs/ s3 case) and manual test.

Resource CRUD

image image image

UDF CRUD

image

Using in task

image image

@github-actions github-actions bot added UI ui and front end related backend labels Jun 12, 2024
@ruanwenjun ruanwenjun marked this pull request as draft June 12, 2024 11:58
@ruanwenjun ruanwenjun force-pushed the dev_wenjun_refactorStorageAPI branch 2 times, most recently from d1333cf to a0db19d Compare June 12, 2024 12:09
response.setContentType("application/octet-stream");
response.setCharacterEncoding("utf-8");
response.setContentLength(length);
response.setHeader("Content-Disposition", "attachment;filename=" + fileName);

Check warning

Code scanning / CodeQL

HTTP response splitting

This header depends on a [user-provided value](1), which may cause a response-splitting vulnerability.
response.setCharacterEncoding("utf-8");
response.setContentLength(length);
response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
Files.copy(Paths.get(localTmpFileAbsolutePath), response.getOutputStream());

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression

This path depends on a [user-provided value](1).
String originDirectoryAbsolutePath = renameDirectoryDto.getOriginDirectoryAbsolutePath();
String targetDirectoryAbsolutePath = renameDirectoryDto.getTargetDirectoryAbsolutePath();
storageOperate.copy(originDirectoryAbsolutePath, targetDirectoryAbsolutePath, true, true);
log.info("Success rename directory: {} -> {} ", originDirectoryAbsolutePath, targetDirectoryAbsolutePath);

Check failure

Code scanning / CodeQL

Log Injection

This log entry depends on a [user-provided value](1). This log entry depends on a [user-provided value](2).
String originFileAbsolutePath = renameFileDto.getOriginFileAbsolutePath();
String targetFileAbsolutePath = renameFileDto.getTargetFileAbsolutePath();
storageOperate.copy(originFileAbsolutePath, targetFileAbsolutePath, true, true);
log.info("Success rename file: {} -> {} ", originFileAbsolutePath, targetFileAbsolutePath);

Check failure

Code scanning / CodeQL

Log Injection

This log entry depends on a [user-provided value](1).
String originFileAbsolutePath = renameFileDto.getOriginFileAbsolutePath();
String targetFileAbsolutePath = renameFileDto.getTargetFileAbsolutePath();
storageOperate.copy(originFileAbsolutePath, targetFileAbsolutePath, true, true);
log.info("Success rename file: {} -> {} ", originFileAbsolutePath, targetFileAbsolutePath);

Check failure

Code scanning / CodeQL

Log Injection

This log entry depends on a [user-provided value](1). This log entry depends on a [user-provided value](2).
}
storageOperate.upload(srcLocalTmpFileAbsolutePath, updateFileDto.getFileAbsolutePath(), true, true);
ApiServerMetrics.recordApiResourceUploadSize(updateFileDto.getFile().getSize());
log.info("Success upload resource file: {} complete.", updateFileDto.getFileAbsolutePath());

Check failure

Code scanning / CodeQL

Log Injection

This log entry depends on a [user-provided value](1).
storageOperate.upload(srcLocalTmpFileAbsolutePath, updateFileFromContentDto.getFileAbsolutePath(), true,
true);
ApiServerMetrics.recordApiResourceUploadSize(updateFileFromContentDto.getFileContent().length());
log.info("Success upload resource file: {} complete.", updateFileFromContentDto.getFileAbsolutePath());

Check failure

Code scanning / CodeQL

Log Injection

This log entry depends on a [user-provided value](1).
@ruanwenjun ruanwenjun force-pushed the dev_wenjun_refactorStorageAPI branch 3 times, most recently from 448904a to 02350b4 Compare June 12, 2024 14:21
@ruanwenjun ruanwenjun self-assigned this Jun 12, 2024
@ruanwenjun ruanwenjun added this to the 3.3.0 milestone Jun 12, 2024
@ruanwenjun ruanwenjun force-pushed the dev_wenjun_refactorStorageAPI branch 3 times, most recently from 1cff355 to b89b35b Compare June 12, 2024 14:32
@codecov-commenter
Copy link

codecov-commenter commented Jun 12, 2024

Codecov Report

Attention: Patch coverage is 41.84477% with 517 lines in your changes missing coverage. Please review.

Project coverage is 41.07%. Comparing base (61a6bd0) to head (12b3efd).

Current head 12b3efd differs from pull request most recent head 82a6f2d

Please upload reports for the commit 82a6f2d to get more accurate results.

Files Patch % Lines
...heduler/api/service/impl/ResourcesServiceImpl.java 0.00% 147 Missing ⚠️
...nscheduler/api/controller/ResourcesController.java 50.57% 43 Missing ⚠️
...scheduler/plugin/storage/s3/S3StorageOperator.java 77.61% 25 Missing and 5 partials ⚠️
...pache/dolphinscheduler/common/utils/FileUtils.java 7.40% 25 Missing ⚠️
...or/resource/CreateDirectoryRequestTransformer.java 4.16% 23 Missing ⚠️
...resource/PagingResourceItemRequestTransformer.java 0.00% 23 Missing ⚠️
...duler/plugin/storage/hdfs/HdfsStorageOperator.java 79.79% 18 Missing and 2 partials ⚠️
...or/resource/FileFromContentRequestTransformer.java 9.52% 19 Missing ⚠️
...api/validator/resource/FileRequestTransformer.java 9.52% 19 Missing ⚠️
...apache/dolphinscheduler/api/vo/ResourceItemVO.java 0.00% 14 Missing ⚠️
... and 28 more
Additional details and impacted files
@@             Coverage Diff              @@
##                dev   #16141      +/-   ##
============================================
+ Coverage     40.70%   41.07%   +0.36%     
+ Complexity     5245     5155      -90     
============================================
  Files          1385     1399      +14     
  Lines         46109    44856    -1253     
  Branches       4923     4756     -167     
============================================
- Hits          18768    18423     -345     
+ Misses        25414    24628     -786     
+ Partials       1927     1805     -122     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ruanwenjun ruanwenjun force-pushed the dev_wenjun_refactorStorageAPI branch from b89b35b to 554b9f2 Compare June 13, 2024 01:19
@ruanwenjun ruanwenjun marked this pull request as ready for review June 13, 2024 12:09
@ruanwenjun ruanwenjun force-pushed the dev_wenjun_refactorStorageAPI branch 3 times, most recently from 8c6a08c to 41332d7 Compare June 14, 2024 15:34
@ruanwenjun ruanwenjun force-pushed the dev_wenjun_refactorStorageAPI branch 2 times, most recently from 346663b to c3253e9 Compare June 15, 2024 02:32
Copy link
Contributor

@rickchengx rickchengx left a comment

Choose a reason for hiding this comment

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

Overall LGTM, thanks @ruanwenjun for refactoring Storage API to enhance the robustness and maintainability of this part of the code.

Copy link
Contributor

@rickchengx rickchengx left a comment

Choose a reason for hiding this comment

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

Since this is a refactor of the storage module, it would be better to provide some screenshots.

@ruanwenjun ruanwenjun force-pushed the dev_wenjun_refactorStorageAPI branch from c3253e9 to 80d9adb Compare June 15, 2024 03:29
@ruanwenjun
Copy link
Member Author

Since this is a refactor of the storage module, it would be better to provide some screenshots.

Good suggestion, I add some picture in the description

@ruanwenjun ruanwenjun requested a review from rickchengx June 15, 2024 03:38
@ruanwenjun ruanwenjun force-pushed the dev_wenjun_refactorStorageAPI branch from 2bf30e1 to 2fa31dc Compare June 16, 2024 03:28
Copy link
Member

@SbloodyS SbloodyS left a comment

Choose a reason for hiding this comment

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

Please check failed UT.

@ruanwenjun ruanwenjun force-pushed the dev_wenjun_refactorStorageAPI branch from 72ab21f to 8876467 Compare June 16, 2024 07:12
@ruanwenjun
Copy link
Member Author

Please check failed UT.

Done

@ruanwenjun ruanwenjun force-pushed the dev_wenjun_refactorStorageAPI branch from 8876467 to 6964ceb Compare June 16, 2024 13:55
@ruanwenjun ruanwenjun force-pushed the dev_wenjun_refactorStorageAPI branch from 6964ceb to 9fb32f3 Compare June 16, 2024 13:58
@ruanwenjun ruanwenjun requested a review from SbloodyS June 17, 2024 02:06
Copy link
Member

@SbloodyS SbloodyS left a comment

Choose a reason for hiding this comment

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

LGTM.

Copy link
Contributor

@rickchengx rickchengx left a comment

Choose a reason for hiding this comment

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

LGTM

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
32.2% Coverage on New Code (required ≥ 60%)
E Reliability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

@ruanwenjun ruanwenjun merged commit edeb1b2 into apache:dev Jun 17, 2024
@ruanwenjun ruanwenjun deleted the dev_wenjun_refactorStorageAPI branch June 17, 2024 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[DSIP-45] Polish the Storage SPI [Bug] [resource center] edit json which more than 3000 line will cut off

4 participants