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

[BEAM-357] fixing build on windows #496

Closed

Conversation

rmannibucau
Copy link
Contributor

Small fixes or workarounds for windows.

Main issues were:

  • Paths.get(...): windows has ":" which will make it failing, using new File(...).toPath() to fix it
  • Workaround for hadoop which requires winutils.exe on windows (see https://issues.apache.org/jira/browse/BEAM-357 for a comment on it)

@jbonofre
Copy link
Member

R: @jbonofre

@jbonofre
Copy link
Member

Starting the review.

@@ -60,6 +60,9 @@
<goals>
<goal>integration-test</goal>
</goals>
<configuration>
<ignoreEOLStyle>true</ignoreEOLStyle> <!-- for win -->
Copy link
Member

Choose a reason for hiding this comment

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

Can you remove the comment? Alternatively, please expand as to why it is needed, etc.

@davorbonaci
Copy link
Member

Hi Romain,
Welcome to Beam! I'm glad to see your contribution!

On a high level -- we really need to work well on Windows. Thanks for starting this effort. In fact, we need to add integration testing on Windows as soon as possible.

Code-wise, we need to find a different solution -- we cannot really download random, untrusted files and execute them on users' machine.

Again, thanks and welcome!

@rmannibucau
Copy link
Contributor Author

Hi Davor,

Updated the comments. Let me know if it is better or worse ;).

Changed a bit the downloading to add a sanity check (we could replace it by a checksum but the best would be to be able to use gpg --verify but seems bouncycastle doesn't fully match gpg format).

This repo is not really random since it is provided by an asf committer and I downgraded to a signed binary version. A maybe better alternative is to package a beam-hadoop-win jar with this exe and just explode it if running tests on windows - drawback is we put a binary in a jar, advantage is beam owns this binary.

wdyt?

@davorbonaci
Copy link
Member

This is definitely safer, but I feel we are still exposing a potentially unnecessary attack surface to our users.

Would you be able to summarize the problem on the Windows platform, and how does this binary solves it?

@rmannibucau
Copy link
Contributor Author

Sure, on windows hadoop relies for most commands (including chmods which are the first commands triggered in beam) on winutils.exe to actually execute the action (https://github.com/apache/hadoop/blob/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Shell.java#L224 for instance). It does find the winutils.exe from hadoop home which is ATM not set in beam. If you have locally hadoop with winutils.exe - not provided by ASF yet - and set the home properly then most of tests - excepted the one using Path but that's something else - should be fine but if you don't you need that workaround cause Shell of hadoop get winutils in a static block (https://github.com/apache/hadoop/blob/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Shell.java#L639) and it can be null. If null it will not remove the option but execute commands with a null entry in the array (processbuilder.execute([null, "chmod", ....])) which leads to a NPE.

Side note: if you are curious chmod is implemented like that https://github.com/apache/hadoop/blob/trunk/hadoop-common-project/hadoop-common/src/main/winutils/chmod.c with win API

We can also propose to hadoop a degraded mode where if winutils is not there and a "test" flag activated we try to do these operations in java and if it fails we ignore them when acceptable (chmod/chown should be ok to ignore for tests for instance). Didn't check if it would be doable for all winutils operations.

@davorbonaci
Copy link
Member

I think the alternative could be a better approach overall. In general, chmod is rarely needed on Windows and with minimal benefits in the testing environment.

There are others too -- tools like Cygwin, etc. provide many of these utilities. Finally, Microsoft announced Windows Subsystem for Linux (WSL) that enables the scenario too.

So, I think we could try with a degraded mode first. What do you think?

Separately, I have to kindly ask not to push commits to our repository, including creating a feature branch.

@rmannibucau
Copy link
Contributor Author

Yep, cygwin could be detected and surely enough.

Will try to find some time for it and finally change this PR for a hadoop upgrade + the few other fixes.

About the push: mea culpa, bad ctrl+R, deleted it just after.

@davorbonaci
Copy link
Member

(Also, feel free to separate into multiple PR. A good portion of this one can probably go in separately and is non-controversial. Of course, do as you see fit.)

@jbonofre
Copy link
Member

jbonofre commented Aug 8, 2016

Rebasing and checking ...

@davorbonaci
Copy link
Member

Should we close this if it is not active, and track it in JIRA instead, which can link back to the closed PR?

@rmannibucau
Copy link
Contributor Author

ok with me

@jbonofre
Copy link
Member

+1 to close

@asfbot
Copy link

asfbot commented Feb 27, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/beam_PreCommit_Java_MavenInstall/7896/

Build result: FAILURE

[...truncated 1.08 MB...] at hudson.remoting.UserRequest.perform(UserRequest.java:50) at hudson.remoting.Request$2.run(Request.java:336) at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)Caused by: org.apache.maven.plugin.MojoExecutionException: Archetype IT 'basic' failed: Execution failure: exit code = 1 at org.apache.maven.archetype.mojos.IntegrationTestMojo.execute(IntegrationTestMojo.java:269) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) ... 31 more2017-02-27T18:32:16.636 [ERROR] 2017-02-27T18:32:16.636 [ERROR] Re-run Maven using the -X switch to enable full debug logging.2017-02-27T18:32:16.637 [ERROR] 2017-02-27T18:32:16.637 [ERROR] For more information about the errors and possible solutions, please read the following articles:2017-02-27T18:32:16.637 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException2017-02-27T18:32:16.637 [ERROR] 2017-02-27T18:32:16.637 [ERROR] After correcting the problems, you can resume the build with the command2017-02-27T18:32:16.637 [ERROR] mvn -rf :beam-sdks-java-maven-archetypes-starterchannel stoppedSetting status of 460d21c to FAILURE with url https://builds.apache.org/job/beam_PreCommit_Java_MavenInstall/7896/ and message: 'Build finished. 'Using context: Jenkins: Maven clean install
--none--

@davorbonaci
Copy link
Member

@rmannibucau, can you close please then?

@rmannibucau
Copy link
Contributor Author

yep :)

@rmannibucau rmannibucau closed this Mar 9, 2017
Abacn pushed a commit to Abacn/beam that referenced this pull request Jan 31, 2023
johnjcasey pushed a commit to johnjcasey/beam that referenced this pull request Feb 8, 2023
pl04351820 pushed a commit to pl04351820/beam that referenced this pull request Dec 20, 2023
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.

None yet

4 participants