-
Notifications
You must be signed in to change notification settings - Fork 6
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
Fix for MIN-1312: Graceful exit of DataMover for invalid prefix #25
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -206,17 +206,34 @@ def get_s3_prefix(logger, nfs_cluster, prefix=None): | |
yield nfs_server_ip + "/" | ||
|
||
|
||
def validate_s3_prefix(logger, prefix): | ||
def validate_s3_prefix(logger, prefix, config_nfs=None): | ||
""" | ||
Validate a given prefix. A S3 prefix should start without "/" and end with "/". | ||
<prefix string>/ | ||
:param logger: multiprocessing logger object | ||
:param prefix: a string | ||
:param(optional) config_nfs: nfs_share Config dict | ||
:return: Success/Failure | ||
""" | ||
inv_prefix = 0 | ||
if prefix.startswith("/") or not prefix.endswith("/"): | ||
logger.error("WRONG specification of prefix. Should be in the format of <nfs_server_ip>/<prefix>/ ") | ||
logger.fatal("WRONG specification of prefix. Should be in the format of <nfs_server_ip>/<prefix>/ ") | ||
return False | ||
if config_nfs is not None: | ||
cluster_ip = prefix.split('/')[0] | ||
if config_nfs and cluster_ip in config_nfs: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You already checked There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was actually looking to make a double validation... Anyways, it did seem clogged up, so have updated the code in my latest commit. |
||
for nfs_share in config_nfs[cluster_ip]: | ||
nfs_share_prefix = cluster_ip + nfs_share | ||
if not prefix.startswith(nfs_share_prefix): | ||
inv_prefix += 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could have optimized better. Make inv_prefix as a bool with False. If it gets detected, mark it as True and break rather than looping all the entries of config_nfs[cluster_ip] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does make sense... have updated the code to reflect such. |
||
if inv_prefix == len(config_nfs[cluster_ip]): | ||
logger.fatal("Specified Prefix: {} does not match any entry in the Config file nfs_share list: " | ||
"{}.".format(prefix, config_nfs[cluster_ip])) | ||
return False | ||
else: | ||
logger.fatal("Specified Prefix IP: {} does not match any entry in the Config file nfs_share IP list: {}." | ||
.format(cluster_ip, config_nfs)) | ||
return False | ||
return True | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if config_nfs:
is sufficient.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated.