Quantcast

revert to esx snapshot in build step

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

revert to esx snapshot in build step

xterm-2
i am a first time poster and first time plugin creator. i am trying to create a plugin to revert an esx vm to a snapshot during the build step. I have everything working up to the point where i commit the launch but when i try and perform the 'setChannel' i get this:

runtimeexception: java.io.EOFException: unexpected stream termination

because of this line:

vsSlave.setChannel(new BufferedInputStream(System.in),
new BufferedOutputStream(System.out),
listener.getLogger(), null);

i guess i am not doing something right but i am not sure how to make it right. the documentation says to run setChannel after launch to let hudson/jenkins know of the etablished connection and to tie inputstream to slave.jar but im not sure how to do this.  i believe that if i do this correctly, the channel will be synced and i wont get the following error if this line is not included.
 
if i dont include the setchannel in the code, i get another run time exception: channelalreadyclosed exception.

--xterm
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: revert to esx snapshot in build step

Tom Rini-2
On Thu, Oct 18, 2012 at 07:45:15AM -0700, xterm wrote:

> i am a first time poster and first time plugin creator. i am trying to
> create a plugin to revert an esx vm to a snapshot during the build step. I
> have everything working up to the point where i commit the launch but when
> i try and perform the 'setChannel' i get this:

Have you seen the LabManager plugin?  This should be adaptable to to
VMwares more recent offerings and supports restoring to a snapshot as
part of the configuration for a given slave.

--
Tom
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: revert to esx snapshot in build step

xterm
This post has NOT been accepted by the mailing list yet.
In reply to this post by xterm-2
thanks tom,  i am not only doing this for my environment but as an exercise to understand jenkins and the plugin structure.  i feel that im very close and would like to get this working.

xterm
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: revert to esx snapshot in build step

xterm-2
In reply to this post by Tom Rini-2
thanks tom, i am trying to complete this for my environment and to try and learn
about the plugin structure.  i feel that im very close and would just like to complete it.

xterm

On Thu, Oct 18, 2012 at 11:24 AM, Tom Rini <[hidden email]> wrote:
On Thu, Oct 18, 2012 at 07:45:15AM -0700, xterm wrote:

> i am a first time poster and first time plugin creator. i am trying to
> create a plugin to revert an esx vm to a snapshot during the build step. I
> have everything working up to the point where i commit the launch but when
> i try and perform the 'setChannel' i get this:

Have you seen the LabManager plugin?  This should be adaptable to to
VMwares more recent offerings and supports restoring to a snapshot as
part of the configuration for a given slave.

--
Tom

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: revert to esx snapshot in build step

xterm-2
In reply to this post by xterm-2
well, as i see it, this is what i believe to be the problem:

1. the jenkins server and target start off with a channel (connection)
2. the channel is disconnected using:
2a. beforeDisconnect
2b. disonnect
2c. afterDisconnect
3. the vm is reverted to desired snapshot
4. the vm is powered on
5. waits for vmtools
6. islaunchsupported: launch
7. setChannel(in, out, tasklistener, channel.listener)
8.

FATAL: java.io.EOFException: unexpected stream termination
java.lang.RuntimeException: java.io.EOFException: unexpected stream termination
	at org.jenkinsci.plugins.vSphereBuilder.perform(vSphereBuilder.java:302)
	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:717)
	at hudson.model.Build$BuildExecution.build(Build.java:199)
	at hudson.model.Build$BuildExecution.doRun(Build.java:160)
	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:499)
	at hudson.model.Run.execute(Run.java:1502)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
	at hudson.model.ResourceController.execute(ResourceController.java:88)
	at hudson.model.Executor.run(Executor.java:236)
Caused by: java.io.EOFException: unexpected stream termination
	at hudson.remoting.ClassicCommandTransport.create(ClassicCommandTransport.java:100)
	at hudson.remoting.Channel.<init>(Channel.java:391)
	at hudson.remoting.Channel.<init>(Channel.java:387)
	at hudson.remoting.Channel.<init>(Channel.java:348)
	at hudson.remoting.Channel.<init>(Channel.java:344)
	at hudson.slaves.SlaveComputer.setChannel(SlaveComputer.java:316)
	at org.jenkinsci.plugins.vSphereBuilder.perform(vSphereBuilder.java:284)

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: revert to esx snapshot in build step

Tom Rini-2
On Thu, Oct 18, 2012 at 10:43:23AM -0700, xterm wrote:

> well, as i see it, this is what i believe to be the problem:
>
> 1. the jenkins server and target start off with a channel (connection)
> 2. the channel is disconnected using:
> 2a. beforeDisconnect
> 2b. disonnect
> 2c. afterDisconnect
> 3. the vm is reverted to desired snapshot
> 4. the vm is powered on
> 5. waits for vmtools
> 6. islaunchsupported: launch
> 7. setChannel(in, out, tasklistener, channel.listener)
> 8.

So the way I had worked with this problem is to have the VMs be
on-demand, so it went (since I had different groups, single VMs could be
used instead):
1. Jenkins says I want a 'buildhost-distroA-revert-on-boot' slave
2. Jenkins picks one of the VMs with that label, turns it on.
3. All VMs with that label are configured as revert-on-boot so that the
   first thing that happens is LabManger (esx under the hood) reverts to
   the snapshot and the second thing is it turns the VM on.
4. Jenkins connects with the slave

This is all off the top of my head and might differ slightly from
implementation, but it's the general idea behind it.

--
Tom
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: revert to esx snapshot in build step

xterm-2
In reply to this post by xterm-2
thanks tom, but i think the problem is that i am not running launch synchronously and thats why jenkins/hudson still thinks the channel is open and then tries to close it.

is there anyone out there that can point to an example that shows how to run launch synchronously?

thanks,

xterm

On Thursday, October 18, 2012 9:45:15 AM UTC-5, xterm wrote:
i am a first time poster and first time plugin creator. i am trying to create a plugin to revert an esx vm to a snapshot during the build step. I have everything working up to the point where i commit the launch but when i try and perform the 'setChannel' i get this:

runtimeexception: java.io.EOFException: unexpected stream termination

because of this line:

vsSlave.setChannel(new BufferedInputStream(System.in),
new BufferedOutputStream(System.out),
listener.getLogger(), null);

i guess i am not doing something right but i am not sure how to make it right. the documentation says to run setChannel after launch to let hudson/jenkins know of the etablished connection and to tie inputstream to slave.jar but im not sure how to do this.  i believe that if i do this correctly, the channel will be synced and i wont get the following error if this line is not included.
 
if i dont include the setchannel in the code, i get another run time exception: channelalreadyclosed exception.

--xterm
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: revert to esx snapshot in build step

xterm-2
In reply to this post by xterm-2
got it done finally....

just waiting to publish onto github

On Thursday, October 18, 2012 9:45:15 AM UTC-5, xterm wrote:
i am a first time poster and first time plugin creator. i am trying to create a plugin to revert an esx vm to a snapshot during the build step. I have everything working up to the point where i commit the launch but when i try and perform the 'setChannel' i get this:

runtimeexception: java.io.EOFException: unexpected stream termination

because of this line:

vsSlave.setChannel(new BufferedInputStream(System.in),
new BufferedOutputStream(System.out),
listener.getLogger(), null);

i guess i am not doing something right but i am not sure how to make it right. the documentation says to run setChannel after launch to let hudson/jenkins know of the etablished connection and to tie inputstream to slave.jar but im not sure how to do this.  i believe that if i do this correctly, the channel will be synced and i wont get the following error if this line is not included.
 
if i dont include the setchannel in the code, i get another run time exception: channelalreadyclosed exception.

--xterm
Loading...