Esempio n. 1
0
        def update_config(tf_config: TerraformConfig,
                          cluster_config: ClusterConfig,
                          operators=None):
            if tf_config is None:
                tf_config = TerraformConfig()
            if cluster_config is None:
                cluster_config = ClusterConfig()
            if operators is None:
                operators = parse_olm_operators_from_env()

            tf_config.worker_memory = resource_param(
                tf_config.worker_memory, OperatorResource.WORKER_MEMORY_KEY,
                operators)
            tf_config.master_memory = resource_param(
                tf_config.master_memory, OperatorResource.MASTER_MEMORY_KEY,
                operators)
            tf_config.worker_vcpu = resource_param(
                tf_config.worker_vcpu, OperatorResource.WORKER_VCPU_KEY,
                operators)
            tf_config.master_vcpu = resource_param(
                tf_config.master_vcpu, OperatorResource.MASTER_VCPU_KEY,
                operators)
            tf_config.workers_count = resource_param(
                tf_config.workers_count, OperatorResource.WORKER_COUNT_KEY,
                operators)
            tf_config.worker_disk = resource_param(
                tf_config.worker_disk, OperatorResource.WORKER_DISK_KEY,
                operators)
            tf_config.master_disk = resource_param(
                tf_config.master_disk, OperatorResource.MASTER_DISK_KEY,
                operators)
            tf_config.master_disk_count = resource_param(
                tf_config.master_disk_count,
                OperatorResource.MASTER_DISK_COUNT_KEY, operators)
            tf_config.worker_disk_count = resource_param(
                tf_config.worker_disk_count,
                OperatorResource.WORKER_DISK_COUNT_KEY, operators)

            tf_config.nodes_count = tf_config.masters_count + tf_config.workers_count
            cluster_config.olm_operators = [operators]
Esempio n. 2
0
    def start_install_and_wait_for_installed(self):
        cluster_name = self.config.day1_cluster_name
        # Running twice as a workaround for an issue with terraform not spawning a new node on first apply.
        for _ in range(2):
            with utils.file_lock_context():
                utils.run_command(
                    f"make _apply_terraform CLUSTER_NAME={cluster_name} PLATFORM={consts.Platforms.BARE_METAL}"
                )
        time.sleep(5)

        num_nodes_to_wait = self.config.day2_workers_count
        installed_status = consts.NodesStatus.DAY2_INSTALLED

        tfvars = utils.get_tfvars(self.config.tf_folder)
        tf_network_name = tfvars["libvirt_network_name"]

        config = TerraformConfig()
        config.nodes_count = num_nodes_to_wait
        libvirt_controller = LibvirtController(config=config,
                                               entity_config=ClusterConfig())
        libvirt_controller.wait_till_nodes_are_ready(
            network_name=tf_network_name)

        # Wait for day2 nodes
        waiting.wait(
            lambda: self.are_libvirt_nodes_in_cluster_hosts(),
            timeout_seconds=consts.NODES_REGISTERED_TIMEOUT,
            sleep_seconds=10,
            waiting_for="Nodes to be registered in inventory service",
        )
        self.set_nodes_hostnames_if_needed(tf_network_name)
        wait_till_all_hosts_are_in_status(
            client=self.api_client,
            cluster_id=self.config.cluster_id,
            nodes_count=self.config.day2_workers_count,
            statuses=[consts.NodesStatus.KNOWN],
            interval=30,
        )

        # Start day2 nodes installation
        log.info("Start installing all known nodes in the cluster %s",
                 self.config.cluster_id)
        kubeconfig = utils.get_kubeconfig_path(self.config.day1_cluster_name)
        ocp_ready_nodes = self.get_ocp_cluster_ready_nodes_num(kubeconfig)
        hosts = self.api_client.get_cluster_hosts(self.config.cluster_id)
        [
            self.api_client.install_day2_host(self.config.infra_env_id,
                                              host["id"]) for host in hosts
            if host["status"] == "known"
        ]

        log.info(
            "Waiting until all nodes of cluster %s have been installed (reached added-to-existing-cluster)",
            self.config.cluster_id,
        )
        wait_till_all_hosts_are_in_status(
            client=self.api_client,
            cluster_id=self.config.cluster_id,
            nodes_count=num_nodes_to_wait,
            statuses=[installed_status],
            interval=30,
        )

        log.info(
            "Waiting until installed nodes has actually been added to the OCP cluster"
        )
        waiting.wait(
            lambda: self.wait_nodes_join_ocp_cluster(
                ocp_ready_nodes, self.config.day2_workers_count, kubeconfig),
            timeout_seconds=consts.NODES_REGISTERED_TIMEOUT,
            sleep_seconds=30,
            waiting_for="Day2 nodes to be added to OCP cluster",
            expected_exceptions=Exception,
        )
        log.info("%d worker nodes were successfully added to OCP cluster",
                 self.config.day2_workers_count)