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

Changes required for devfile support #52

Closed rajivnathan closed 4 years ago

rajivnathan commented 4 years ago

This PR adds a devfile-supervisor.conf file and a devfile-command script that will be injected into devfile component containers that will be used to execute devfile commands. Supervisord will be started with devfile-supervisor.conf which in turn calls the devfile-command script. For more details on how devfile support will make use of supervisord see https://github.com/openshift/odo/issues/2654

The supervisord binary wasn't launching in alpine linux containers. Since devfile support is meant to also expand support to images beyond standard S2I-based images I've also updated the build options for the go-init and supervisord binaries.

I had to build the go binaries using the GOOS=linux GOARCH=amd64 CGO_ENABLED=0 options. See https://stackoverflow.com/questions/34729748/installed-go-binary-not-found-in-path-on-alpine-linux-docker for details

A note on commit 617658dc11311430ea0cea82dd4b88e68105c1ed:

We were seeing a problem where the devfile-command script was failing with an error:

k logs python-hello-world-5c4cc48687-fqdv5
time="2020-03-30T15:29:07Z" level=info msg="create process:devrun" 
time="2020-03-30T15:29:07Z" level=info msg="create process:devdebug" 
time="2020-03-30T15:29:12Z" level=debug msg="no auth required" 
time="2020-03-30T15:29:12Z" level=info msg="stop the program" program=devrun 
time="2020-03-30T15:29:12Z" level=info msg="stop the program" program=devdebug 
time="2020-03-30T15:29:12Z" level=info msg="force to kill the program" program=devdebug 
time="2020-03-30T15:29:12Z" level=info msg="force to kill the program" program=devrun 
time="2020-03-30T15:29:13Z" level=debug msg="no auth required" 
time="2020-03-30T15:29:13Z" level=debug msg="succeed to find process:devrun" 
time="2020-03-30T15:29:13Z" level=info msg="try to start program" program=devrun 
time="2020-03-30T15:29:13Z" level=info msg="success to start program" program=devrun 
ODO_COMMAND_RUN is python hello-world.py
Changing directory to ${CHE_PROJECTS_ROOT}/python-hello-world
/opt/odo/bin/devfile-command: 25: cd: can't cd to ${CHE_PROJECTS_ROOT}/python-hello-world
time="2020-03-30T15:29:14Z" level=debug msg="wait program exit" program=devrun 
time="2020-03-30T15:29:14Z" level=error msg="program stopped with error:exit status 2" program=devrun 
time="2020-03-30T15:29:14Z" level=info msg="Don't start the stopped program because its autorestart flag is false" program=devrun 

This was because the ODO_COMMAND_RUN_WORKING_DIR variable's value was ${CHE_PROJECTS_ROOT}/python-hello-world. The container has the variable set, however, when trying to execute cd $ODO_COMMAND_RUN_WORKING_DIR within the script the ${CHE_PROJECTS_ROOT} portion of the path was not being expanded. In order to work around it I had to wrap the command with sh -c and then ${CHE_PROJECTS_ROOT} was expanded to /projects correctly.

rajivnathan commented 4 years ago

@cdrage Looks like the test-cmd-service test failed. I saw an error due to RBAC:

[oc] Error from server (Forbidden): serviceinstances.servicecatalog.k8s.io is forbidden: User "developer" cannot list serviceinstances.servicecatalog.k8s.io in the namespace "ekilmcxklf": no RBAC policy matched

Is that something you'd be able to help with?

rajivnathan commented 4 years ago

/retest

openshift-ci-robot commented 4 years ago

@rajivnathan: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to [this](https://github.com/openshift/odo-init-image/pull/52#issuecomment-604635964): >/retest Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
cdrage commented 4 years ago

/ok-to-test

cdrage commented 4 years ago

@cdrage Looks like the test-cmd-service test failed. I saw an error due to RBAC:

[oc] Error from server (Forbidden): serviceinstances.servicecatalog.k8s.io is forbidden: User "developer" cannot list serviceinstances.servicecatalog.k8s.io in the namespace "ekilmcxklf": no RBAC policy matched

Is that something you'd be able to help with?

I think that's a flake. Just need to re-run it :)

kadel commented 4 years ago

@cdrage Looks like the test-cmd-service test failed. I saw an error due to RBAC:

[oc] Error from server (Forbidden): serviceinstances.servicecatalog.k8s.io is forbidden: User "developer" cannot list serviceinstances.servicecatalog.k8s.io in the namespace "ekilmcxklf": no RBAC policy matched

Is that something you'd be able to help with?

I think that's a flake. Just need to re-run it :)

it is probably related to this https://github.com/openshift/odo/pull/2767

rajivnathan commented 4 years ago

/retest

cdrage commented 4 years ago

/retest

kadel commented 4 years ago

/approve

openshift-ci-robot commented 4 years ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kadel

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/openshift/odo-init-image/blob/master/OWNERS)~~ [kadel] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
cdrage commented 4 years ago

/lgtm