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

Websocket proxy worker for HTM5 consoles #7078

Merged
merged 4 commits into from
Apr 7, 2016

Conversation

skateman
Copy link
Member

@skateman skateman commented Mar 3, 2016

Parent issue: #2451

List of changes:

  • Allow running of a rack application specified in RACK_APPLICATION with a web worker
  • Create a new WebsocketWorker running a dummy rack application on port 5000
  • Add an UI feature to control the number of the workers
  • Add a PROTOCOL option into the MiqApache::Conf class for loadbalancing websocket workers
  • Adjust the specs of the MiqApache module
  • Implement the WebSocket -> Socket proxy using the websocket-driver gem
  • Adjust the console access ticket generation for the new proxy
  • Change the URL in the noVNC & SPICE client settings
  • Add some new tests

@kbrock
Copy link
Member

kbrock commented Mar 11, 2016

If this is going to take a while to merge, Do you want to pull out the change in API that supports passing the protocol? (but we'd just pass 'http' everywhere)

@skateman skateman force-pushed the console-proxy-worker branch 6 times, most recently from f3347d3 to a7a2d17 Compare March 23, 2016 15:24
@skateman skateman force-pushed the console-proxy-worker branch 5 times, most recently from ff48981 to 85d7778 Compare March 31, 2016 07:22
@@ -0,0 +1,5 @@
class AddOpenedToConsoles < ActiveRecord::Migration[5.0]
def change
add_column :consoles, :opened, :boolean, :default => false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid default database values...prefer default_value_for in the model.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Fryguy fixed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this has never been merged, can you just collapse the two migrations together, to reduce the migration churn?

@skateman skateman force-pushed the console-proxy-worker branch 2 times, most recently from a9c112f to 27680ac Compare March 31, 2016 16:26
@@ -0,0 +1,16 @@
class Console < ApplicationRecord
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I like this class name as it can be confused with the Rails::Console. Not sure what a better name might be, though...RemoteConsole?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SystemConsole or ComputerSystemConsole?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SystemConsole sounds good to me

@skateman skateman changed the title [WIP] Websocket proxy worker for HTML8 consoles [WIP] Websocket proxy worker for HTM5 consoles Apr 4, 2016
@skateman skateman force-pushed the console-proxy-worker branch from 76aa935 to d21f697 Compare April 5, 2016 09:22
@skateman skateman changed the title [WIP] Websocket proxy worker for HTM5 consoles Websocket proxy worker for HTM5 consoles Apr 5, 2016
@chessbyte chessbyte removed the wip label Apr 5, 2016
@skateman skateman force-pushed the console-proxy-worker branch from d21f697 to ebbf3ea Compare April 6, 2016 11:30
@skateman skateman force-pushed the console-proxy-worker branch 2 times, most recently from 905ae81 to 957d2eb Compare April 6, 2016 12:52
Pairing = Struct.new(:is_ws, :proxy)

def initialize
@pairing = {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a concurrent hash for @pairing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kbrock nope, the read is guarded by the critical section of @sockets

@kbrock
Copy link
Member

kbrock commented Apr 6, 2016

This is a bit big for me to wrap my head around, but it looks good.

if (!host || !port || !password) {
spice_error(__("must set host, port and password"));
var secret = "#{@secret}";
var url = "#{@url}";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two probably need to be escaped...

@skateman skateman force-pushed the console-proxy-worker branch from 957d2eb to 5aec6be Compare April 7, 2016 12:50
@miq-bot
Copy link
Member

miq-bot commented Apr 7, 2016

<github_pr_commenter_batch />Some comments on commits skateman/manageiq@5ee925a~...5aec6be

@miq-bot
Copy link
Member

miq-bot commented Apr 7, 2016

Checked commits skateman/manageiq@5ee925a~...5aec6be with ruby 2.2.3, rubocop 0.37.2, and haml-lint 0.16.1
33 files checked, 23 offenses detected

app/controllers/api_controller/vms.rb

app/controllers/vm_common.rb

app/models/manageiq/providers/redhat/infra_manager/vm/remote_console.rb

  • 🔹 - Line 23, Col 5 - Metrics/AbcSize - Assignment Branch Condition size for remote_console_acquire_ticket is too high. [24.1/15]

app/models/manageiq/providers/vmware/infra_manager/vm/remote_console.rb

app/models/miq_server/role_management.rb

app/models/miq_ui_worker.rb

app/models/miq_web_service_worker.rb

app/models/miq_websocket_worker.rb

app/models/mixins/miq_web_server_worker_mixin.rb

gems/pending/spec/util/miq_apache/conf_spec.rb

gems/pending/util/miq_apache/miq_apache.rb

lib/websocket_proxy.rb

  • 🔹 - Line 4, Col 3 - Metrics/AbcSize - Assignment Branch Condition size for initialize is too high. [29.07/15]

lib/websocket_server.rb

  • 🔶 - Line 39, Col 7 - Performance/RedundantMerge - Use @pairing[ws] = Pairing.new(true, proxy); @pairing[sock] = Pairing.new(false, proxy) instead of @pairing.merge!(ws => Pairing.new(true, proxy), sock => Pairing.new(false, proxy)).
  • 🔹 - Line 4, Col 3 - Metrics/AbcSize - Assignment Branch Condition size for initialize is too high. [17.03/15]
  • 🔹 - Line 28, Col 3 - Metrics/AbcSize - Assignment Branch Condition size for call is too high. [18.28/15]

@martinpovolny
Copy link
Member

We should revisit how the API is defined and if it should remain as it is now. But that can be done in a separate PR.

@martinpovolny martinpovolny merged commit 318a31c into ManageIQ:master Apr 7, 2016
@martinpovolny martinpovolny added this to the Sprint 39 Ending Apr 18, 2016 milestone Apr 7, 2016
@skateman skateman deleted the console-proxy-worker branch April 7, 2016 14:00
@kbrock
Copy link
Member

kbrock commented Apr 8, 2016

yay!

context.cert = OpenSSL::X509::Certificate.new(File.open('certs/server.cer'))
context.key = OpenSSL::PKey::RSA.new(File.open('certs/server.cer.key'))
context.ssl_version = :SSLv23
context.verify_depth = OpenSSL::SSL::VERIFY_NONE
Copy link
Contributor

@cben cben May 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@skateman accidentally came across this line, I think it's assigning apples to oranges. perhaps you meant:

context.verify_mode = OpenSSL::SSL::VERIFY_NONE

verify_depth is an integer, limits length of chain: https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_verify_depth.html
VERIFY_NONE is conceptually an enum, one of the valid values for verify_mode. It happens to be the integer 0. But verify_depth = 0 doesn't even mean "always accept" nor "never accept", because the root trust anchor and the validated cert don't count towards the depth; AFAICT it means the arbitrary "verify but reject if there are any intermediate certs in the chain"...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I thought you were going to say "Let's please avoid VERIFY_NONE.

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

Successfully merging this pull request may close these issues.

10 participants