You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: node_unplugger.rb
    path of file: ./repos/kontena/server/app/services/agent
    
    the code of the file until where you have to start completion: module Agent
  class NodeUnplugger
    include Logging

    attr_reader :node

    # @param [HostNode] node
    def initialize(node)
      @node = node
    end

    # @param [Time] connected_at
    # @param [Integer] code websocket close
    # @param [String] reason websocket close
    def unplug!(connected_at, code, reason)
      connection = @node.webs
    
    def update_node!(connected_at, **attrs)
      connected_node = HostNode.where(:id => node.id, :connected_at => connected_at)
        .find_one_and_update({:$set => attrs})

      fail "Node #{@node} has already re-connected at #{@node.connected_at}" unless connected_node

      node.reload # find_one_and_update does not update mongoid document attrs

      info "Disconnected node #{@node.to_path} connected at #{connected_at}"
    end

    def update_node_containers
      node.containers.unscoped.where(:container_type.ne => 'volume').set(:deleted_at => Time.now.utc)
    end

    def publish_update_event
      node.publish_update_event
    end
  end