[PATCH][Wok] Issue #166: wok is pointing to /etc/nginx/conf.d which does not exists on OpenSuse 42.1

Create dir if not exist Signed-off-by: Ramon Medeiros <ramonn@linux.vnet.ibm.com> --- src/wok/proxy.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/wok/proxy.py b/src/wok/proxy.py index b68b86e..4b06fc2 100644 --- a/src/wok/proxy.py +++ b/src/wok/proxy.py @@ -116,6 +116,11 @@ def _create_proxy_config(options): # SSL certifications. if not paths.installed: dst = os.path.join(paths.sys_nginx_conf_dir, "wok.conf") + + # directoy does not exist: create it + if not os.path.exists(paths.sys_nginx_conf_dir): + os.makedirs(paths.sys_nginx_conf_dir) + if os.path.isfile(dst) or os.path.islink(dst): os.remove(dst) os.symlink(os.path.join(nginx_config_dir, "wok.conf"), dst) -- 2.5.5

Reviewed-By: Paulo Vital <pvital@linux.vnet.ibm.com> On Wed, 2016-09-21 at 14:58 -0300, Ramon Medeiros wrote:
Create dir if not exist
Signed-off-by: Ramon Medeiros <ramonn@linux.vnet.ibm.com> --- src/wok/proxy.py | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/src/wok/proxy.py b/src/wok/proxy.py index b68b86e..4b06fc2 100644 --- a/src/wok/proxy.py +++ b/src/wok/proxy.py @@ -116,6 +116,11 @@ def _create_proxy_config(options): # SSL certifications. if not paths.installed: dst = os.path.join(paths.sys_nginx_conf_dir, "wok.conf") + + # directoy does not exist: create it + if not os.path.exists(paths.sys_nginx_conf_dir): + os.makedirs(paths.sys_nginx_conf_dir) + if os.path.isfile(dst) or os.path.islink(dst): os.remove(dst) os.symlink(os.path.join(nginx_config_dir, "wok.conf"), dst)

Hi Ramon, On 09/21/2016 02:58 PM, Ramon Medeiros wrote:
Create dir if not exist
Is it the recommendation from nginx? I mean, this directory should be installed by nginx and if it is not maybe there is a better directory (already installed by nginx) to place configuration files. Also, doing that, the system will keep the directory on package removal.
Signed-off-by: Ramon Medeiros <ramonn@linux.vnet.ibm.com> --- src/wok/proxy.py | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/src/wok/proxy.py b/src/wok/proxy.py index b68b86e..4b06fc2 100644 --- a/src/wok/proxy.py +++ b/src/wok/proxy.py @@ -116,6 +116,11 @@ def _create_proxy_config(options): # SSL certifications. if not paths.installed: dst = os.path.join(paths.sys_nginx_conf_dir, "wok.conf") + + # directoy does not exist: create it + if not os.path.exists(paths.sys_nginx_conf_dir): + os.makedirs(paths.sys_nginx_conf_dir) + if os.path.isfile(dst) or os.path.islink(dst): os.remove(dst) os.symlink(os.path.join(nginx_config_dir, "wok.conf"), dst)

On 09/22/2016 09:00 AM, Aline Manera wrote:
Hi Ramon,
On 09/21/2016 02:58 PM, Ramon Medeiros wrote:
Create dir if not exist
Is it the recommendation from nginx? I mean, this directory should be installed by nginx and if it is not maybe there is a better directory (already installed by nginx) to place configuration files.
Also, doing that, the system will keep the directory on package removal. Nop,
just remove the rpm and the file is still there
Signed-off-by: Ramon Medeiros <ramonn@linux.vnet.ibm.com> --- src/wok/proxy.py | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/src/wok/proxy.py b/src/wok/proxy.py index b68b86e..4b06fc2 100644 --- a/src/wok/proxy.py +++ b/src/wok/proxy.py @@ -116,6 +116,11 @@ def _create_proxy_config(options): # SSL certifications. if not paths.installed: dst = os.path.join(paths.sys_nginx_conf_dir, "wok.conf") + + # directoy does not exist: create it + if not os.path.exists(paths.sys_nginx_conf_dir): + os.makedirs(paths.sys_nginx_conf_dir) + if os.path.isfile(dst) or os.path.islink(dst): os.remove(dst) os.symlink(os.path.join(nginx_config_dir, "wok.conf"), dst)
-- Ramon Nunes Medeiros Kimchi Developer Linux Technology Center Brazil IBM Systems & Technology Group Phone : +55 19 2132 7878 ramonn@br.ibm.com

On 09/26/2016 01:17 PM, Ramon Medeiros wrote:
On 09/22/2016 09:00 AM, Aline Manera wrote:
Hi Ramon,
On 09/21/2016 02:58 PM, Ramon Medeiros wrote:
Create dir if not exist
Is it the recommendation from nginx? I mean, this directory should be installed by nginx and if it is not maybe there is a better directory (already installed by nginx) to place configuration files.
Also, doing that, the system will keep the directory on package removal. Nop,
just remove the rpm and the file is still there
And we don't want it, right?
Signed-off-by: Ramon Medeiros <ramonn@linux.vnet.ibm.com> --- src/wok/proxy.py | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/src/wok/proxy.py b/src/wok/proxy.py index b68b86e..4b06fc2 100644 --- a/src/wok/proxy.py +++ b/src/wok/proxy.py @@ -116,6 +116,11 @@ def _create_proxy_config(options): # SSL certifications. if not paths.installed: dst = os.path.join(paths.sys_nginx_conf_dir, "wok.conf") + + # directoy does not exist: create it + if not os.path.exists(paths.sys_nginx_conf_dir): + os.makedirs(paths.sys_nginx_conf_dir) + if os.path.isfile(dst) or os.path.islink(dst): os.remove(dst) os.symlink(os.path.join(nginx_config_dir, "wok.conf"), dst)

I don't like this solution of adding the 'conf.d' dir if it doesn't exist. We shouldn't tamper with other packages dir structure. An acceptable solution would be to use the /etc/nginx/conf.d dir if it exists, otherwise use /etc/nginx . I also want to point out that this bug is preventing WoK from working at all in Opensuse 42.1. Hardcode freeze for the release is tomorrow. I advise to send a v2 and get it upstream ASAP On 09/27/2016 03:52 PM, Aline Manera wrote:
On 09/26/2016 01:17 PM, Ramon Medeiros wrote:
On 09/22/2016 09:00 AM, Aline Manera wrote:
Hi Ramon,
On 09/21/2016 02:58 PM, Ramon Medeiros wrote:
Create dir if not exist
Is it the recommendation from nginx? I mean, this directory should be installed by nginx and if it is not maybe there is a better directory (already installed by nginx) to place configuration files.
Also, doing that, the system will keep the directory on package removal. Nop,
just remove the rpm and the file is still there
And we don't want it, right?
Signed-off-by: Ramon Medeiros <ramonn@linux.vnet.ibm.com> --- src/wok/proxy.py | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/src/wok/proxy.py b/src/wok/proxy.py index b68b86e..4b06fc2 100644 --- a/src/wok/proxy.py +++ b/src/wok/proxy.py @@ -116,6 +116,11 @@ def _create_proxy_config(options): # SSL certifications. if not paths.installed: dst = os.path.join(paths.sys_nginx_conf_dir, "wok.conf") + + # directoy does not exist: create it + if not os.path.exists(paths.sys_nginx_conf_dir): + os.makedirs(paths.sys_nginx_conf_dir) + if os.path.isfile(dst) or os.path.islink(dst): os.remove(dst) os.symlink(os.path.join(nginx_config_dir, "wok.conf"), dst)
_______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel

It's not possible for just put wok.conf in /etc/nginx. There is not statement in nginx.conf that includes /etc/nginx/*conf files. We can do it, if we add this statement to nginx.conf. Here is the includes statement: ramonn@jarvis:/etc/nginx$ cat nginx.conf | grep include include /usr/share/nginx/modules/*.conf; include /etc/nginx/mime.types; # See http://nginx.org/en/docs/ngx_core_module.html#include include /etc/nginx/conf.d/*.conf; include /etc/nginx/default.d/*.conf; # include /etc/nginx/default.d/*.conf; My system (fedora 24) has conf.d and default.d, but opensuse does not have both. On 09/27/2016 04:24 PM, Daniel Henrique Barboza wrote:
I don't like this solution of adding the 'conf.d' dir if it doesn't exist. We shouldn't tamper with other packages dir structure.
An acceptable solution would be to use the /etc/nginx/conf.d dir if it exists, otherwise use /etc/nginx .
I also want to point out that this bug is preventing WoK from working at all in Opensuse 42.1. Hardcode freeze for the release is tomorrow. I advise to send a v2 and get it upstream ASAP
On 09/27/2016 03:52 PM, Aline Manera wrote:
On 09/26/2016 01:17 PM, Ramon Medeiros wrote:
On 09/22/2016 09:00 AM, Aline Manera wrote:
Hi Ramon,
On 09/21/2016 02:58 PM, Ramon Medeiros wrote:
Create dir if not exist
Is it the recommendation from nginx? I mean, this directory should be installed by nginx and if it is not maybe there is a better directory (already installed by nginx) to place configuration files.
Also, doing that, the system will keep the directory on package removal. Nop,
just remove the rpm and the file is still there
And we don't want it, right?
Signed-off-by: Ramon Medeiros <ramonn@linux.vnet.ibm.com> --- src/wok/proxy.py | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/src/wok/proxy.py b/src/wok/proxy.py index b68b86e..4b06fc2 100644 --- a/src/wok/proxy.py +++ b/src/wok/proxy.py @@ -116,6 +116,11 @@ def _create_proxy_config(options): # SSL certifications. if not paths.installed: dst = os.path.join(paths.sys_nginx_conf_dir, "wok.conf") + + # directoy does not exist: create it + if not os.path.exists(paths.sys_nginx_conf_dir): + os.makedirs(paths.sys_nginx_conf_dir) + if os.path.isfile(dst) or os.path.islink(dst): os.remove(dst) os.symlink(os.path.join(nginx_config_dir, "wok.conf"), dst)
_______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel
_______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel
-- Ramon Nunes Medeiros Kimchi Developer Linux Technology Center Brazil IBM Systems & Technology Group Phone : +55 19 2132 7878 ramonn@br.ibm.com

On 09/27/2016 03:52 PM, Aline Manera wrote:
On 09/26/2016 01:17 PM, Ramon Medeiros wrote:
On 09/22/2016 09:00 AM, Aline Manera wrote:
Hi Ramon,
On 09/21/2016 02:58 PM, Ramon Medeiros wrote:
Create dir if not exist
Is it the recommendation from nginx? I mean, this directory should be installed by nginx and if it is not maybe there is a better directory (already installed by nginx) to place configuration files.
Also, doing that, the system will keep the directory on package removal. Nop,
just remove the rpm and the file is still there
And we don't want it, right?
Well, at Fedora 24, removing the package, the conf.d directory persists: ramonn@jarvis:~$ sudo rpm -e nginx [sudo] password for ramonn: ramonn@jarvis:~$ ls -l /etc/nginx/ conf.d/ default.d/ mime.types mime.types.rpmnew ramonn@jarvis:~$ ls -l /etc/nginx/default.d/ total 0 ramonn@jarvis:~$ ls -l /etc/nginx/conf.d/ total 0 lrwxrwxrwx. 1 root root 44 Sep 28 10:37 wok.conf -> /home/ramonn/GitTrees/WOK/src/nginx/wok.conf
Signed-off-by: Ramon Medeiros <ramonn@linux.vnet.ibm.com> --- src/wok/proxy.py | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/src/wok/proxy.py b/src/wok/proxy.py index b68b86e..4b06fc2 100644 --- a/src/wok/proxy.py +++ b/src/wok/proxy.py @@ -116,6 +116,11 @@ def _create_proxy_config(options): # SSL certifications. if not paths.installed: dst = os.path.join(paths.sys_nginx_conf_dir, "wok.conf") + + # directoy does not exist: create it + if not os.path.exists(paths.sys_nginx_conf_dir): + os.makedirs(paths.sys_nginx_conf_dir) + if os.path.isfile(dst) or os.path.islink(dst): os.remove(dst) os.symlink(os.path.join(nginx_config_dir, "wok.conf"), dst)
-- Ramon Nunes Medeiros Kimchi Developer Linux Technology Center Brazil IBM Systems & Technology Group Phone : +55 19 2132 7878 ramonn@br.ibm.com

On 09/28/2016 10:43 AM, Ramon Medeiros wrote:
On 09/27/2016 03:52 PM, Aline Manera wrote:
On 09/26/2016 01:17 PM, Ramon Medeiros wrote:
On 09/22/2016 09:00 AM, Aline Manera wrote:
Hi Ramon,
On 09/21/2016 02:58 PM, Ramon Medeiros wrote:
Create dir if not exist
Is it the recommendation from nginx? I mean, this directory should be installed by nginx and if it is not maybe there is a better directory (already installed by nginx) to place configuration files.
Also, doing that, the system will keep the directory on package removal. Nop,
just remove the rpm and the file is still there
And we don't want it, right?
Well, at Fedora 24, removing the package, the conf.d directory persists:
ramonn@jarvis:~$ sudo rpm -e nginx [sudo] password for ramonn: ramonn@jarvis:~$ ls -l /etc/nginx/ conf.d/ default.d/ mime.types mime.types.rpmnew ramonn@jarvis:~$ ls -l /etc/nginx/default.d/ total 0 ramonn@jarvis:~$ ls -l /etc/nginx/conf.d/ total 0 lrwxrwxrwx. 1 root root 44 Sep 28 10:37 wok.conf -> /home/ramonn/GitTrees/WOK/src/nginx/wok.conf
I am saying the opposite. What happen when removing the wok package?
Signed-off-by: Ramon Medeiros <ramonn@linux.vnet.ibm.com> --- src/wok/proxy.py | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/src/wok/proxy.py b/src/wok/proxy.py index b68b86e..4b06fc2 100644 --- a/src/wok/proxy.py +++ b/src/wok/proxy.py @@ -116,6 +116,11 @@ def _create_proxy_config(options): # SSL certifications. if not paths.installed: dst = os.path.join(paths.sys_nginx_conf_dir, "wok.conf") + + # directoy does not exist: create it + if not os.path.exists(paths.sys_nginx_conf_dir): + os.makedirs(paths.sys_nginx_conf_dir) + if os.path.isfile(dst) or os.path.islink(dst): os.remove(dst) os.symlink(os.path.join(nginx_config_dir, "wok.conf"), dst)
--
Ramon Nunes Medeiros Kimchi Developer Linux Technology Center Brazil IBM Systems & Technology Group Phone : +55 19 2132 7878 ramonn@br.ibm.com

Ramon is right, nginx by default expects the conf files to be hosted @ conf.d dir, even in the Opensuse case where the dir isn't created by default. As he said in one of his answers, we either (1) create the conf.d dir or (2) change nginx.conf to add a new include line to get wok.conf from /etc/nginx. Both are undesirable but (1) is the most sane of them. Reviewed-by: Daniel Barboza <danielhb@linux.vnet.ibm.com> Tested-by: Daniel Barboza <danielhb@linux.vnet.ibm.com> On 09/21/2016 02:58 PM, Ramon Medeiros wrote:
Create dir if not exist
Signed-off-by: Ramon Medeiros <ramonn@linux.vnet.ibm.com> --- src/wok/proxy.py | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/src/wok/proxy.py b/src/wok/proxy.py index b68b86e..4b06fc2 100644 --- a/src/wok/proxy.py +++ b/src/wok/proxy.py @@ -116,6 +116,11 @@ def _create_proxy_config(options): # SSL certifications. if not paths.installed: dst = os.path.join(paths.sys_nginx_conf_dir, "wok.conf") + + # directoy does not exist: create it + if not os.path.exists(paths.sys_nginx_conf_dir): + os.makedirs(paths.sys_nginx_conf_dir) + if os.path.isfile(dst) or os.path.islink(dst): os.remove(dst) os.symlink(os.path.join(nginx_config_dir, "wok.conf"), dst)
participants (4)
-
Aline Manera
-
Daniel Henrique Barboza
-
Paulo Ricardo Paz Vital
-
Ramon Medeiros