Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HPCC-30090 Find Dropzone plane using host and path when spraying #17676

Merged
merged 1 commit into from
Aug 23, 2023

Conversation

wangkx
Copy link
Member

@wangkx wangkx commented Aug 14, 2023

Type of change:

  • This change is a bug fix (non-breaking change which fixes an issue).
  • This change is a new feature (non-breaking change which adds functionality).
  • This change improves the code (refactor or other change that does not change the functionality)
  • This change fixes warnings (the fix does not alter the functionality or the generated code)
  • This change is a breaking change (fix or feature that will cause existing behavior to change).
  • This change alters the query API (existing queries will have to be recompiled)

Checklist:

  • My code follows the code style of this project.
    • My code does not create any new warnings from compiler, build system, or lint.
  • The commit message is properly formatted and free of typos.
    • The commit message title makes sense in a changelog, by itself.
    • The commit is signed.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly, or...
    • I have created a JIRA ticket to update the documentation.
    • Any new interfaces or exported functions are appropriately commented.
  • I have read the CONTRIBUTORS document.
  • The change has been fully tested:
    • I have added tests to cover my changes.
    • All new and existing tests passed.
    • I have checked that this change does not introduce memory leaks.
    • I have used Valgrind or similar tools to check for potential issues.
  • I have given due consideration to all of the following potential concerns:
    • Scalability
    • Performance
    • Security
    • Thread-safety
    • Cloud-compatibility
    • Premature optimization
    • Existing deployed queries will not be broken
    • This change fixes the problem, not just the symptom
    • The target branch of this pull request is appropriate for such a change.
  • There are no similar instances of the same problem that should be addressed
    • I have addressed them here
    • I have raised JIRA issues to address them separately
  • This is a user interface / front-end modification
    • I have tested my changes in multiple modern browsers
    • The component(s) render as expected

Smoketest:

  • Send notifications about my Pull Request position in Smoketest queue.
  • Test my draft Pull Request.

Testing:

@wangkx wangkx requested a review from jakesmith August 14, 2023 18:58
@github-actions
Copy link

https://track.hpccsystems.com/browse/HPCC-30090
This pull request is already registered

Copy link
Member

@jakesmith jakesmith left a comment

Choose a reason for hiding this comment

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

@wangkx - 1 issue and 1 improvement suggestion.

throw makeStringExceptionV(ECLWATCH_INVALID_INPUT, "The host '%s' defined in the SourcePath '%s' does not match with the host '%s' defined in SourceIP.", hostInPath.str(), file, hostReq);
}
if (isAbsolutePath(firstFilePath))
return findDropZonePlane(firstFilePath, hostReq, true, isContainerized());
Copy link
Member

Choose a reason for hiding this comment

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

unless I'm missing something this doesn't look right..

'file' will be e.g. /mydropzone/filename.csv

so it will be calling findDropZonePlane(path="/mydropzone/filename.csv", ... )
which will not match a plane configured with /mydropzone

i.e. I think you need to strip the "/filename.csv" and test only with the path

Copy link
Member

Choose a reason for hiding this comment

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

I know it's not supposed to / not supported, if they have multiple filenames that point to different planes, but it would be validating that here, i.e. don't just return 1st match. Instead retain it, and check other paths match, or if a UNC, both the host and the path match - fire an error if any don't (unsupported).

Copy link
Member Author

Choose a reason for hiding this comment

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

I found that the filename.csv does not have to be stripped because the findDropZonePlane() will call the isPathInPlane() to validate the path:
bool isPathInPlane(IPropertyTree *plane, const char *path)
{
return isEmptyString(path) || startsWith(path, plane->queryProp("@Prefix"));
}

Copy link
Member Author

Choose a reason for hiding this comment

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

I know it's not supposed to / not supported, if they have multiple filenames that point to different planes, but it would be validating that here, i.e. don't just return 1st match. Instead retain it, and check other paths match, or if a UNC, both the host and the path match - fire an error if any don't (unsupported).

The existing code does check other paths and host in line 2001 to 2039. Do we want to duplicate the function or refactor them in this PR?

Copy link
Member

Choose a reason for hiding this comment

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

I found that the filename.csv does not have to be stripped because the findDropZonePlane() will call the isPathInPlane() to validate the path: bool isPathInPlane(IPropertyTree *plane, const char *path) { return isEmptyString(path) || startsWith(path, plane->queryProp("@Prefix")); }

ok, yes agree, I misinterpreted what isPlaneInPath was doing. It's fine as it is.

Copy link
Member Author

@wangkx wangkx Aug 16, 2023

Choose a reason for hiding this comment

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

Lookup based on the 1st file, if it is relative, then it has to lookup by host only.

What if >1 dropzones have the same host (with different paths) and the 2nd filename has an absolute path which matches with the path of the 2nd dropzone?

Copy link
Member

Choose a reason for hiding this comment

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

all inconsistencies should be rejected.
Find the dropzone based on the 1st file + IP from UNC, or IP from request, and if any subsequent ones do not lie in that dropzone, throw an error.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok

Copy link
Member Author

Choose a reason for hiding this comment

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

For bare-metal and isDropZoneRestrictionEnabled()==false, the findDropZonePlane() may return nullptr. I guess the code should call the findDropZonePlane() if it is 1st file and !dropZone?

Copy link
Member

Choose a reason for hiding this comment

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

yes, agreed.

@wangkx
Copy link
Member Author

wangkx commented Aug 15, 2023

@jakesmith please see my responses to your comments.

@wangkx
Copy link
Member Author

wangkx commented Aug 15, 2023

@jakesmith please review my new commit.

@wangkx wangkx requested a review from jakesmith August 15, 2023 21:26
Copy link
Member

@jakesmith jakesmith left a comment

Choose a reason for hiding this comment

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

@wangkx - see my replies.

@wangkx wangkx force-pushed the h30090 branch 2 times, most recently from 8c2dc95 to 1d6c72d Compare August 16, 2023 20:15
@wangkx wangkx requested a review from jakesmith August 16, 2023 21:55
@wangkx
Copy link
Member Author

wangkx commented Aug 16, 2023

@jakesmith please review my new commit.

Copy link
Member

@jakesmith jakesmith left a comment

Choose a reason for hiding this comment

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

@wangkx - looks good, 1 minor comment, but (not new), where is isDropZoneRestrictionEnabled validated? It looks like it will let it proceed if a dropzone is not found, even if isDropZoneRestrictionEnabled are on?

I see that getAndValidateDropZone uses isDropZoneRestrictionEnabled, but that's not called in this context, should it be?

throw makeStringExceptionV(ECLWATCH_INVALID_INPUT, "Path '%s' is not valid for dropzone '%s'", path, sourcePlaneReq.str());
}
else
{
if (!dropZone && (i == 0))
{
dropZone.setown(findDropZonePlane(nullptr, sourceIPReq, true, isContainerized()));
Copy link
Member

Choose a reason for hiding this comment

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

might benefit from a comment above this line to say that if here, it sourceIPReq must have been supplied

@wangkx
Copy link
Member Author

wangkx commented Aug 17, 2023

@jakesmith please review my changes.

@wangkx wangkx requested a review from jakesmith August 17, 2023 13:07
Copy link
Member

@jakesmith jakesmith left a comment

Choose a reason for hiding this comment

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

@wangkx - looks correct. Please squash

@wangkx
Copy link
Member Author

wangkx commented Aug 17, 2023

@ghalliday this PR is ready to be merged.

@ghalliday ghalliday merged commit 04b6c0b into hpcc-systems:candidate-9.2.x Aug 23, 2023
50 checks passed
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.

3 participants