Skip to content

MINIFICPP-1390 Create DeleteS3Object processor#931

Closed
lordgamez wants to merge 29 commits intoapache:mainfrom
lordgamez:MINIFICPP-1390
Closed

MINIFICPP-1390 Create DeleteS3Object processor#931
lordgamez wants to merge 29 commits intoapache:mainfrom
lordgamez:MINIFICPP-1390

Conversation

@lordgamez
Copy link
Contributor

Jira issue: https://issues.apache.org/jira/browse/MINIFICPP-1390


Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.

In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:

For all changes:

  • Is there a JIRA ticket associated with this PR? Is it referenced
    in the commit message?

  • Does your PR title start with MINIFICPP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.

  • Has your PR been rebased against the latest commit within the target branch (typically main)?

  • Is your initial contribution a single, squashed commit?

For code changes:

  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
  • If applicable, have you updated the LICENSE file?
  • If applicable, have you updated the NOTICE file?

For documentation related changes:

  • Have you ensured that format looks appropriate for the output in which it is rendered?

Note:

Please ensure that once the PR is submitted, you check GitHub Actions CI results for build issues and submit an update to your PR as soon as possible.

Copy link
Contributor

@arpadboda arpadboda left a comment

Choose a reason for hiding this comment

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

Mostly looks good, added some minor comments.

@adamdebreceni
Copy link
Contributor

wrapping the object id in quotes when logging might improve readability of the log message (might be beneficial for the bucket id as well) (here "one" is the object id)

::S3WrapperBase] [info] Deleted S3 object one from bucket adebreceni-minifi-0


### Description

Deletes FlowFiles on an Amazon S3 Bucket. If attempting to delete a file that does not exist, FlowFile is routed to success.
Copy link
Contributor

Choose a reason for hiding this comment

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

This sounds like "if something does not exist it is rerouted to success".

Copy link
Contributor

Choose a reason for hiding this comment

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

I see this is verbatim from NiFi, but I still don't understand what is going on. If a flowfile does not exist, this processor yields.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We started discussing this with @arpadboda and @adebreceni in a comment above, where @adebreceni noted that it can be logical if we interpret it the following way: "if you define "success" as the post-condition "the object is not in the S3 bucket", it makes sense to transfer to "success"". So if the goal is to have the object non-existent in that bucket we succeed by doing nothing.


if (!getExpressionLanguageSupportedProperties(context, flow_file)) {
context->yield();
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't the flowfile get transfered to Failure here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you are right, as if this fails we cannot continue with this flow file as one of the required properties is missing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in af2501b


void DeleteS3Object::initialize() {
// Set the supported properties
std::set<core::Property> properties(S3Processor::getSupportedProperties());
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor, but instead of adding the properties manually and defining them twiceS3Processor could set its supported properties in its constructor, and the interface for the ConfigurableComponent could be extended with insertion for new properties.

Copy link
Contributor Author

@lordgamez lordgamez Dec 11, 2020

Choose a reason for hiding this comment

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

Included in b065515. The only difference is that I did not introduce a new insertion operation in the ConfigurableComponent but used updateSupportedProperties instead.

: S3Processor(std::move(name), uuid, logging::LoggerFactory<DeleteS3Object>::getLogger()) {
}

explicit DeleteS3Object(std::string name, minifi::utils::Identifier uuid, std::unique_ptr<aws::s3::S3WrapperBase> s3_wrapper)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this constructor used somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this constructor is used in the tests to pass the mocked version of the S3 wrapper.

Copy link
Contributor

@adamdebreceni adamdebreceni Dec 11, 2020

Choose a reason for hiding this comment

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

if it is only used for testing we could make it private and friend a DeleteS3ObjectTestAccessor (or some other equally horrendously named class)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved the constructor private in b04bddf

core::PropertyBuilder::createProperty("Communications Timeout")
->isRequired(true)
->withDefaultValue<core::TimePeriodValue>("30 sec")
->withDescription("")
Copy link
Contributor

Choose a reason for hiding this comment

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

I see that NiFi does not have this either, but shouldn't we add some explanation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added description in 4f3ac8e

EndpointOverrideURL, ProxyHost, ProxyPort, ProxyUsername, ProxyPassword, UseDefaultCredentials};
}

minifi::utils::optional<Aws::Auth::AWSCredentials> S3Processor::getAWSCredentialsFromControllerService(const std::shared_ptr<core::ProcessContext> &context) const {
Copy link
Contributor

@hunyadi-dev hunyadi-dev Dec 9, 2020

Choose a reason for hiding this comment

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

Minor, but minifi:: seems redundant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is needed in this case, as we introduced minifi::aws::utils and this class is in the scope of the aws namespace.

@lordgamez lordgamez force-pushed the MINIFICPP-1390 branch 2 times, most recently from 4f3ac8e to 3f872f1 Compare December 11, 2020 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants