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

Add code to replace relative paths on upgrade. #1397 #1461

Merged
merged 9 commits into from
Dec 20, 2019

Conversation

milleruntime
Copy link
Contributor

No description provided.

String metaEntry = key.getColumnQualifier().toString();
Path relPath = resolveRelativePath(metaEntry, key);
Path absPath = new Path(volumeProp, relPath);
if (fs.exists(absPath)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do existence check again?

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 was thinking the 2 static methods could be called by a command line utility to give admins the chance to resolve the paths before an upgrade. I can remove the second check as long as we make sure the utility calls the other method first.

@ctubbsii ctubbsii added this to In progress in 2.1.0 via automation Dec 17, 2019
Copy link
Member

@ctubbsii ctubbsii left a comment

Choose a reason for hiding this comment

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

I can't wait to have this done. I noticed there was no description in the commit log message, or PR description box. It would be helpful if the log message when this is eventually merged have a few more details about what the change accomplishes.

For example:

Resolve and replace all relative paths found in metadata tables with absolute
paths during upgrade. Absolute paths are resolved by prefixing relative paths
with a volume configured by the user in a new configuration property created
specifically for this purpose. If any relative paths are found and this property
is not configured, or if any resolved absolute path does not correspond to a
file that actually exists, the upgrade step fails and aborts without making changes.

if (!filePath.toString().contains(":")) {
// found relative paths so verify the property used to build the absolute paths
hasRelatives = true;
if (upgradeProperty == null || upgradeProperty.isBlank()) {
Copy link
Member

Choose a reason for hiding this comment

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

Will the upgradeProperty be normalized by the new Path code? If not, it might be useful to error out on things like having multiple // (except if it immediately follows the first :, as in hdfs://) or having any ../ present in the string. If Path normalizes this, then this is less important.

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 believe so... after this check, I create the path: Path absPath = new Path(upgradeProperty, relPath);

Copy link
Member

Choose a reason for hiding this comment

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

That might just do a simple concatenation with the appropriate file separator. It might not do normalization.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looking at the source, there is some normalization done by Path using the java URI object here. And as far as I can tell that source is the same as the source I downloaded for 3.1.2: http://archive.apache.org/dist/hadoop/common/hadoop-3.1.2/hadoop-3.1.2-src.tar.gz

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 also confirmed that extra intermediate / get removed by this normalization, with my last update adding an extra erroneously to one of the relative paths:
tables//1b/default_tablet/A000001c.rf becomes tables/1b/default_tablet/A000001c.rf

It won't hurt to add some erroneous paths to the unit test though, now that I have one.

Copy link
Member

Choose a reason for hiding this comment

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

It won't hurt to add some erroneous paths to the unit test though, now that I have one.

Agreed.

@milleruntime
Copy link
Contributor Author

I think this is ready to go

@milleruntime milleruntime merged commit ad10737 into apache:master Dec 20, 2019
2.1.0 automation moved this from In progress to Done Dec 20, 2019
@milleruntime milleruntime deleted the upgrade-relative branch December 20, 2019 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
2.1.0
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants