示例#1
0
def main():
    args = handle_arguments()

    if args.sosreport:
        gather_sosreport_data(output_dir=args.dest)

    client = ClientFactory.create_client(
        url=args.inventory_url, timeout=CONNECTION_TIMEOUT, offline_token=get_env("OFFLINE_TOKEN")
    )
    if args.cluster_id:
        cluster = client.cluster_get(args.cluster_id)
        download_cluster_logs(
            client,
            json.loads(json.dumps(cluster.to_dict(), sort_keys=True, default=str)),
            args.dest,
            args.must_gather,
            args.update_by_events,
            pull_secret=args.pull_secret,
        )
    else:
        clusters = get_clusters(client, args.download_all)

        if not clusters:
            log.info("No clusters were found")
            return

        for cluster in clusters:
            if args.download_all or should_download_logs(cluster):
                download_cluster_logs(
                    client, cluster, args.dest, args.must_gather, args.update_by_events, pull_secret=args.pull_secret
                )

        log.info("Cluster installation statuses: %s", dict(Counter(cluster["status"] for cluster in clusters).items()))
def log_collection(vm_ip):
    etype, _value, _tb = sys.exc_info()

    logging.info(
        f"Collecting logs after a {('failed', 'successful')[etype is None]} installation"
    )

    try:
        logging.info("Gathering sosreport data from host...")
        gather_sosreport_data(output_dir=IBIP_DIR)
    except Exception:
        logging.exception("sosreport gathering failed!")

    utils.retry()
    try:
        logging.info("Gathering information via installer-gather...")
        utils.recreate_folder(INSTALLER_GATHER_DIR, force_recreate=True)
        installer_gather(ip=vm_ip,
                         ssh_key=consts.DEFAULT_SSH_PRIVATE_KEY_PATH,
                         out_dir=INSTALLER_GATHER_DIR)
    except Exception:
        logging.exception("installer-gather failed!")

    try:
        logging.info("Gathering information via must-gather...")
        utils.recreate_folder(MUST_GATHER_DIR)
        download_must_gather(KUBE_CONFIG, MUST_GATHER_DIR)
    except Exception:
        logging.exception("must-gather failed!")
示例#3
0
    def log_collection(self, master_ip: Optional[str]):
        """
        Collects all sorts of logs about the installation process

        @param master_ip The IP address of the master node. Used to SSH into the node when doing installer gather.
                         When not given, installer gather log collection is skipped.
        """
        etype, _value, _tb = sys.exc_info()

        log.info(
            f"Collecting logs after a {('failed', 'successful')[etype is None]} installation"
        )

        with SuppressAndLog(Exception):
            log.info("Gathering sosreport data from host...")
            gather_sosreport_data(output_dir=IBIP_DIR)

        if master_ip is not None:
            with SuppressAndLog(Exception):
                log.info("Gathering information via installer-gather...")
                utils.recreate_folder(INSTALLER_GATHER_DIR,
                                      force_recreate=True)
                self.installer_gather(
                    ip=master_ip,
                    ssh_key=consts.DEFAULT_SSH_PRIVATE_KEY_PATH,
                    out_dir=INSTALLER_GATHER_DIR)

        with SuppressAndLog(Exception):
            log.info("Gathering information via must-gather...")
            download_must_gather(KUBE_CONFIG, IBIP_DIR)