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

Allow way to check if instance is ready before starting agent #104

Closed
andyshinn opened this issue May 23, 2019 · 5 comments
Closed

Allow way to check if instance is ready before starting agent #104

andyshinn opened this issue May 23, 2019 · 5 comments

Comments

@andyshinn
Copy link

andyshinn commented May 23, 2019

I am doing some post-boot stuff with cloud-init and startup scripts to prepare my instance for Jenkins (mounting NVMe disks and post-boot Ansible playbook). I'm actually wanting to store Jenkins workspace data on the NVMe SSD for performance reasons which means I need to wait for this to complete before the plugin can copy and start the agent.jar.

In 3.0.0 I was able to hack around this by creating a custom /usr/local/bin/java script that was picked up when the instance installer first checked output of java -version. The wrapper script would artificially hang until the Ansible playbook had completed (to Jenkins it just appears that the command returns very slowly).

This issue is a feature request to have a way to wait for the instance to be ready via external method. The simple fix to enable the hack again is to just move the java -version check before the agent.jar copy. But I actually think longer term it might make sense to add a check for the cloud-init Final stage using cloud-init status --wait or the /var/lib/cloud/instance/boot-finished file. This would likely account for my scenario and others where people bootstrap instances using cloud-init where there might be stuff required before the agent can actually run jobs.

@stephenashank
Copy link
Contributor

Thanks for submitting this! I like the idea of waiting for cloud-init. In the meantime, I've created #105 to restore the previous functionality.

@andyshinn
Copy link
Author

Thanks!

A slight amendment to my initial research about cloud-init. I am actually using the google-startup-script unit and it runs after cloud-init (I assumed it would be part of cloud-init). Implementation details should take into account the startup-script service as well.

stephenashank pushed a commit that referenced this issue Jun 4, 2019
* Refactor to perform launch preparation in common method

* First check java version, then copy agent jar.

* PR feedback: Remove tight coupling by using abstract method instead.

* PR Feedback: Separate concerns for preparing java launch string.

* Make launch methods nearly identical by factoring out connection setup logic.

* Consolidate into one method on the ComputeEngineComputerLauncher.

* PR Feedback: De-duplicate logging methods, various cleanup of duplication and unused code.
@rachely3n
Copy link
Contributor

I've cut a release 3.3.0 that has #105 included. Please try it out and let us know how it goes.

@craigdbarber
Copy link
Contributor

Closing this with the release of 3.3.0. Please feel free to re-open if the issue persists.

@kishorviswanathan
Copy link

kishorviswanathan commented Jun 10, 2020

After one year, I am here looking for the exact same feature. Creating a custom image with java just for Jenkins agent is an overkill. So I ended up using the hack mentioned by @andyshinn by adding cloud-init status --wait in the wrapper script. It would be really helpful if the plugin could wait for the cloud-init completion before checking for Java.

Please reopen this issue.

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

No branches or pull requests

5 participants