Skip to content

[JENKINS-36997] CLI implementation of RemoteAgent#18

Merged
jglick merged 20 commits intojenkinsci:masterfrom
jglick:ExecRemoteAgent-JENKINS-36997
Feb 10, 2017
Merged

[JENKINS-36997] CLI implementation of RemoteAgent#18
jglick merged 20 commits intojenkinsci:masterfrom
jglick:ExecRemoteAgent-JENKINS-36997

Conversation

@jglick
Copy link
Member

@jglick jglick commented Feb 8, 2017

JENKINS-36997; trying to finish #17.

@reviewbybees

Mi-La and others added 10 commits November 21, 2016 11:01
…stalled on a slave.

Not working yet with keys protected by a passphrase.
OpenSSH 7.0 and greater disables use of ssh-dss public key algorithm.
To allow tests to run on system with OpenSSH 7.0, explicitly enable
ssh-dss by passing `-o HostKeyAlgorithms=+ssh-dss`.
Older OpenSSH implementations does not support the `...=+ssh-dss` syntax
to add a key alg (mind the `+`),
So use `...=ssh-dss` to make tests working also on pre-7.0 versions of
OpenSSH.

This is an amendment of commit 66bae3b.
…AgentServer would create.

Switching expectation to what ssh-agent, via ExecRemoteAgent, will create. From the man page:

FILES
     $TMPDIR/ssh-XXXXXXXXXX/agent.<ppid>
             UNIX-domain sockets used to contain the connection to the authen‐
             tication agent.  These sockets should only be readable by the
             owner.  The sockets should get automatically removed when the
             agent exits.
tw.writeMPInt(rpk.getModulus());
return new String(Base64.encode(tw.getBytes()));
}
if (pk instanceof DSAPublicKey) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Our tests use RSA, so there is no need to even check for this.

sshd.getProperties().put(SshServer.WELCOME_BANNER, "Welcome to the Mock SSH Server\n");
sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(new File(hostKey.getPath())));
SimpleGeneratorHostKeyProvider hostKeyProvider = new SimpleGeneratorHostKeyProvider(new File(hostKey.getPath()));
hostKeyProvider.setAlgorithm(/* TODO when upgrading sshd: KeyUtils.RSA_ALGORITHM */"RSA"); // http://stackoverflow.com/a/33692432/12916
Copy link
Member Author

Choose a reason for hiding this comment

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

Allow tests to run even with a newer ssh command connecting.

job.getBuildersList().add(shell);

r.assertLogContains("Permission denied (publickey).", r.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get()));
r.assertLogContains("Failed to run ssh-add", r.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get()));
Copy link
Member Author

Choose a reason for hiding this comment

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

Used to proceed with the block even when the passphrase was bad, which did not make much sense—better to fail at once.

* Stops the agent.
*/
void stop();
void stop() throws IOException, InterruptedException;
Copy link
Member Author

Choose a reason for hiding this comment

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

These methods may now be running remote commands, so they should be allowed to throw reasonable exceptions.

} finally {
purgeSockets();
}
purgeSockets();
Copy link
Member Author

Choose a reason for hiding this comment

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

Various updates related to exception handling from stop.

SystemCredentialsProvider.getInstance().save();

FreeStyleProject job = r.createFreeStyleProject();
job.setAssignedNode(r.createSlave());
Copy link
Member Author

Choose a reason for hiding this comment

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

Make sure the remote part works.

story.j.assertBuildStatusSuccess(story.j.waitForCompletion(b));

Pattern pattern = Pattern.compile("(?:SSH Agent (?:before|after) restart )/.+/ssh([0-9])+");
Pattern pattern = Pattern.compile("(?:SSH Agent (?:before|after) restart )/.+/ssh-.+/agent.(\\d)+");
Copy link
Member Author

Choose a reason for hiding this comment

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

Different socket path name patterns created by new implementation.

<jenkins.version>1.609.3</jenkins.version>
<java.level>7</java.level> <!-- sshd-core is 7+ -->
<workflow-jenkins-plugin.version>1.9</workflow-jenkins-plugin.version>
<workflow-jenkins-plugin.version>1.14.2</workflow-jenkins-plugin.version>
Copy link
Member Author

Choose a reason for hiding this comment

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

The latest compatible with 1.609.3.

Copy link
Member

@stephenc stephenc left a comment

Choose a reason for hiding this comment

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

🐝

@jglick
Copy link
Member Author

jglick commented Feb 10, 2017

@reviewbybees done

@jglick jglick merged commit 8d02c6c into jenkinsci:master Feb 10, 2017
@jglick jglick deleted the ExecRemoteAgent-JENKINS-36997 branch February 10, 2017 18:44
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