def METHOD_NAME(configFile:str, oldSampleFile:str, newSampleFile:str, unsafeAttributesFile:str, filetype:str):
    """
    Core logic for updating config files during upgrade using conf store.
    Following is algorithm from merge:
    Iterate over all parameters sample.new file
    for every parameter, check
    - if it is marked as 'unsafe' in attributes file, skip
    - if it marked as 'safe' in the attributes file
        - diff the value in config and sample.old - if it is changed, skip
        - if it is not changed,  we will overwrite the value in cfg file from sample.new
        - if it does not exist in cfg file add the value from sample.new file to cfg file
    - All the arrays in yaml are always overwritten
    """
    #If config file is not present then abort merging.
    if not os.path.isfile(configFile):
        logger.error(f'config file {configFile} does not exist')
        raise Exception(f'ERROR: config file {configFile} does not exist')
    logger.info(f'config file {str(configFile)} upgrade started.')
    # old sample file
    conf_old_sample = filetype + oldSampleFile
    cs_conf_old_sample = S3CortxConfStore(config=conf_old_sample, index=conf_old_sample)
    # new sample file
    conf_new_sample = filetype + newSampleFile
    cs_conf_new_sample = S3CortxConfStore(config=conf_new_sample, index=conf_new_sample)
    conf_new_sample_keys = cs_conf_new_sample.get_all_keys()
    # unsafe attribute file
    conf_unsafe_file = filetype + unsafeAttributesFile
    cs_conf_unsafe_file = S3CortxConfStore(config=conf_unsafe_file, index=conf_unsafe_file)
    conf_unsafe_file_keys = cs_conf_unsafe_file.get_all_keys()
    # active config file
    conf_file =  filetype + configFile
    cs_conf_file = S3CortxConfStore(config=conf_file, index=conf_file)
    conf_file_keys = cs_conf_file.get_all_keys()
    #logic to determine which keys to merge.
    keys_to_overwrite = []
    for key in conf_new_sample_keys:
        #If key is marked for unsafe then do not modify/overwrite.
        if key in conf_unsafe_file_keys:
            continue
        #if key not present active config file then add it
        # (this will also add and hence effectively overwrite keys removed in above [] handing
        # and hence will always result in overwrite for these keys from the new sample file).
        if key not in conf_file_keys:
            keys_to_overwrite.append(key)
        #if key is not unsafe and value is not changed by user then overwrite it.
        elif cs_conf_file.get_config(key) == cs_conf_old_sample.get_config(key):
            keys_to_overwrite.append(key)
        #if user has changed the value of the key then skip it.
        else:
            continue
    cs_conf_file.merge_config(source_index=conf_new_sample, keys_to_include=keys_to_overwrite)
    cs_conf_file.save_config()
    logger.info(f'config file {str(configFile)} upgrade completed')