Commit cfbc3c51 authored by Francesc Guasch's avatar Francesc Guasch
Browse files

refactor(ports); fixes when many created at once

parent fd9f9694
......@@ -2388,7 +2388,6 @@ sub _do_execute_command {
if ($err) {
my $user = $request->defined_arg('user');
if ($user) {
warn "sending message to ".$user->id." ".$user->name;
my $subject = $err;
my $message = '';
if (length($subject) > 40 ) {
......
......@@ -2290,14 +2290,21 @@ sub _add_expose($self, $internal_port, $name, $restricted) {
." VALUES (?,?,?,?,?)"
);
my $public_port = $self->_vm->_new_free_port();
$sth->execute($self->id
, $public_port, $internal_port
, ($name or undef)
, $restricted
);
$sth->finish;
my $public_port;
for (;;) {
eval {
$public_port = $self->_vm->_new_free_port();
$sth->execute($self->id
, $public_port, $internal_port
, ($name or undef)
, $restricted
);
$sth->finish;
};
last if !$@;
confess $@ if $@ && $@ !~ /Duplicate entry .*for key 'public/;
}
$self->_open_exposed_port($internal_port, $name, $restricted)
if $self->is_active && $self->ip;
......
Supports Markdown
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