Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
4.7 kB
2
Indexable
Never
Code
def collect_ams_engine_version_logs(self, instance_id, workflow_path):
        """
        Gather ams engine versions
        """
        credentials = self.get_pas_credentials(PAS_ADMIN_OPS_ROLE)
        cmds = self.get_rds_s3_file_transfer_template(
            credentials["AccessKeyId"], credentials["SecretAccessKey"]
        )

        cmds.append("sudo date > /tmp/engine_commit_id.log 2>&1")
        cmds.append(
            r'/rdsdbbin/oscar/bin/mysql -u rdsbmsperf -p auroraperf -e "SELECT aurora_version();" -prdsbmsperf | grep -P \'[\d.]+\' >> /tmp/engine_commit_id.log 2>&1'
        )
        cmds.append(r'MySQL_grep=$(/rdsdbbin/oscar/bin/mysqld --version | grep "git-head")')
        cmds.append(
            r'engine_internal_version=$(echo $MySQL_grep | grep -P "OscarMysql[\d]+-[\d.]+" -o)'
        )
        cmds.append(
            r'engine_build_time=$(echo $MySQL_grep | grep -P "\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}UTC" -o)'
        )
        cmds.append(r'engine_git_commit=$(echo $MySQL_grep | grep -P "[\w\d]{40}" -o -m1)')

        cmds.append(
            f'echo "engine_public_version: $(cat /tmp/engine_commit_id.log | grep -oP "[\d.]+")" >> /tmp/engine_commit_id.log'
        )
        cmds.append(
            f'echo "engine_internal_version: $engine_internal_version" >> /tmp/engine_commit_id.log'
        )
        cmds.append(f'echo "engine_build_time: $engine_build_time" >> /tmp/engine_commit_id.log')
        cmds.append(f'echo "engine_git_commit: $engine_git_commit" >> /tmp/engine_commit_id.log')

        cmds.append(
            "aws s3 cp /tmp/engine_commit_id.log "
            + f"{get_pas_logs_s3_dir_for_instance(workflow_path, instance_id[0].strip())}"
        )

        self.__ssm_client.run_cmd(
            instance_id[1],
            cmds,
        )

    def collect_kermit_logs(self, instance_id, workflow_path, test_start_timestamp):
        """
        Gather rds db diagnostics logs
        """
        credentials = self.get_pas_credentials(PAS_ADMIN_OPS_ROLE)
        cmds = self.get_rds_s3_file_transfer_template(
            credentials["AccessKeyId"], credentials["SecretAccessKey"]
        )

        cmds.append("export logfile=/rdsdbdata/tmp/gather-kermit-logs.log")
        cmds.append("sudo date > $logfile 2>&1")
        cmds.append('sudo echo "Copy gather-kermit-logs.sh to /tmp" >> $logfile 2>&1')
        cmds.append(
            "aws s3 cp "
            + f"{self.base_s3_location}/aurora-db-logs/gather-kermit-logs.sh /tmp "
            + ">> $logfile 2>&1"
        )
        cmds.append('sudo echo "Run gather-kermit-logs.sh" >> $logfile 2>&1')
        cmds.append("sudo chmod +x /tmp/gather-kermit-logs.sh >> $logfile 2>&1")

        if test_start_timestamp:
            test_start_timestamp = test_start_timestamp.strftime("%Y-%m-%d %H:%M:%S")
        cmds.append(
            "sudo bash /tmp/gather-kermit-logs.sh -z aurora-perf-analysis-rdsdbdiagnostic "
            + f"-t '{test_start_timestamp}' /rdsdbdiagnostic/engine-logs /rdsdbdiagnostic/hm-logs "
            + "/rdsdbdiagnostic/tmp /rdsdbdiagnostic/hm-logs /rdsdbdiagnostic/processed-core-dumps  >> $logfile 2>&1"
        )
        cmds.append(
            'sudo echo "Copy /tmp/aurora-perf-analysis-rdsdbdiagnostic.tar.gz to S3" >> $logfile 2>&1'
        )
        cmds.append(
            "aws s3 cp /tmp/aurora-perf-analysis-rdsdbdiagnostic.tar.gz "
            + f"{get_pas_logs_s3_dir_for_instance(workflow_path, instance_id[0].strip())} "
            + ">> $logfile 2>&1"
        )
        cmds.append(
            'sudo echo "Copy /tmp/aurora-perf-analysis-rdsdbdiagnostic.tar.gz to S3" >> $logfile 2>&1'
        )
        cmds.append("sleep 2")
        cmds.append(
            "aws s3 cp ${logfile} "
            + f"{get_pas_logs_s3_dir_for_instance(workflow_path, instance_id[0].strip())} "
            + ">> $logfile 2>&1"
        )
        self.__ssm_client.run_cmd(
            instance_id[1],
            cmds,
       )

Error
[CPython38-release] src/aurora_performance_data_service/helpers/log_utils/log_collection.py:236:13: F541 f-string is missing placeholders
[CPython38-release] src/aurora_performance_data_service/helpers/log_utils/log_collection.py:236:89: W605 invalid escape sequence '\d'
[CPython38-release] src/aurora_performance_data_service/helpers/log_utils/log_collection.py:239:13: F541 f-string is missing placeholders
[CPython38-release] src/aurora_performance_data_service/helpers/log_utils/log_collection.py:241:21: F541 f-string is missing placeholders
[CPython38-release] src/aurora_performance_data_service/helpers/log_utils/log_collection.py:242:21: F541 f-string is missing placeholders
Leave a Comment