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

InABox reactor crashes if it can't find a snapshot #123

Open
Davis-A opened this issue Mar 31, 2020 · 2 comments
Open

InABox reactor crashes if it can't find a snapshot #123

Davis-A opened this issue Mar 31, 2020 · 2 comments

Comments

@Davis-A
Copy link
Member

Davis-A commented Mar 31, 2020

This is running master with a small diff to the regex to force i failure to find a snapshot.

-        grep { $_->{name} =~ m/^fminabox-/ }
+        grep { $_->{name} =~ m/^zzfminabox-/ }                                                                                                                                                                                                                                          

User requests 'box create' and gets back

Creating box, this will take a minute or two.
My inabox reactor crashed while handling your message. Sorry!

Console output:

adavis@adavis-lenovo:~/src/box-version-Synergy$ carton exec perl bin/synergy -c /home/adavis/src/box-version-Synergy/config.json
LOG | listening on port 8118
LOG | registered /metrics
LOG | Connected to Slack!
LOG | Slack group conversations loaded
LOG | Slack dm channels loaded
LOG | Slack channels loaded
LOG | Users loaded
LOG | message event from slack/u:adavis: box create
LOG | Found SSH key: 24704070 (fminabox)
LOG | fminabox snapshot not found?!
LOG | error with box listener on inabox: Can't use an undefined value as a HASH reference at lib/Synergy/Reactor/InABox.pm line 131.

Code path enters the else branch then returns undef.

 if ($snapshot) {
        $Logger->log([ "Found snapshot: %s (%s)", $snapshot->{id}, $snapshot->{name} ]);
      }
      else {
        $Logger->log([ "fminabox snapshot not found?!" ]);
      }
      Future->done($snapshot);
    }

So then we try to get the id of undef. And never reach the check.

  my ($snapshot_id, $ssh_key_id) = Future->wait_all(
    $self->_get_snapshot,
    $self->_get_ssh_key,
  )->then(
    sub (@futures) {
      Future->done(map { $_->get->{id} } @futures)
    }
  )->get;

My thought is if we get a value back, it will have an id. We should put the check in the then that what we got back was defined and then get the id. I'm not sure what that looks like though.

@mmcclimon
Copy link
Contributor

Oh right, this is actually a problem with ->_get_snapshot, which can return undef. (It should probably fail the future instead.)

In the meantime, you can work around this (at least the crash) with this diff:

-      Future->done(map { $_->get->{id} } @futures)
+      Future->done(map { $_->get->{id} } grep { defined } @futures)

@Davis-A
Copy link
Member Author

Davis-A commented Apr 1, 2020

That crashes at that line if i can't find the snapshot.
LOG | error with box listener on inabox: Can't use an undefined value as a HASH reference at lib/Synergy/Reactor/InABox.pm line 131.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants