Skip to content

Commit

Permalink
Fix exec not working for another region (#10539)
Browse files Browse the repository at this point in the history
This conditionally includes a region query parameter when
opening the exec socket.
  • Loading branch information
legege committed May 13, 2021
1 parent 7aa18b6 commit f75ceea
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ui/app/services/sockets.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import Service from '@ember/service';
import config from 'nomad-ui/config/environment';
import { getOwner } from '@ember/application';
import { inject as service } from '@ember/service';

export default class SocketsService extends Service {
@service system;

getTaskStateSocket(taskState, command) {
const mirageEnabled =
config.environment !== 'production' &&
Expand All @@ -27,10 +30,12 @@ export default class SocketsService extends Service {
const applicationAdapter = getOwner(this).lookup('adapter:application');
const prefix = `${applicationAdapter.host ||
window.location.host}/${applicationAdapter.urlPrefix()}`;
const region = this.system.activeRegion;

return new WebSocket(
`${protocol}//${prefix}/client/allocation/${taskState.allocation.id}` +
`/exec?task=${taskState.name}&tty=true&ws_handshake=true` +
(region ? `&region=${region}` : '') +
`&command=${encodeURIComponent(`["${command}"]`)}`
);
}
Expand Down

0 comments on commit f75ceea

Please sign in to comment.