Commit 3a2c0961 authored by Levin Zimmermann's avatar Levin Zimmermann

stack/erp5: Fix NEO URL formatting for WCFS

The NEO/go commit kirr/neo@8c974485
changed the URL with which a NEO/go client can be loaded from

    // neo://name@master1,master2,...,masterN?options

to

    neo(s)://[credentials@]master1,master2,...,masterN/name?options

We need to apply this change in the NEO URL structure to instance-wcfs.cfg.in
to use WCFS with NEO storage.

Why?

The URL in instance-wcfs.cfg.in is finally send to wcfs binary, which
will open a NEO/go client with this URL via the "openClientByURL" function [1].
If the URL formatting instance-wcfs.cfg.in follows the old pattern,
NEO/go is unable to create a NEO/go client and may even raise an
exception [2], because information regarding NEO server is at the wrong
position of the URL.

[1] See https://lab.nexedi.com/kirr/neo/blob/87199da2b163c09ed3946b7ab9bb00a5b987d377/go/neo/client.go#L416-534
for openClientByURL.

[2] For instance when using the old pattern of putting the cluster name
in the "user" part, NEO/go will raise "credentials can be specified only
with neos:// scheme", because NEO/go reserves the "user" part for
encryption information,
see https://lab.nexedi.com/kirr/neo/blob/87199da2b163c09ed3946b7ab9bb00a5b987d377/go/neo/client.go#L449
parent d28403ac
...@@ -102,4 +102,4 @@ md5sum = 5cf0316fdd17a940031e4083bbededd8 ...@@ -102,4 +102,4 @@ md5sum = 5cf0316fdd17a940031e4083bbededd8
[instance-wcfs.cfg.in] [instance-wcfs.cfg.in]
filename = instance-wcfs.cfg.in filename = instance-wcfs.cfg.in
md5sum = eb4be2669a9a56187cc4366272e11d18 md5sum = 629b9263eed3ad4fbe9f6716f90f8d43
...@@ -12,15 +12,19 @@ ...@@ -12,15 +12,19 @@
{% if zodb['type'] == 'zeo' -%} {% if zodb['type'] == 'zeo' -%}
{% set zurl = ('zeo://%s?storage=%s' % (z['server'], z['storage'])) -%} {% set zurl = ('zeo://%s?storage=%s' % (z['server'], z['storage'])) -%}
{% elif zodb['type'] == 'neo' -%} {% elif zodb['type'] == 'neo' -%}
{% set zurl = ('neo://%s@%s' % (z.pop('name'), z.pop('master_nodes'))) -%} {# See https://lab.nexedi.com/kirr/neo/blob/87199da2b163c09ed3946b7ab9bb00a5b987d377/go/neo/client.go#L417 #}
{% set argv = [] -%} {# for correct URL format. #}
{% set i = 0 -%} {% if z.pop("ssl", false) -%}
{% for k,v in z|dictsort -%} {# See https://lab.nexedi.com/kirr/neo/blob/87199da2b163c09ed3946b7ab9bb00a5b987d377/go/neo/client.go#L428 #}
{% do argv.append('%s=%s' % (k,v)) -%} {% for encryption_file_path_key in ("ca", "cert", "key") -%}
{% endfor -%} {% do z.update({encryption_file_path_key: z[encryption_file_path_key] | urlencode | replace("/", "%2F")}) -%}
{% if len(argv) > 0 -%} {% endfor -%}
{% set zurl = zurl + '&' + '?'.join(argv) -%} {% set zurl = 'neos://ca=%s;cert=%s;key=%s@' % (z.pop("ca"), z.pop("cert"), z.pop("key")) -%}
{% else -%}
{% set zurl = 'neo://' -%}
{% endif -%} {% endif -%}
{% set zurl = ('%s%s/%s' % (zurl, z.pop('master_nodes'), z.pop('name'))) -%}
{% set zurl = zurl + '?' + (z | urlencode) -%}
{% else -%} {% else -%}
{% do assert(False, ("unsupported ZODB type", zodb)) -%} {% do assert(False, ("unsupported ZODB type", zodb)) -%}
{% endif -%} {% endif -%}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment