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

Fix "Invalid environment variabled" error for multi-container rockons with "environment" section #1688

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,11 @@ RockonEnvironment = RockonCustomChoice.extend({
}
var env_map = {};
var envars = this.custom_config.filter(function(cvar) {
env_map[cvar.get('key')] = this.$('#' + cvar.id).val();
co_id = cvar.get('container');
if(env_map[co_id] == undefined) {
env_map[co_id] = {};
}
env_map[co_id][cvar.get('key')] = this.$('#' + cvar.id).val();
return cvar;
}, this);
this.model.set('env_map', env_map);
Expand Down
18 changes: 10 additions & 8 deletions src/rockstor/storageadmin/views/rockon_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def post(self, request, rid, command):
env_map = request.data.get('environment', {})
containers = DContainer.objects.filter(rockon=rockon)
for co in containers:
co_id = str(co.id)
for sname in share_map.keys():
dest_dir = share_map[sname]
if (not Share.objects.filter(name=sname).exists()):
Expand Down Expand Up @@ -144,14 +145,15 @@ def post(self, request, rid, command):
cco = DCustomConfig.objects.get(rockon=rockon, key=c)
cco.val = cc_map[c]
cco.save()
for e in env_map.keys():
if (not DContainerEnv.objects.filter(
container=co, key=e).exists()):
e_msg = ('Invalid environment variabled(%s)' % e)
handle_exception(Exception(e_msg), request)
ceo = DContainerEnv.objects.get(container=co, key=e)
ceo.val = env_map[e]
ceo.save()
if (co_id in env_map):
for e in env_map[co_id].keys():
if (not DContainerEnv.objects.filter(
container=co, key=e).exists()):
e_msg = ('Invalid environment variable(%s)' % e)
handle_exception(Exception(e_msg), request)
ceo = DContainerEnv.objects.get(container=co, key=e)
ceo.val = env_map[co_id][e]
ceo.save()
install.async(rockon.id)
rockon.state = 'pending_install'
rockon.save()
Expand Down