Example #1
0
def commit_push_staged(pr_info: PRInfo):
    # It works ONLY for PRs, and only over ssh, so either
    # ROBOT_CLICKHOUSE_SSH_KEY should be set or ssh-agent should work
    assert pr_info.number
    if not pr_info.head_name == pr_info.base_name:
        # We can't push to forks, sorry folks
        return
    git_staged = git_runner("git diff --cached --name-only")
    if not git_staged:
        return
    remote_url = pr_info.event["pull_request"]["base"]["repo"]["ssh_url"]
    git_prefix = (  # All commits to remote are done as robot-clickhouse
        "git -c [email protected] "
        "-c user.name=robot-clickhouse -c commit.gpgsign=false "
        "-c core.sshCommand="
        "'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'"
    )
    git_runner(f"{git_prefix} commit -m 'Automatic style fix'")
    push_cmd = (
        f"{git_prefix} push {remote_url} head-{pr_info.head_ref}:{pr_info.head_ref}"
    )
    if os.getenv("ROBOT_CLICKHOUSE_SSH_KEY", ""):
        with SSHKey("ROBOT_CLICKHOUSE_SSH_KEY"):
            git_runner(push_cmd)
    else:
        git_runner(push_cmd)
Example #2
0
        os.makedirs(temp_path)

    docker_image = get_image_with_version(temp_path, "clickhouse/docs-release")

    test_output = os.path.join(temp_path, "docs_release_log")
    if not os.path.exists(test_output):
        os.makedirs(test_output)

    if args.as_root:
        user = "******"
    else:
        user = f"{os.geteuid()}:{os.getegid()}"

    run_log_path = os.path.join(test_output, "runlog.log")

    with SSHKey("ROBOT_CLICKHOUSE_SSH_KEY"):
        cmd = (
            f"docker run --cap-add=SYS_PTRACE --user={user} "
            f"--volume='{os.getenv('SSH_AUTH_SOCK', '')}:/ssh-agent' "
            f"--volume={repo_path}:/repo_path --volume={test_output}:/output_path "
            f"-e SSH_AUTH_SOCK=/ssh-agent -e EXTRA_BUILD_ARGS='--verbose' "
            f"-e CLOUDFLARE_TOKEN={CLOUDFLARE_TOKEN} {docker_image}")
        logging.info("Running command: %s", cmd)
        with TeePopen(cmd, run_log_path) as process:
            retcode = process.wait()
            if retcode == 0:
                logging.info("Run successfully")
                status = "success"
                description = "Released successfuly"
            else:
                description = "Release failed (non zero exit code)"
Example #3
0
        os.makedirs(temp_path)

    docker_image = get_image_with_version(temp_path, 'clickhouse/docs-release')

    test_output = os.path.join(temp_path, 'docs_release_log')
    if not os.path.exists(test_output):
        os.makedirs(test_output)

    token = os.getenv('CLOUDFLARE_TOKEN')
    cmd = "docker run --cap-add=SYS_PTRACE --volume=$SSH_AUTH_SOCK:/ssh-agent -e SSH_AUTH_SOCK=/ssh-agent " \
          f"-e CLOUDFLARE_TOKEN={token} --volume={repo_path}:/repo_path --volume={test_output}:/output_path {docker_image}"

    run_log_path = os.path.join(test_output, 'runlog.log')

    with open(run_log_path, 'w',
              encoding='utf-8') as log, SSHKey("ROBOT_CLICKHOUSE_SSH_KEY"):
        with subprocess.Popen(cmd, shell=True, stderr=log,
                              stdout=log) as process:
            retcode = process.wait()
            if retcode == 0:
                logging.info("Run successfully")
                status = "success"
                description = "Released successfuly"
            else:
                description = "Release failed (non zero exit code)"
                status = "failure"
                logging.info("Run failed")

    subprocess.check_call(f"sudo chown -R ubuntu:ubuntu {temp_path}",
                          shell=True)
    files = os.listdir(test_output)
Example #4
0
    # This check run separately from other checks because it requires exclusive
    # run (see .github/workflows/jepsen.yml) So we cannot add explicit
    # dependency on a build job and using busy loop on it's results. For the
    # same reason we are using latest docker image.
    build_url = f"https://s3.amazonaws.com/clickhouse-builds/{release_or_pr}/{pr_info.sha}/{build_name}/clickhouse"
    head = requests.head(build_url)
    counter = 0
    while head.status_code != 200:
        time.sleep(10)
        head = requests.head(build_url)
        counter += 1
        if counter >= 180:
            logging.warning("Cannot fetch build in 30 minutes, exiting")
            sys.exit(0)

    with SSHKey(key_value=get_parameter_from_ssm("jepsen_ssh_key") + "\n"):
        ssh_auth_sock = os.environ["SSH_AUTH_SOCK"]
        auth_sock_dir = os.path.dirname(ssh_auth_sock)
        cmd = get_run_command(
            ssh_auth_sock,
            auth_sock_dir,
            pr_info,
            nodes_path,
            REPO_COPY,
            build_url,
            result_path,
            docker_image,
        )
        logging.info("Going to run jepsen: %s", cmd)

        run_log_path = os.path.join(TEMP_PATH, "runlog.log")
Example #5
0
            time.sleep(i * 3)
            logging.info("Got execption pulling docker %s", ex)
    else:
        raise Exception(f"Cannot pull dockerhub for image {docker_image}")

    test_output = os.path.join(temp_path, 'docs_release_log')
    if not os.path.exists(test_output):
        os.makedirs(test_output)

    token = os.getenv('CLOUDFLARE_TOKEN')
    cmd = "docker run --cap-add=SYS_PTRACE --volume=$SSH_AUTH_SOCK:/ssh-agent -e SSH_AUTH_SOCK=/ssh-agent " \
          f"-e CLOUDFLARE_TOKEN={token} --volume={repo_path}:/repo_path --volume={test_output}:/output_path {docker_image}"

    run_log_path = os.path.join(test_output, 'runlog.log')

    with open(run_log_path, 'w', encoding='utf-8') as log, SSHKey("ROBOT_CLICKHOUSE_SSH_KEY"):
        with subprocess.Popen(cmd, shell=True, stderr=log, stdout=log) as process:
            retcode = process.wait()
            if retcode == 0:
                logging.info("Run successfully")
                status = "success"
                description = "Released successfuly"
            else:
                description = "Release failed (non zero exit code)"
                status = "failure"
                logging.info("Run failed")

    subprocess.check_call(f"sudo chown -R ubuntu:ubuntu {temp_path}", shell=True)
    files = os.listdir(test_output)
    lines = []
    additional_files = []
Example #6
0
    test_output = os.path.join(temp_path, "docs_release_log")
    if not os.path.exists(test_output):
        os.makedirs(test_output)

    token = CLOUDFLARE_TOKEN
    cmd = (
        "docker run --cap-add=SYS_PTRACE --volume=$SSH_AUTH_SOCK:/ssh-agent "
        f"-e SSH_AUTH_SOCK=/ssh-agent -e CLOUDFLARE_TOKEN={token} "
        f"-e EXTRA_BUILD_ARGS='--verbose' --volume={repo_path}:/repo_path"
        f" --volume={test_output}:/output_path {docker_image}"
    )

    run_log_path = os.path.join(test_output, "runlog.log")

    with open(run_log_path, "w", encoding="utf-8") as log, SSHKey(
        "ROBOT_CLICKHOUSE_SSH_KEY"
    ):
        with subprocess.Popen(cmd, shell=True, stderr=log, stdout=log) as process:
            retcode = process.wait()
            if retcode == 0:
                logging.info("Run successfully")
                status = "success"
                description = "Released successfuly"
            else:
                description = "Release failed (non zero exit code)"
                status = "failure"
                logging.info("Run failed")

    subprocess.check_call(f"sudo chown -R ubuntu:ubuntu {temp_path}", shell=True)
    files = os.listdir(test_output)
    lines = []