-
Notifications
You must be signed in to change notification settings - Fork 242
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
preStart events support #4909
preStart events support #4909
Conversation
cb4efdd
to
1f0ae4b
Compare
/test v4.7-integration-e2e |
1f0ae4b
to
1ceb755
Compare
Verified as working > mkdir sample
cp -avrf ../odo/tests/examples/source/wildfly/* ./sample
> cd sample
> odo create --s2i wildfly wildfly
Validation
Warning: wildfly is not fully supported by odo, and it is not guaranteed to work
✓ Validating component [756ms]
Conversion
✓ Successfully generated devfile.yaml and env.yaml for provided S2I component
Please use `odo push` command to create the component with source deployed
> cat devfile.yaml
commands:
- exec:
commandLine: /opt/odo/bin/s2i-setup && /opt/odo/bin/assemble-and-restart
component: s2i-builder
group:
isDefault: true
kind: build
id: s2i-assemble
- exec:
commandLine: /opt/odo/bin/run
component: s2i-builder
group:
isDefault: true
kind: run
id: s2i-run
- exec:
commandLine: /opt/odo/bin/run
component: s2i-builder
group:
isDefault: true
kind: debug
id: s2i-debug
components:
- container:
endpoints:
- name: http-8080
targetPort: 8080
- name: http-8778
targetPort: 8778
env:
- name: DEBUG_PORT
value: "5858"
- name: ODO_S2I_SCRIPTS_URL
value: /usr/local/s2i
- name: ODO_S2I_SCRIPTS_PROTOCOL
value: image://
- name: ODO_S2I_SRC_BIN_PATH
value: /tmp
- name: ODO_S2I_DEPLOYMENT_DIR
value: /deployments
- name: ODO_S2I_WORKING_DIR
value: /home/jboss
- name: ODO_S2I_BUILDER_IMG
value: centos7/s2i-base-centos7
- name: ODO_SRC_BACKUP_DIR
value: /opt/app-root/src-backup
- name: ODO_S2I_CONVERTED_DEVFILE
value: "true"
image: docker.io/openshift/wildfly-100-centos7:latest
mountSources: true
sourceMapping: /tmp/projects
name: s2i-builder
metadata:
name: wildfly
version: 1.0.0
schemaVersion: 2.0.0
> ls
devfile.yaml pom.xml src
> vi devfile.yaml
> cat devfile.yaml
commands:
- exec:
commandLine: /opt/odo/bin/s2i-setup && /opt/odo/bin/assemble-and-restart
component: s2i-builder
group:
isDefault: true
kind: build
id: s2i-assemble
- exec:
commandLine: /opt/odo/bin/run
component: s2i-builder
group:
isDefault: true
kind: run
id: s2i-run
- exec:
commandLine: /opt/odo/bin/run
component: s2i-builder
group:
isDefault: true
kind: debug
id: s2i-debug
- apply:
component: copy-app-root-container
id: copy-app-root
events:
preStart:
- copy-app-root
components:
- container:
command:
- /bin/sh
- -c
- "cp -R /opt/app-root /mnt/"
image: docker.io/openshift/wildfly-100-centos7:latest
volumeMounts:
- name: app-root
path: /mnt/app-root
name: copy-app-root-container
- container:
endpoints:
- name: http-8778
targetPort: 8778
- name: http-8080
targetPort: 8080
env:
- name: DEBUG_PORT
value: "5858"
- name: ODO_S2I_SCRIPTS_URL
value: /usr/libexec/s2i
- name: ODO_S2I_SCRIPTS_PROTOCOL
value: image://
- name: ODO_S2I_SRC_BIN_PATH
value: /tmp
- name: ODO_S2I_DEPLOYMENT_DIR
value: /deployments
- name: ODO_S2I_WORKING_DIR
value: /home/jboss
- name: ODO_S2I_BUILDER_IMG
value: centos7/s2i-base-centos7
- name: ODO_SRC_BACKUP_DIR
value: /opt/app-root/src-backup
- name: ODO_S2I_CONVERTED_DEVFILE
value: "true"
image: docker.io/openshift/wildfly-100-centos7:latest
mountSources: true
sourceMapping: /tmp/projects
volumeMounts:
- name: app-root
path: /opt/app-root
name: s2i-builder
- name: app-root
volume:
size: 1Gi
metadata:
name: wildfly
version: 1.0.0
schemaVersion: 2.0.0
> oc new-project myproject
Now using project "myproject" on server "https://api.ci-ln-s3lnirb-f76d1.origin-ci-int-gce.dev.openshift.com:6443".
You can add applications to this project with the 'new-app' command. For example, try:
oc new-app centos/ruby-25-centos7~https://github.com/sclorg/ruby-ex.git
to build a new example application in Ruby.
> odo push
Validation
✓ Validating the devfile [241359ns]
Updating services
✓ Services and Links are in sync with the cluster, no changes are required
Creating Kubernetes resources for component wildfly
✓ Added storage app-root to wildfly
✓ Waiting for component to start [54s]
✓ Waiting for component to start [291ms]
Applying URL changes
✓ URL http-8778: http://http-8778-app-myproject.apps.ci-ln-s3lnirb-f76d1.origin-ci-int-gce.dev.openshift.com/ created
✓ URL http-8080: http://http-8080-app-myproject.apps.ci-ln-s3lnirb-f76d1.origin-ci-int-gce.dev.openshift.com/ created
Syncing to component wildfly
✓ Checking files for pushing [2ms]
✓ Syncing files to the component [6s]
Executing devfile commands for component wildfly
✓ Waiting for component to start [325ms]
✓ Executing s2i-assemble command "/opt/odo/bin/s2i-setup && /opt/odo/bin/assemble-and-restart" [2s]
✓ Executing s2i-run command "/opt/odo/bin/run" [3s]
Pushing devfile component "wildfly"
✓ Changes successfully pushed to component
> oc get deployments
NAME READY UP-TO-DATE AVAILABLE AGE
wildfly-app 1/1 1 1 104s
> oc describe deployment wildfly-app
...
Init Containers:
copy-app-root-container-copy-app-root-1:
Image: docker.io/openshift/wildfly-100-centos7:latest
Port: <none>
Host Port: <none>
Command:
/bin/sh
-c
cp -R /opt/app-root /mnt/
Environment:
PROJECTS_ROOT: /projects
PROJECT_SOURCE: /projects
Mounts:
/mnt/app-root from app-root-wildfly-app-vol (rw)
copy-supervisord:
Image: registry.access.redhat.com/ocp-tools-4/odo-init-container-rhel8:1.1.10
Port: <none>
Host Port: <none>
Command:
/usr/bin/cp
Args:
-r
/opt/odo-init/.
/opt/odo/
Environment: <none>
Mounts:
/opt/odo/ from odo-supervisord-shared-data (rw)
... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
/lgtm
if err != nil { | ||
return err | ||
} | ||
|
||
var initContainers []corev1.Container |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the fact that we have to do this speaks of a need for improvement on the library side. We should be able to fetch init containers and the remaining containers seperately.
Nice one though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, the devfile team has made a change on the library for this recently: devfile/library#108
a296af5
to
0531711
Compare
/test v4.7-integration-e2e |
/lgtm |
pkg/devfile/validate/events.go
Outdated
func validatePreStart(preStart []string) (err error) { | ||
// This is odo specific validation. There is still discussion about how PreStart should be implemented. | ||
// https://github.com/devfile/api/issues/204 | ||
// https://github.com/openshift/odo/issues/4187 | ||
// This is here to prevent anyone from using PreStart event until we have a proper implementation | ||
if len(preStart) != 0 { | ||
return &UnsupportedFieldError{fieldName: "preStart"} | ||
} | ||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this now, do we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are right, I removed the associated code
Kudos, SonarCloud Quality Gate passed!
|
/test psi-kubernetes-integration-e2e |
@feloy Do we need integration tests to test preStart event support? |
/test psi-kubernetes-integration-e2e |
It's not user facing at the moment. It's not possible to use any odo commands to set/unset |
/test psi-kubernetes-integration-e2e |
/approve |
[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:
Approvers can indicate their approval by writing |
/lgtm |
@feloy: The following test failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
/retest-required |
* preStart events support * Changelog * devfile/library with new getContainers * Fix unit test * Remove unnecessary validateEvents
What type of PR is this?
/kind feature
What does this PR do / why we need it:
Which issue(s) this PR fixes:
Fixes #4901
PR acceptance criteria:
Unit test
Integration test
Documentation
Update changelog
I have read the test guidelines
How to test changes / Special notes to the reviewer:
odo create --s2i wildfly wildfly
odo push