crowbar/crowbar-core

View on GitHub
crowbar_framework/app/models/api/upgrade.rb

Summary

Maintainability
F
2 wks
Test Coverage

File upgrade.rb has 1844 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "open3"

module Api
  class Upgrade < Tableless
    class << self
Severity: Major
Found in crowbar_framework/app/models/api/upgrade.rb - About 5 days to fix

Class Upgrade has 78 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Upgrade < Tableless
    class << self
      def timeouts
        ::Crowbar::UpgradeTimeouts.new.values
      end
Severity: Major
Found in crowbar_framework/app/models/api/upgrade.rb - About 1 day to fix

Method services has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
Open

      def services
        return unless cluster_health_check
        return unless check_schema_migrations
        return unless check_product_version
        begin
Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb - About 1 day to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method checks has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
Open

      def checks
        upgrade_status = ::Crowbar::UpgradeStatus.new
        upgrade_status.start_step(:prechecks)

        {}.tap do |ret|
Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb - About 1 day to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method services has 163 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def services
        return unless cluster_health_check
        return unless check_schema_migrations
        return unless check_product_version
        begin
Severity: Major
Found in crowbar_framework/app/models/api/upgrade.rb - About 6 hrs to fix

Method adminrepocheck has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

      def adminrepocheck
        upgrade_status = ::Crowbar::UpgradeStatus.new
        upgrade_status.start_step(:repocheck_crowbar)
        zypper_stream = Hash.from_xml(
          `sudo /usr/bin/zypper-retry --xmlout products`
Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb - About 5 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method adminrepocheck has 102 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def adminrepocheck
        upgrade_status = ::Crowbar::UpgradeStatus.new
        upgrade_status.start_step(:repocheck_crowbar)
        zypper_stream = Hash.from_xml(
          `sudo /usr/bin/zypper-retry --xmlout products`
Severity: Major
Found in crowbar_framework/app/models/api/upgrade.rb - About 4 hrs to fix

Method nodes has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

      def nodes(component = "all")
        status = ::Crowbar::UpgradeStatus.new

        if component == "postpone"
          status.postpone
Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb - About 3 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method upgradable_elements_of_proposals has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

      def upgradable_elements_of_proposals(proposals)
        to_upgrade = []

        # First find out the nodes with compute role, for later checks
        compute_nodes = {}
Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb - About 3 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method non_disruptive_upgrade_compute_nodes has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

      def non_disruptive_upgrade_compute_nodes(names)
        compute_nodes = names.map do |name|
          ::Node.find_node_by_name_or_alias(name)
        end

Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb - About 3 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method nodes has 91 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def nodes(component = "all")
        status = ::Crowbar::UpgradeStatus.new

        if component == "postpone"
          status.postpone
Severity: Major
Found in crowbar_framework/app/models/api/upgrade.rb - About 3 hrs to fix

Method checks has 91 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def checks
        upgrade_status = ::Crowbar::UpgradeStatus.new
        upgrade_status.start_step(:prechecks)

        {}.tap do |ret|
Severity: Major
Found in crowbar_framework/app/models/api/upgrade.rb - About 3 hrs to fix

Method parallel_upgrade_compute_nodes has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

      def parallel_upgrade_compute_nodes(compute_nodes, controller = nil)
        Rails.logger.info("Entering parallel upgrade of compute nodes, #{upgrade_mode} mode")
        Rails.logger.info("Nodes for upgrade: #{compute_nodes.map(&:name).join(', ')}")
        save_nodes_state(compute_nodes, "compute", "upgrading")
        save_node_action("upgrading the packages")
Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb - About 3 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method openstackbackup has 84 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def openstackbackup
        crowbar_lib_dir = "/var/lib/crowbar"
        dump_path = "#{crowbar_lib_dir}/backup/8-to-9-openstack_dump.sql.gz"
        if File.exist?(dump_path)
          Rails.logger.warn("OpenStack backup already exists. Skipping...")
Severity: Major
Found in crowbar_framework/app/models/api/upgrade.rb - About 3 hrs to fix

Method parallel_upgrade_compute_nodes has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def parallel_upgrade_compute_nodes(compute_nodes, controller = nil)
        Rails.logger.info("Entering parallel upgrade of compute nodes, #{upgrade_mode} mode")
        Rails.logger.info("Nodes for upgrade: #{compute_nodes.map(&:name).join(', ')}")
        save_nodes_state(compute_nodes, "compute", "upgrading")
        save_node_action("upgrading the packages")
Severity: Major
Found in crowbar_framework/app/models/api/upgrade.rb - About 2 hrs to fix

Method evacuate_network_node has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def evacuate_network_node(controller, network_node, delete_namespaces = false)
        save_node_action("evacuating dhcp networks")
        hostname = network_node["hostname"]
        migrated_file = "/var/lib/crowbar/upgrade/crowbar-network-evacuated"
        if network_node.file_exist? migrated_file
Severity: Major
Found in crowbar_framework/app/models/api/upgrade.rb - About 2 hrs to fix

Method openstackbackup has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

      def openstackbackup
        crowbar_lib_dir = "/var/lib/crowbar"
        dump_path = "#{crowbar_lib_dir}/backup/8-to-9-openstack_dump.sql.gz"
        if File.exist?(dump_path)
          Rails.logger.warn("OpenStack backup already exists. Skipping...")
Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb - About 2 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method ha_config_errors has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def ha_config_errors(check)
        ret = {}
        if check[:errors]
          ret[:ha_configured] = {
            data: check[:errors],
Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb - About 1 hr to fix

Method non_disruptive_upgrade_compute_nodes has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def non_disruptive_upgrade_compute_nodes(names)
        compute_nodes = names.map do |name|
          ::Node.find_node_by_name_or_alias(name)
        end

Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb - About 1 hr to fix

Method prepare_compute_nodes has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def prepare_compute_nodes(virt)
        Rails.logger.info("Preparing #{virt} compute nodes for upgrade... ")
        compute_nodes = ::Node.find("roles:nova-compute-#{virt}")
        if compute_nodes.empty?
          Rails.logger.info("There are no compute nodes of #{virt} type.")
Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb - About 1 hr to fix

Method run_online_migrations has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def run_online_migrations
        nova_nodes = ::Node.find("roles:nova-controller")
        heat_nodes = ::Node.find("roles:heat-server")
        return if nova_nodes.empty? && heat_nodes.empty?

Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method noderepocheck has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def noderepocheck
        upgrade_status = ::Crowbar::UpgradeStatus.new
        upgrade_status.start_step(:repocheck_nodes)

        response = {}
Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb - About 1 hr to fix

Method start_remote_resources has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def start_remote_resources(controller, hostname)
        save_node_action("starting services at remote node #{hostname}")
        out = controller.run_ssh_cmd(
          "crm --wait node ready remote-#{hostname}",
          "60s"
Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb - About 1 hr to fix

Method keystone_migrate_and_restart has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def keystone_migrate_and_restart(node)
        save_node_action("Making sure that Keystone is stopped on non-upgraded nodes")

        cluster = node[:pacemaker][:config][:environment]

Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb - About 1 hr to fix

Method execute_scripts_and_wait_for_finish has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def execute_scripts_and_wait_for_finish(nodes, script, seconds)
        nodes.each do |node|
          Rails.logger.info("Executing script '#{script}' at #{node.name}")
          ssh_status = node.ssh_cmd(script).first
          if ssh_status != 200
Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb - About 1 hr to fix

Method upgrade_first_cluster_node has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def upgrade_first_cluster_node(node, other_node)
        return true if node.upgraded?
        node_api = Api::Node.new node.name
        other_node_api = Api::Node.new other_node.name
        node_api.save_node_state("controller", "upgrading")
Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb - About 1 hr to fix

Method upgradable_elements_of_proposals has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def upgradable_elements_of_proposals(proposals)
        to_upgrade = []

        # First find out the nodes with compute role, for later checks
        compute_nodes = {}
Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb - About 1 hr to fix

Method delete_upgrade_scripts has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def delete_upgrade_scripts(node)
        return if node.admin?

        scripts_to_delete = [
          "prepare-repositories",
Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb - About 1 hr to fix

Method run_online_migrations has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def run_online_migrations
        nova_nodes = ::Node.find("roles:nova-controller")
        heat_nodes = ::Node.find("roles:heat-server")
        return if nova_nodes.empty? && heat_nodes.empty?

Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb - About 1 hr to fix

Method upgrade_controller_clusters has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def upgrade_controller_clusters
        ::Crowbar::UpgradeStatus.new.save_substep(:controller_nodes, :running)

        return upgrade_controllers_disruptive if upgrade_mode == :normal

Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb - About 1 hr to fix

Method execute_scripts_and_wait_for_finish has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def execute_scripts_and_wait_for_finish(nodes, script, seconds)
        nodes.each do |node|
          Rails.logger.info("Executing script '#{script}' at #{node.name}")
          ssh_status = node.ssh_cmd(script).first
          if ssh_status != 200
Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method upgrade_controllers_disruptive has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def upgrade_controllers_disruptive
        Rails.logger.info("Entering disruptive upgrade of controller nodes")

        # Go through all OpenStack barclamps ordered by run_order
        proposals = {}
Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method upgrade_controller_clusters has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def upgrade_controller_clusters
        ::Crowbar::UpgradeStatus.new.save_substep(:controller_nodes, :running)

        return upgrade_controllers_disruptive if upgrade_mode == :normal

Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method reload_nova_services has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def reload_nova_services
        nova_nodes = if upgrade_mode == :normal
          ::Node.find("roles:nova-controller")
        else
          ::Node.find("roles:nova-*").sort do |n|
Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb - About 45 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method evacuate_network_node has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def evacuate_network_node(controller, network_node, delete_namespaces = false)
        save_node_action("evacuating dhcp networks")
        hostname = network_node["hostname"]
        migrated_file = "/var/lib/crowbar/upgrade/crowbar-network-evacuated"
        if network_node.file_exist? migrated_file
Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb - About 45 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method stop_nova_services has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def stop_nova_services
        nova_nodes = if upgrade_mode == :normal
          ::Node.find("roles:nova-controller")
        else
          ::Node.find("roles:nova-*").sort do |n|
Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb - About 45 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method start_remote_resources has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def start_remote_resources(controller, hostname)
        save_node_action("starting services at remote node #{hostname}")
        out = controller.run_ssh_cmd(
          "crm --wait node ready remote-#{hostname}",
          "60s"
Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb - About 45 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method check_for_running_instances has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def check_for_running_instances
        controller = ::Node.find("run_list_map:nova-controller").first
        if controller.nil?
          Rails.logger.info("No nova-controller node found.")
          return
Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb - About 35 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method upgrade_nodes_disruptive has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def upgrade_nodes_disruptive(elements_to_upgrade)
        elements_to_upgrade.each do |element|
          # If role has a cluster assigned ugprade that cluster (reuse the non-disruptive code here)
          if ServiceObject.is_cluster?(element)
            cluster = ServiceObject.cluster_name element
Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb - About 35 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method node_status has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def node_status
        not_upgraded = []
        upgraded = []
        if ::Crowbar::UpgradeStatus.new.finished?
          upgraded = ::Node.all.reject(&:admin?).map(&:name)
Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb - About 35 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Avoid too many return statements within this method.
Open

          return
Severity: Major
Found in crowbar_framework/app/models/api/upgrade.rb - About 30 mins to fix

Avoid too many return statements within this method.
Open

          return
Severity: Major
Found in crowbar_framework/app/models/api/upgrade.rb - About 30 mins to fix

Avoid too many return statements within this method.
Open

          return
Severity: Major
Found in crowbar_framework/app/models/api/upgrade.rb - About 30 mins to fix

Avoid too many return statements within this method.
Open

          return
Severity: Major
Found in crowbar_framework/app/models/api/upgrade.rb - About 30 mins to fix

Avoid too many return statements within this method.
Open

          return
Severity: Major
Found in crowbar_framework/app/models/api/upgrade.rb - About 30 mins to fix

Method upgrade_compute_node has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def upgrade_compute_node(controller, node)
        return if node.upgraded?
        node_api = Api::Node.new node.name
        node_api.save_node_state("compute", "upgrading")
        hostname = node[:hostname]
Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method enable_compute_service has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def enable_compute_service(controller, node, only_enable = false)
        hostname = node[:hostname]
        controller.run_ssh_cmd(
          "source /root/.openrc; " \
          "openstack --insecure compute service set --enable #{hostname} nova-compute"
Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method unlock_crowbar_ui_package has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def unlock_crowbar_ui_package
        ui_unlock = run_cmd("sudo zypper-retry removelock 'crowbar-ui*'")
        unless ui_unlock[:exit_code].zero?
          raise_node_upgrade_error(
            "Removing crowbar-ui package lock has failed. " \
Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method upgrade_one_node has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def upgrade_one_node(name)
        node = ::Node.find_node_by_name_or_alias(name)
        return if node.upgraded?
        node_api = Api::Node.new name

Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method upgrade_compute_nodes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def upgrade_compute_nodes(virt)
        Rails.logger.info("Upgrading #{virt} compute nodes... ")
        compute_nodes = ::Node.find("roles:nova-compute-#{virt}")
        if compute_nodes.empty?
          Rails.logger.info("There are no compute nodes of #{virt} type.")
Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

        begin
          unless nova_node.nil?
            nova_node.wait_for_script_to_finish(
              "/usr/sbin/crowbar-delete-unknown-nova-services.sh",
              timeouts[:delete_nova_services]
Severity: Major
Found in crowbar_framework/app/models/api/upgrade.rb and 2 other locations - About 45 mins to fix
crowbar_framework/app/models/api/upgrade.rb on lines 541..560
crowbar_framework/app/models/api/upgrade.rb on lines 582..601

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 40.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

        begin
          unless monasca_node.nil?
            monasca_node.wait_for_script_to_finish(
              "/usr/sbin/crowbar-monasca-cleanups.sh",
              timeouts[:monasca_cleanups]
Severity: Major
Found in crowbar_framework/app/models/api/upgrade.rb and 2 other locations - About 45 mins to fix
crowbar_framework/app/models/api/upgrade.rb on lines 582..601
crowbar_framework/app/models/api/upgrade.rb on lines 603..622

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 40.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

        begin
          unless monasca_node.nil?
            monasca_node.wait_for_script_to_finish(
              "/usr/sbin/crowbar-dump-monasca-db.sh",
              timeouts[:dump_monasca_db]
Severity: Major
Found in crowbar_framework/app/models/api/upgrade.rb and 2 other locations - About 45 mins to fix
crowbar_framework/app/models/api/upgrade.rb on lines 541..560
crowbar_framework/app/models/api/upgrade.rb on lines 603..622

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 40.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      rescue ::Crowbar::Error::Upgrade::LiveMigrationError => e
        substep = ::Crowbar::UpgradeStatus.new.current_substep
        ::Crowbar::UpgradeStatus.new.save_substep(substep, :failed)
        ::Crowbar::UpgradeStatus.new.end_step(
          false,
Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb and 1 other location - About 30 mins to fix
crowbar_framework/app/models/api/upgrade.rb on lines 988..1024

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 32.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      rescue ::Crowbar::Error::Upgrade::NodeError => e
        substep = ::Crowbar::UpgradeStatus.new.current_substep
        ::Crowbar::UpgradeStatus.new.save_substep(substep, :failed)
        ::Crowbar::UpgradeStatus.new.end_step(
          false,
Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb and 1 other location - About 30 mins to fix
crowbar_framework/app/models/api/upgrade.rb on lines 998..1024

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 32.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

          "prepare-repositories",
          "upgrade-os",
          "shutdown-services-before-upgrade",
          "delete-cinder-services-before-upgrade",
          "dump-monasca-db",
Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.rb and 1 other location - About 15 mins to fix
chef/cookbooks/crowbar/recipes/default.rb on lines 53..79

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 26.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

There are no issues that match your filters.

Category
Status