Beispiel #1
0
def send_health_check_error_message(request, enable):
    weblink = "deploy.pinadmin.com/groups/webapp/config/"
    if enable:
        message = "Failed to enable health check for auto scaling group webapp. Please manually enable it: <{}|here>".format(weblink)
    else:
        message = "Failed to disable health check for auto scaling group webapp. Please manually disable it: <{}|here>".format(weblink)
    systems_helper.send_chat_message(request, "system", "autoscaling", message)
Beispiel #2
0
def sendStartMessage(request, user, envName, stageName, notifyAuthor):
    env = environs_helper.get_env_by_stage(request, envName, stageName)
    deploy = deploys_helper.get(request, env['deployId'])
    build = builds_helper.get_build(request, deploy['buildId'])
    branch = build['branch']
    Ngapp2DeployUtils().reset_finish_message_flag(stageName)
    message = "{}/{}: deploy of {}/{} started. See details <{}|here>.".format(
        envName, stageName, branch, build['commitShort'], get_deploy_url(envName, stageName))
    systems_helper.send_chat_message(request, user.name, get_slack_channel(), message)

    if not notifyAuthor:
        return

    author_msg = get_notify_authors_message(request, env, build)
    if author_msg and is_prod():
        systems_helper.send_chat_message(request, user.name, get_slack_channel(), author_msg)
    elif author_msg:
        logger.info("get author list message:{}".format(author_msg))
Beispiel #3
0
def sendFinishMessage(request, user, envName, stageName, state):
    ngapp2DeployUtils = Ngapp2DeployUtils()

    # if we've already sent the message
    if ngapp2DeployUtils.get_finish_message_flag(stageName) == "True":
        return
    env = environs_helper.get_env_by_stage(request, envName, stageName)
    deploy = deploys_helper.get(request, env['deployId'])
    build = builds_helper.get_build(request, deploy['buildId'])
    branch = build['branch']
    commit = build['commit']
    weblink = get_deploy_url(envName, stageName)
    state = state.lower()
    if state == "succeeding" or state == "done":
        template = "{}/{}: deploy of {}/{} completed successfully. See details <{}|here>"
    else:
        template = "{}/{}: deploy of {}/{} failed. See details <{}|here>"
    message = template.format(envName, stageName, branch, commit[:7], weblink)
    ngapp2DeployUtils.set_finish_message_flag(stageName)
    systems_helper.send_chat_message(request, deploy['operator'], get_slack_channel(), message)
Beispiel #4
0
def update_env_priority(request, env_name):
    try:
        if env_name == NGAPP_A:
            curr_env = NGAPP_A
            prev_env = NGAPP_B
        else:
            curr_env = NGAPP_B
            prev_env = NGAPP_A

        # we only update env priority once
        if Ngapp2DeployUtils().get_finish_message_flag("prod") != "True":
            return

        curr_data = {"priority": "HIGH"}
        prev_data = {"priority": "NORMAL"}
        environs_helper.update_env_basic_config(request, curr_env, "prod", data=curr_data)
        environs_helper.update_env_basic_config(request, prev_env, "prod", data=prev_data)
    except:
        logger.error("Failed change ngapp2 deploy priority")

        # send message to the auto scaling channel
        message = "Failed to switch ngapp2 deploy priority after deploy. This may lead to health check failure. Please take actions."
        systems_helper.send_chat_message(request, "system", "autoscaling", message)
Beispiel #5
0
def update_env_priority(request, env_name):
    try:
        if env_name == NGAPP_A:
            curr_env = NGAPP_A
            prev_env = NGAPP_B
        else:
            curr_env = NGAPP_B
            prev_env = NGAPP_A

        # we only update env priority once
        if Ngapp2DeployUtils().get_finish_message_flag("prod") != "True":
            return

        curr_data = {"priority": "HIGH"}
        prev_data = {"priority": "NORMAL"}
        environs_helper.update_env_basic_config(request, curr_env, "prod", data=curr_data)
        environs_helper.update_env_basic_config(request, prev_env, "prod", data=prev_data)
    except:
        logger.error("Failed change ngapp2 deploy priority")

        # send message to the auto scaling channel
        message = "Failed to switch ngapp2 deploy priority after deploy. This may lead to health check failure. Please take actions."
        systems_helper.send_chat_message(request, "system", "autoscaling", message)