コード例 #1
0
ファイル: sysstat.py プロジェクト: shekharberry/kubuculum
    def start(self):

        logger.info(f'{self.tag} start')

        # create directory for self
        util_functions.create_dir(self.params['dir'])

        # shortcuts
        namespace = self.params['namespace']
        podlabel = self.params['podlabel']

        templates_dir = self.dirpath + '/' + self.params['templates_dir']
        template_file = self.params['template_file']
        yaml_file = self.params['dir'] + '/' + self.params['yaml_file']

        util_functions.instantiate_template ( templates_dir, \
            template_file, yaml_file, self.params)

        logger.debug(f'{self.tag}: starting sysstat pods')
        # create the pods
        # expected count is unknown, use 0; so retries not relevant
        # pause of 10 sec
        # timeout of 300 sec; TODO: use a param here
        k8s_wrappers.createpods_sync (namespace, yaml_file, \
            podlabel, 0, 10, 0, 300)
        logger.debug(f'{self.tag}: pods ready')

        # get pod locations
        k8s_wrappers.get_podlocations (podlabel, namespace, \
            self.params['dir'])
コード例 #2
0
    def __init__(self, run_dir, params_dict, globals):

        # get directory pathname for module
        self.dirpath = os.path.dirname(os.path.abspath(__file__))

        # get a unique id and tag
        self.id = fio_iops.instance_counter
        self.tag = 'calm-fioiops-' + str(self.id)
        fio_iops.instance_counter += 1

        # load defaults from file
        yaml_file = self.dirpath + '/defaults.yaml'
        self.params = util_functions.dict_from_file(yaml_file)

        # update params; this will override some of the defaults
        labels_path = ['calm', 'fio_iops']
        new_params = util_functions.get_modparams(params_dict, labels_path)
        util_functions.deep_update(self.params, new_params)
        util_functions.update_modparams(self.params, globals)
        self.params['dir'] = run_dir + '/' + self.tag
        self.params['name'] = self.tag
        self.params['podlabel'] = "name=" + self.tag

        logger.debug(f'parameters: {self.params}')

        # create directory for self
        util_functions.create_dir(self.params['dir'])

        # create a handle for the fio server object
        #
        self.serverhandle = server_fio.server_fio \
            (self.params['dir'], params_dict, globals)

        #
        # derive parameters for fio server for later use
        #

        # pass on basic parameters
        self.serverparams = {
            'nservers': self.params['ninstances'],
            'fio_image': self.params['fio_image']
        }

        # derive space requirements
        if 'pvcsize_gb' in self.params:
            self.serverparams['pvcsize_gb'] = self.params['pvcsize_gb']
        else:
            pvcsize_gb = self.params['numjobs'] * self.params['filesize_gb']
            self.serverparams['pvcsize_gb'] = int (pvcsize_gb * \
                self.params['scalefactor'] + self.params['extraspace_gb'])

        # pass on storageclass, if specified
        if 'storageclass' in self.params:
            self.serverparams['storageclass'] = self.params['storageclass']

        # pass on nodeselector, if specified
        if 'server_nodeselector' in self.params:
            self.serverparams['nodeselector'] = \
                self.params['server_nodeselector']
コード例 #3
0
ファイル: fio_random.py プロジェクト: shekharberry/kubuculum
    def run(self):

        # will there be multiple iterations?
        num_iterations = len(self.params['bs_kb_list']) * \
            len(self.params['iodepth_list'])

        # rate_iops_list is optional
        if 'rate_iops_list' in self.params:
            num_inner = len(self.params['rate_iops_list'])
            num_iterations *= num_inner
        else:
            num_inner = 1

        logger.info(f'tests to be performed: {num_iterations}')

        iter = 0
        for bs_kb in self.params['bs_kb_list']:
            self.params['bs_kb'] = bs_kb
            bs_dirtag = 'bs_kb-' + str(bs_kb)

            for iodepth in self.params['iodepth_list']:
                self.params['iodepth'] = iodepth
                iod_dirtag = '_iodepth-' + str(iodepth)

                i_inner = 0
                while i_inner < num_inner:
                    if 'rate_iops_list' in self.params:
                        rate_iops = self.params['rate_iops_list'][i_inner]
                        self.params['rate_iops'] = rate_iops
                        run_dir = bs_dirtag + iod_dirtag \
                            + '_rate_iops-' + str (rate_iops)
                    else:
                        run_dir = bs_dirtag + iod_dirtag

                    if num_iterations > 1:
                        run_dirpath = self.params['dir'] + '/' + run_dir
                        util_functions.create_dir(run_dirpath)
                    else:
                        run_dirpath = self.params['dir']

                    logger.info(f'starting test : {iter}')
                    self._run(run_dirpath)
                    logger.info(f'completed test : {iter}')

                    iter += 1
                    i_inner += 1
                    if iter < num_iterations:
                        self._setup_next()

        logger.info(f'tests performed: {iter}')

        # gather info from server pods
        self.serverhandle.gather()

        logger.info(f'stopping server_fio pods')
        self.serverhandle.stop()
コード例 #4
0
ファイル: sysstat.py プロジェクト: shekharberry/kubuculum
    def gather(self, tag=""):

        # shortcuts
        namespace = self.params['namespace']
        podlabel = self.params['podlabel']

        if tag == "":
            gather_dir = self.params['dir']
        else:
            # TODO: gather_dir should not exist
            gather_dir = self.params['dir'] + tag
            util_functions.create_dir(gather_dir)

        # copy output from pod
        k8s_wrappers.copyfrompods (namespace, podlabel, \
            self.params['podoutdir'], gather_dir)
        logger.info(f'{self.tag} gather: copied output from sysstat pods')
コード例 #5
0
ファイル: fio_random.py プロジェクト: shekharberry/kubuculum
    def prepare(self):

        # shortcuts for commonly used parameters
        namespace = self.params['namespace']
        run_dir = self.params['dir']
        preparep_dir = run_dir + '/prepare_phase'
        podlabel = self.params['prep_podlabel']

        # create directory for prepare_phase output
        util_functions.create_dir(preparep_dir)

        # start the servers
        logger.info(f'starting server_fio pods')
        conn_params = self.serverhandle.start(self.serverparams)

        # update self.params with parameters required for server_fio
        util_functions.deep_update(self.params, conn_params)

        templates_dir = self.dirpath + '/' + self.params['templates_dir']
        template_file = self.params['prepare_template']
        yaml_file = run_dir + '/' + self.params['prepare_yaml']

        # create yaml for prepare phase
        util_functions.instantiate_template (templates_dir, \
            template_file, yaml_file, self.params)

        logger.info(f'creating prep pod')

        # create prep pod, and wait for its completion
        # expected pod count is 1, pause of 5 sec, 0 retries
        k8s_wrappers.createpods_sync (namespace, yaml_file, podlabel, \
            1, 5, 0, self.params['maxruntime_sec'])
        logger.info(f'prep pod completed')

        # copy output from pod
        k8s_wrappers.copyfrompods (namespace, podlabel, \
            self.params['podoutdir'], preparep_dir)
        logger.info(f'copied output from prep pod')

        # delete prep pod
        k8s_wrappers.deletefrom_yaml(yaml_file, namespace)
        logger.info(f'deleted prep pod')
コード例 #6
0
    def gather(self, tag=""):

        # shortcuts
        namespace = self.params['namespace']
        podlabel = self.params['podlabel']

        if tag == "":
            gather_dir = self.params['dir']
        else:
            # TODO: gather_dir should not exist
            gather_dir = self.params['dir'] + tag
            util_functions.create_dir(gather_dir)

        # form list of commands
        ls_command = 'ls -l' + ' ' + self.params['datadir']
        command_list = [(ls_command, 'ls_l.txt'), \
            ('df -h', 'df_h.txt'), ('mount', 'mount.txt')]

        # gather output of commands
        k8s_wrappers.command_tofile (command_list, podlabel, \
            namespace, gather_dir)
コード例 #7
0
    def start(self, passed_params):

        logger.debug(f'{self.tag} start')
        util_functions.deep_update(self.params, passed_params)
        logger.debug(f'{self.tag} parameters: {self.params}')

        # create directory for self
        util_functions.create_dir(self.params['dir'])

        # shortcuts
        namespace = self.params['namespace']
        podlabel = self.params['podlabel']

        templates_dir = self.dirpath + '/' + self.params['templates_dir']
        template_file = self.params['template_file']
        yaml_file = self.params['dir'] + '/' + self.params['yaml_file']

        util_functions.instantiate_template ( templates_dir, \
            template_file, yaml_file, self.params)

        logger.debug(f'starting {self.tag} pods')
        # create the pods
        # expected count is nservers
        # set retries to nservers with pause of 30 sec
        # timeout of 300 sec; TODO: use a param here
        k8s_wrappers.createpods_sync (namespace, yaml_file, podlabel, \
            self.params['nservers'], 30, self.params['nservers'], 300)
        logger.debug(f'{self.tag} pods ready')

        # get pod locations
        k8s_wrappers.get_podlocations (podlabel, namespace, \
            self.params['dir'])

        # TODO: use list of pods as returned by k8s
        # update returnparams with server list
        for inst in range(self.params['nservers']):
            new_elem = self.tag + '-' + str(inst) + '.' + self.tag
            self.returnparams['serverlist'].append(new_elem)

        return self.returnparams
コード例 #8
0
    def drop_caches(self):

        logger.debug(f'{self.tag}: drop_caches')

        # command for pods to execute
        self.params['command'] = "sync; sysctl vm.drop_caches=3"
        logger.debug(f'{self.tag} parameters: {self.params}')

        # drop_caches might be called multiple times on same object
        if self.drop_count == 0:
            # first call, create directory for self
            # TODO: dir present should not be an error
            util_functions.create_dir(self.params['dir'])

            templates_dir = self.dirpath + '/' + self.params['templates_dir']
            template_file = self.params['template_file']
            yaml_file = self.params['dir'] + '/' + self.params['yaml_file']

            util_functions.instantiate_template ( templates_dir, \
                template_file, yaml_file, self.params)
        else:
            yaml_file = self.params['dir'] + '/' + self.params['yaml_file']

        # create the pods
        # expected count is unknown, use 0; so retries not relevant
        # pause of 10 sec, retries 0
        # timeout of 300 sec; TODO: use a param here
        k8s_wrappers.createpods_sync (self.params['namespace'], \
            yaml_file, self.params['podlabel'], 0, 10, 0, 300)
        logger.debug(f'{self.tag}: pods ready')

        self.drop_count += 1

        # pods ready means task complete
        k8s_wrappers.deletefrom_yaml(yaml_file, self.params['namespace'])
        logger.info(f'{self.tag}: OS caches dropped')