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

Rockons: Invalid environment variable (...) #1588 #2885

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
14 changes: 12 additions & 2 deletions src/rockstor/storageadmin/static/storageadmin/js/views/rockons.js
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,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 All @@ -834,12 +838,18 @@ RockonInstallSummary = RockstorWizardPage.extend({

render: function() {
RockstorWizardPage.prototype.render.apply(this, arguments);
var container_env_map = {}
for (const [container, container_envs] of Object.entries(this.env_map)) {
for (const [env, value] of Object.entries(container_envs)) {
container_env_map[`${env}:container-id:${container}`] = value
}
}
this.$('#ph-summary-table').html(this.table_template({
share_map: this.share_map,
port_map: this.port_map,
cc_map: this.cc_map,
dev_map: this.dev_map,
env_map: this.env_map
env_map: container_env_map
}));
return this;
},
Expand Down
24 changes: 14 additions & 10 deletions src/rockstor/storageadmin/views/rockon_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ def _pending_check(request):
@transaction.atomic
def post(self, request, rid, command):
with self._handle_exception(request):

if not docker_status():
e_msg = "Docker service is not running. Start it and try again."
handle_exception(Exception(e_msg), request)
Expand Down Expand Up @@ -107,8 +106,12 @@ def post(self, request, rid, command):
dev_map = request.data.get("devices", {})
cc_map = request.data.get("cc", {})
env_map = request.data.get("environment", {})
logger.debug(
f"install request with share_map={share_map}, port_map={port_map}, dev_map={dev_map}, cc_map={cc_map}, env_map={env_map}"
)
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 @@ -175,15 +178,16 @@ 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 variable ({}).").format(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 ({}).").format(e)
handle_exception(Exception(e_msg), request)
ceo = DContainerEnv.objects.get(container=co, key=e)
ceo.val = env_map[co_id][e]
ceo.save()
task_result_handle = install(rockon.id)
rockon.taskid = task_result_handle.id
rockon.state = "pending_install"
Expand Down