Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
1.4 kB
4
Indexable
Never
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'
    )

    # Corrected commands for engine_internal_version
    cmds.append(
        r'MySQL_grep=$(strings /rdsdbbin/oscar/bin/mysqld | grep '\''git-head'\'' -m1)'
    )
    cmds.append(
        r'engine_internal_version=$(echo $MySQL_grep | grep -oP '\''OscarMysql[\d]+-[\d.]+'\'' >> /tmp/engine_commit_id.log 2>&1)'
    )

    cmds.append(
        r"engine_build_time=$(echo $MySQL_grep | grep -oP '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}UTC' >> /tmp/engine_commit_id.log 2>&1)"
    )
    cmds.append(
        r"engine_git_commit=$(echo $MySQL_grep | grep -oP '[\w\d]{40}' -m1 >> /tmp/engine_commit_id.log 2>&1)"
    )

    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,
    )
Leave a Comment