예제 #1
0
def abandon_release(name):
    session = flask.g.db.session
    try:
        release = session.query(Release).filter(Release.name == name).one()
        # Cancel all submitted task groups first
        for phase in filter(lambda x: x.submitted, release.phases):
            actions = fetch_actions_json(phase.task_id)
            hook = generate_action_hook(
                decision_task_id=phase.task_id,
                action_name='cancel-all',
                actions=actions,
            )
            # some parameters contain a lot of entries, so we hit the payload
            # size limit. We don't use this parameter in any case, safe to
            # remove
            for long_param in ('existing_tasks', 'release_history', 'release_partner_config'):
                del hook['context']['parameters'][long_param]
            log.info('Cancel phase %s by hook %s', phase.name, hook)
            res = _hooks().triggerHook(hook['hook_group_id'], hook['hook_id'], hook['hook_payload'])
            log.debug('Done: %s', res)

        release.status = 'aborted'
        session.commit()
        return release.json
    except NoResultFound:
        flask.abort(404)
예제 #2
0
def abandon_release(name):
    session = current_app.db.session
    try:
        release = session.query(Release).filter(Release.name == name).one()

        # we must require scope which depends on product
        required_permission = f'{SCOPE_PREFIX}/abandon_release/{release.product}'
        if not current_user.has_permissions(required_permission):
            user_permissions = ', '.join(current_user.get_permissions())
            abort(
                401,
                f'required permission: {required_permission}, user permissions: {user_permissions}'
            )

        # Cancel all submitted task groups first
        for phase in filter(lambda x: x.submitted, release.phases):
            try:
                actions = fetch_actions_json(phase.task_id)
            except ActionsJsonNotFound:
                logger.info('Ignoring not completed action task %s',
                            phase.task_id)
                continue

            hook = generate_action_hook(
                task_group_id=phase.task_id,
                action_name='cancel-all',
                actions=actions,
                input_={},
            )
            hooks = get_service('hooks')
            client_id = hooks.options['credentials']['clientId'].decode(
                'utf-8')
            hook['context']['clientId'] = client_id
            hook_payload_rendered = render_action_hook(
                payload=hook['hook_payload'],
                context=hook['context'],
                delete_params=[
                    'existing_tasks', 'release_history',
                    'release_partner_config'
                ],
            )
            logger.info('Cancel phase %s by hook %s with payload: %s',
                        phase.name, hook['hook_id'], hook_payload_rendered)
            res = hooks.triggerHook(hook['hook_group_id'], hook['hook_id'],
                                    hook_payload_rendered)
            logger.debug('Done: %s', res)

        release.status = 'aborted'
        session.commit()
        release_json = release.json
    except NoResultFound:
        abort(404)

    notify_via_irc(
        release.product,
        f'Release {release.product} {release.version} build{release.build_number} was just canceled.'
    )

    return release_json
예제 #3
0
def abandon_release(name):
    session = g.db.session
    try:
        r = session.query(Release).filter(Release.name == name).one()
        # Cancel all submitted task groups first
        for phase in filter(lambda x: x.submitted, r.phases):
            try:
                actions = fetch_actions_json(phase.task_id)
            except ActionsJsonNotFound:
                logger.info('Ignoring not completed action task %s',
                            phase.task_id)
                continue

            hook = generate_action_hook(
                task_group_id=phase.task_id,
                action_name='cancel-all',
                actions=actions,
                input_={},
            )
            hooks = get_service('hooks')
            client_id = hooks.options['credentials']['clientId'].decode(
                'utf-8')
            hook['context']['clientId'] = client_id
            hook_payload_rendered = render_action_hook(
                payload=hook['hook_payload'],
                context=hook['context'],
                delete_params=[
                    'existing_tasks', 'release_history',
                    'release_partner_config'
                ],
            )
            logger.info('Cancel phase %s by hook %s with payload: %s',
                        phase.name, hook['hook_id'], hook_payload_rendered)
            res = hooks.triggerHook(hook['hook_group_id'], hook['hook_id'],
                                    hook_payload_rendered)
            logger.debug('Done: %s', res)

        r.status = 'aborted'
        session.commit()
        release = r.json
    except NoResultFound:
        abort(404)

    notify_via_irc(
        f'Release {r.product} {r.version} build{r.build_number} was just canceled.'
    )

    return release
예제 #4
0
def abandon_release(name):
    session = g.db.session
    try:
        r = session.query(Release).filter(Release.name == name).one()
        # Cancel all submitted task groups first
        for phase in filter(lambda x: x.submitted, r.phases):
            try:
                actions = fetch_actions_json(phase.task_id)
            except ActionsJsonNotFound:
                logger.info('Ignoring not completed action task %s',
                            phase.task_id)
                continue

            hook = generate_action_hook(
                decision_task_id=phase.task_id,
                action_name='cancel-all',
                actions=actions,
            )
            # some parameters contain a lot of entries, so we hit the payload
            # size limit. We don't use this parameter in any case, safe to
            # remove
            for long_param in ('existing_tasks', 'release_history',
                               'release_partner_config'):
                del hook['context']['parameters'][long_param]
            logger.info('Cancel phase %s by hook %s', phase.name, hook)
            hooks = get_service('hooks')
            res = hooks.triggerHook(hook['hook_group_id'], hook['hook_id'],
                                    hook['hook_payload'])
            logger.debug('Done: %s', res)

        r.status = 'aborted'
        session.commit()
        release = r.json
    except NoResultFound:
        abort(404)

    notify_via_irc(
        f'Release {r.product} {r.version} build{r.build_number} was just canceled.'
    )

    return release
 def actions(self):
     return fetch_actions_json(self.decision_task_id)
예제 #6
0
 def actions(self):
     return fetch_actions_json(self.decision_task_id)