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

Pre-init s2i extensibility #32

Closed
wants to merge 4 commits into from
Closed

Pre-init s2i extensibility #32

wants to merge 4 commits into from

Conversation

kosciCZ
Copy link
Contributor

@kosciCZ kosciCZ commented Oct 19, 2017

Hi,

This PR would add ability to execute user supplied scripts just before nginx start. This would fix #18, because it implements #19, and it would also fix #20.

All user has to do is place .sh scripts in ./nginx-pre-init/ folder, and these scripts will then be sourced right before nginx starts.

I have also modified permissions on config files, for when container is not running on user 1001 (as seen in tests)

This PR also includes test case for each version and modified test running script to be able to run more than one test.

I've separated changes into three commits for each version to track changes more transparently. Added functionality is the same in all of them, except for 1.8, where I decided to add option to extend the default server block, which I took from 1.10 & 1.12.

@centos-ci
Copy link
Collaborator

Can one of the admins verify this patch?

1 similar comment
@rhscl-bot
Copy link

Can one of the admins verify this patch?

@hhorak
Copy link
Member

hhorak commented Oct 19, 2017

[test]

@kosciCZ
Copy link
Contributor Author

kosciCZ commented Oct 19, 2017

Looks like I've made a mistake somewhere, will fix ASAP

@kosciCZ
Copy link
Contributor Author

kosciCZ commented Oct 19, 2017

@hhorak I have added a fix, could you please trigger the tests again?

@hhorak
Copy link
Member

hhorak commented Oct 19, 2017

[test]

@kosciCZ
Copy link
Contributor Author

kosciCZ commented Nov 2, 2017

ping, can someone please review this PR?

Copy link

@omron93 omron93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks very good. @kosciCZ Thank you for implementing s2i support for this image.

if [ -d ./nginx-pre-init ]; then
echo "---> Copying nginx pre-init scripts..."
if [ "$(ls -A ./nginx-pre-init/*)" ]; then
cp -v ./nginx-pre-init/* "${NGINX_APP_ROOT}/etc/nginx-pre-init"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why to move pre-init scripts there?

I'm not against it, maybe I'm missing something.
Otherwise /opt/app-root/src seems to me as better location that /opt/app-root/etc - the etc is misleading...
But generate_container_user and scl_enable are already in /opt/app-root/etc, so no big harm. But I vote for moving these scripts into NGINX_CONTAINER_SCRIPTS_PATH.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that makes more sense. I've used this location before, don't know why I chose something else here than NGINX_CONTAINER_SCRIPTS_PATH. Will change that

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed this in #41, since I'm not allowed to push to this branch.

cleanup_test_app
}

test_pre_init_script() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely +1 for passing app name as argument to functions. So be able to use these functions in more cases.

test_pre_init_script and test_application
test_connection_s2i and test_connection
are very similar. Only functions used for s2i app testing adds 1-2 lines of code.

I suggest:
1. remove cleanup_test_app from test_application and have to call it explicitly after testing of each app finished.
(2. rename test_application to test_application_basics)
3. when testing s2i app use same test_application and before calling cleanup_test_app do

test_command "cat /opt/app-root/etc/nginx.d/default.conf | grep 'resolver' | sed -e 's/resolver\(.*\);/\1/' | grep 'DNS_SERVER'" ""
check_result $? "pre-init-test-app"

test_for_output "http://$(container_ip):${test_port}/aliased/index2.html" "NGINX2 is working" 

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, will implement this. Just a note, it's the other way around, test_connection has one more line to test. But i got your point, and I'll fix my code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't changed this in #41, because I'd rather see using the test.lib.sh from common repo.

@rhscl-bot
Copy link

Can one of the admins verify this patch?

1 similar comment
@centos-ci
Copy link
Collaborator

Can one of the admins verify this patch?

@hhorak
Copy link
Member

hhorak commented Dec 16, 2017

I wanted to push changes into this PR directly, but it didn't work, so I opened a new PR #41, using most of the changes here, but also doing slightly more.

@hhorak
Copy link
Member

hhorak commented Jan 31, 2018

PR #41 was merged, closing this one. Anyway, thanks a lot for large portion of work, @kosciCZ.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants