Beispiel #1
0
                                    ' 3h. Defaults to all logs.',
                                    default='12h')
        parser_sysdump.add_argument('--size-limit',
                                    type=int,
                                    help='size limit (bytes) for the '
                                    'collected logs',
                                    default=256 * 1024 * 1024)

    args = parser.parse_args()
    try:
        if args.sysdump:
            sysdump_dir_name = "./cilium-sysdump-{}"\
                .format(time.strftime("%Y%m%d-%H%M%S"))
            if not os.path.exists(sysdump_dir_name):
                os.makedirs(sysdump_dir_name)
            sysdumpcollector = sysdumpcollector.SysdumpCollector(
                sysdump_dir_name, args.since, args.size_limit)
            sysdumpcollector.collect()
            sys.exit(0)
    except AttributeError:
        pass
    nodes = utils.get_nodes()

    k8s_check_grp = utils.ModuleCheckGroup("k8s")
    k8s_check_grp.add(
        utils.ModuleCheck("check the kube-apiserver version",
                          lambda: k8schecks.check_kube_apiserver_version_cb()))
    k8s_check_grp.add(
        utils.ModuleCheck("check RBAC configuration",
                          lambda: k8schecks.check_rbac_cb()))
    if not k8s_check_grp.run():
        exit_code = 1
Beispiel #2
0
            ('Detected a large cluster (> 20) with {} nodes. Consider '
             'setting one or more of the following to decrease the size '
             'of the sysdump as many nodes will slow down the collection '
             'and increase the size of the resulting '
             'archive:\n').format(len(nodes)) +
            '  --nodes       (Nodes to collect from)          \n'
            '  --since       (How far back in time to collect)\n'
            '  --size-limit  (Size limit of Cilium logs)      \n')

        choice = prompt('Continue [y/N] (default is N)? ').strip().lower()
        if not choice or choice == 'n':
            sys.exit(0)

    try:
        sysdump_dir_name = './cilium-sysdump-{}'\
            .format(time.strftime('%Y%m%d-%H%M%S'))
        if not os.path.exists(sysdump_dir_name):
            os.makedirs(sysdump_dir_name)
        sysdumpcollector = sysdumpcollector.SysdumpCollector(
            sysdump_dir_name, args.since, args.size_limit, args.output,
            args.quick, args.cilium_labels, args.hubble_labels,
            args.hubble_relay_labels, args.hubble_ui_labels)
        sysdumpcollector.collect(args.nodes)
        sysdumpcollector.archive()
        sys.exit(0)
    except AttributeError:
        log.exception('Fatal error in collecting sysdump')
        sys.exit(1)

    sys.exit(0)
Beispiel #3
0
                                    type=distutils.util.strtobool,
                                    default="false",
                                    help='Enable quick mode. Logs and '
                                    'cilium bugtool output will'
                                    ' not be collected.'
                                    'Defaults to "false".')

    args = parser.parse_args()
    try:
        if args.sysdump:
            sysdump_dir_name = "./cilium-sysdump-{}"\
                .format(time.strftime("%Y%m%d-%H%M%S"))
            if not os.path.exists(sysdump_dir_name):
                os.makedirs(sysdump_dir_name)
            sysdumpcollector = sysdumpcollector.SysdumpCollector(
                sysdump_dir_name, args.since, args.size_limit, args.output,
                args.quick)
            sysdumpcollector.collect()
            sysdumpcollector.archive()
            sys.exit(0)
    except AttributeError as e:
        error_string = str(e)
        # This change makes sure we *only* ignore attribute
        # exceptions related to the args.sysdump workaround.
        if (error_string.find('sysdump') != -1):
            pass
        else:
            log.exception("Fatal error in collecting sysdump")
            sys.exit(1)
    nodes = utils.get_nodes()