redhat-developer / odo-init-image

ODO v3 no loner users this image!!! (Container for ODO v2 to setup SupervisorD inside S2I builder image.)
Apache License 2.0
7 stars 27 forks source link

Facilitate use of assemble script in assemble-and-restart.sh #3

Closed anmolbabu closed 5 years ago

anmolbabu commented 5 years ago

Autodetect path for assemble and run scripts

Odo hardcodes the S2I assemble script path in https://github.com/redhat-developer/odo-supervisord-image/blob/master/assemble-and-restart But the S2I docs suggest that the S2I scripts need to looked up in the following order:

  1. A script found at the --scripts-url URL
  2. A script found in the application source .s2i/bin directory
  3. A script found at the default image URL (io.openshift.s2i.scripts-url label) and ultimately giveup if not found in any of the above paths.

While, 1 is not relevant to us(builds triggered internally by odo), 2 is already done by odo, 3 is enhanced by this PR instead of using the currently(without this PR) hard-coded path

This PR uses the env vars passed by odo due to https://github.com/redhat-developer/odo/pull/924 for running assemble script.

Note: The S2I scripts suggest that the builder image might point to any of the following paths:

a. image://path_to_scripts_dir - absolute path inside the image b. file://path_to_scripts_dir - relative or absolute path on the host machine c. http(s)://path_to_scripts_dir - URL to a directory

Of these, the assemble-and-restart script is with this PR currently capable of handling image://path_to_scripts_dir but not file:// or http(s):// and they are expected to be added over time. At the moment for any of the file:// or http(s)://, the component create and/or update is expected to fail as it is expected to be even with latest master.

To test: Please refer https://github.com/redhat-developer/odo/pull/924 steps to test

fixes: redhat-developer/odo#869 Signed-off-by: anmolbabu anmolbudugutta@gmail.com

anmolbabu commented 5 years ago

ToDo(@anmolbabu):

If the current commit doesn't work, I'll switch it as per #869 (comment)

anmolbabu commented 5 years ago

This PR ideally needs to be merged subject to approval and merge of https://github.com/redhat-developer/odo/pull/924

cdrage commented 5 years ago

Left a review here! @anmolbabu https://github.com/redhat-developer/odo/pull/924

anmolbabu commented 5 years ago
[redhat@localhost redhat-developer]$ odo push -v 4
I1108 17:19:56.732319   17949 occlient.go:308] Trying to connect to server 192.168.42.181:8443
I1108 17:19:56.733421   17949 occlient.go:314] Server https://192.168.42.181:8443 is up
I1108 17:19:56.786527   17949 occlient.go:280] isLoggedIn err:  <nil> 
 output: "developer"
Pushing changes to component: sample-wildfly-xesg
I1108 17:19:56.789867   17949 occlient.go:2306] Getting DeploymentConfig: sample-wildfly-xesg-odo-wgvx
I1108 17:19:56.821915   17949 component.go:478] Source for component sample-wildfly-xesg is file:///home/redhat/git-srcs/src/github.com/redhat-developer/sample.war (binary)
I1108 17:19:56.825841   17949 push.go:83] Copying file /home/redhat/git-srcs/src/github.com/redhat-developer/sample.war to pod
I1108 17:19:56.863345   17949 occlient.go:1436] Waiting for deploymentconfig=sample-wildfly-xesg-odo-wgvx pod
I1108 17:19:56.878605   17949 occlient.go:1458] Status of sample-wildfly-xesg-odo-wgvx-1-h9lwg pod is Running
I1108 17:19:56.878730   17949 occlient.go:1461] Pod sample-wildfly-xesg-odo-wgvx-1-h9lwg is running.
I1108 17:19:56.878867   17949 component.go:345] Copying to pod sample-wildfly-xesg-odo-wgvx-1-h9lwg
Please wait, building component....
+ set -eo pipefail
+ '[' -f /opt/s2i/destination/.s2i/bin/assemble ']'
+ '[' -n /usr/libexec/s2i ']'
+ '[' /opt/s2i/destination '!=' /opt/app-root/src ']'
+ cp -a /opt/app-root/src/. /opt/s2i/destination
cp: preserving times for '/opt/s2i/destination/.': Operation not permitted
I1108 17:19:57.595677   17949 client.go:38] Error:
unable to execute assemble script: error while streaming command: command terminated with exit code 1
failed to push component: sample-wildfly-xesg

:(

geoand commented 5 years ago

@anmolbabu Please push all you changes and will check :)

anmolbabu commented 5 years ago

@anmolbabu Please push all you changes and will check :)

@geoand Got it now the issue was copying over .git files :) I was trying to remove it after copying all sources to s2i destination Fixed it now..

Works for wildfly The Pr is also updated to its latest form

geoand commented 5 years ago

:+1: I will test it shortly!

geoand commented 5 years ago

@anmolbabu openjdk, wildfly and nodejs worked for me :tada: :balloon:

anmolbabu commented 5 years ago

@anmolbabu openjdk, wildfly and nodejs worked for me

Yay !!

@metacosm @cdrage @kadel @mik-dass @surajnarwade @syamgk Please review

anmolbabu commented 5 years ago

@kadel @geoand @metacosm @cdrage Please review

There have a few changes since last review and they have been verified for: wildfly(binary+local), nodejs(local), openjdk(binary+local), python(local)

Cc: @surajnarwade @mik-dass @syamgk