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

Change the working directory in run script to APP_HOME if set #228

Merged
merged 11 commits into from Dec 11, 2018

Conversation

mcyprian
Copy link
Collaborator

#170 was not updated for quite some time, so I went through originally proposed changes and the discussion. I tried to make up something that resolves problem described in #166, doesn't break any of checks implemented in run script and simplify logic of the script. I would like to hear your opinion on this @GrahamDumpleton @pkubatrh.

@centos-ci
Copy link
Collaborator

Can one of the admins verify this patch?

@omron93
Copy link
Contributor

omron93 commented Nov 20, 2017

[test]

@centos-ci
Copy link
Collaborator

Can one of the admins verify this patch?

@mcyprian
Copy link
Collaborator Author

Rebased against master branch after merge of #234 .

@pkubatrh
Copy link
Member

[test]

2.7/s2i/bin/run Outdated
@@ -35,6 +35,13 @@ function get_default_web_concurrency() {
echo $default
}

APP_HOME=$(readlink -f ${APP_HOME:-.})
Copy link
Member

Choose a reason for hiding this comment

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

Double quotes needed around APP_HOME

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When trying this APP_HOME=$(readlink -f ${"APP_HOME":-.}) it ends up with an error bash: ${"APP_HOME":-.}: bad substitution, maybe I don't understand your point here correctly

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess APP_HOME=$(readlink -f "${APP_HOME:-.}")

@GrahamDumpleton
Copy link
Contributor

It will be after next week before I can look at this properly. I will be finally released then from major thing I had to get done and will have free time again. :-)

@mcyprian
Copy link
Collaborator Author

I rebased this PR to use templates after merge of #259. I am not sure if this change is necessary, but we should either finish the work here and merge it or close this PR and #170 as well. What do you think @pkubatrh?

@mcyprian
Copy link
Collaborator Author

[test-openshift]

src/s2i/bin/run Outdated
@@ -35,6 +35,13 @@ function get_default_web_concurrency() {
echo $default
}

APP_HOME=$(readlink -f ${APP_HOME:-.})
Copy link
Member

Choose a reason for hiding this comment

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

APP_HOME in the readlink call needs to be double-quoted to avoid word splitting

src/s2i/bin/run Outdated
if [[ -z "$APP_MODULE" && -f "./wsgi.py" ]]; then
APP_MODULE=wsgi
elif [[ -z "$APP_MODULE" && -f $setup_py ]]; then
APP_MODULE="$(python $setup_py --name)"
Copy link
Member

Choose a reason for hiding this comment

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

Same for $setup_py and HOME in this block.

@pkubatrh
Copy link
Member

Otherwise lgtm, I think its worth it to get this merged in.

@GrahamDumpleton
Copy link
Contributor

Can you wait until I have had another look before merging. I recollect that originally this change wasn't even doing things in the way that I had originally asked for and felt was required. I am on holidays right now, but will try and look later today or tomorrow.

@GrahamDumpleton
Copy link
Contributor

GrahamDumpleton commented Apr 30, 2018

For gunicorn case, does examples/app-home-test-app/project/__init__.py need to exist in the example for this test? The aim is that things should work without it if using method where cd into APP_HOME directory. Unless can explain why it needs to be there, should remove it to ensure that latest changes are not dependent on it existing, which wasn't what was desired.

For Django case, are there any possible risks with python manage.py collectstatic being run from top level directory with path to manage.py, rather than cd to APP_HOME to do it? When do python manage.py runserver, a cd is done. Am concerned that someone has written something to depend on the current working directory, with assumption that manage.py is always run from the directory where it is located. If use path to manage.py for collectstatic, the current working directory will be /app/app-root/src still and not APP_HOME.

@mcyprian
Copy link
Collaborator Author

[test][test-openshift]

@mcyprian
Copy link
Collaborator Author

Thanks for your comments @GrahamDumpleton. The examples/app-home-test-app/project/__init__.py doesn't need to exist, I removed it in 046fece.

I am not aware of any issues caused by python manage.py collectstatic being run from different location, but I added cd $APP_HOME (50ccd6d) to the run script as well to keep the two scripts aligned.

@rhscl-bot
Copy link

Can one of the admins verify this patch?

@pkubatrh
Copy link
Member

Rebased onto current master for latest bits

[test-openshift]

Since 'readlink -f' never returns '.' the check would always be true.
@pkubatrh
Copy link
Member

Removed the check for . since afaik readlink -f will never return ., otherwise lgtm.

@GrahamDumpleton @torsava Would either one of you guys have some spare time to review as well?

@omron93
Copy link
Contributor

omron93 commented Nov 27, 2018

[test-openshift]

2.7/s2i/bin/run Outdated Show resolved Hide resolved
3.4/s2i/bin/run Outdated Show resolved Hide resolved
@torsava
Copy link
Member

torsava commented Nov 27, 2018

I've pointed some things in the comments. Besides that it looks good!

@pkubatrh
Copy link
Member

New changes pushed

[test-openshift]

@pkubatrh
Copy link
Member

[test-openshift]

Copy link
Member

@torsava torsava left a comment

Choose a reason for hiding this comment

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

All issues I've had have been addressed, from my point of view it's ready for a merge. Thank you, @pkubatrh.

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

Successfully merging this pull request may close these issues.

None yet

7 participants