<commit_before>"""Copyright (c) 2016 Red Hat, Inc
All rights reserved.

This software may be modified and distributed under the terms
of the BSD license. See the LICENSE file for details.

Pull built image from Crane to discover its image ID.

After squashing our image, the squashed image 'docker save' form will
have an image ID that is correct for its v2 schema 2
representation. However since Pulp does not yet support v2 schema 2,
we will need to remove that local image and re-pull it from Crane to
discover the image ID Docker will give it.
"""

from __future__ import unicode_literals

from atomic_reactor.constants import (PLUGIN_PULP_PUSH_KEY, PLUGIN_PULP_SYNC_KEY,
                                      PLUGIN_GROUP_MANIFESTS_KEY,
                                      PLUGIN_CHECK_AND_SET_PLATFORMS_KEY,
                                      MEDIA_TYPE_DOCKER_V1, MEDIA_TYPE_DOCKER_V2_SCHEMA1,
                                      MEDIA_TYPE_DOCKER_V2_SCHEMA2,
                                      MEDIA_TYPE_DOCKER_V2_MANIFEST_LIST)

from atomic_reactor.plugin import PostBuildPlugin, ExitPlugin
from atomic_reactor.plugins.exit_remove_built_image import defer_removal
from atomic_reactor.util import get_manifest_digests
from atomic_reactor.plugins.pre_reactor_config import (get_prefer_schema1_digest,
                                                       get_platform_to_goarch_mapping)
import requests
from time import time, sleep


class CraneTimeoutError(Exception):
    """The expected image did not appear in the required time"""
    pass


# Note: We use multiple inheritance here only to make it explicit that
# this plugin needs to act as both an exit plugin (since arrangement
# version 4) and as a post-build plugin (arrangement version < 4). In
# fact, ExitPlugin is a subclass of PostBuildPlugin.
class PulpPullPlugin(ExitPlugin, PostBuildPlugin):
    key = 'pulp_pull'
    is_allowed_to_fail = False

    def __init__(self, tasker, workflow,
                 timeout=600, retry_delay=30,
                 insecure=False, secret=None,
                 expect_v2schema2=False):
        """
        constructor

        :param tasker: DockerTasker instance
        :param workflow: DockerBuildWorkflow instance
        :param timeout: int, maximum number of seconds to wait
        :param retry_delay: int, seconds between pull attempts
        :param insecure: bool, allow non-https pull if true
        :param secret: str, path to secret
        :param expect_v2schema2: bool, require Pulp to return a schema 2 digest and
                                       retry until it does
        """
        # call parent constructor
        super(PulpPullPlugin, self).__init__(tasker, workflow)
        self.timeout = timeout<commit_msg>Increase default pulp_pull timeout (OSBS-5544)<commit_after>"""Copyright (c) 2016 Red Hat, Inc
All rights reserved.

This software may be modified and distributed under the terms
of the BSD license. See the LICENSE file for details.

Pull built image from Crane to discover its image ID.

After squashing our image, the squashed image 'docker save' form will
have an image ID that is correct for its v2 schema 2
representation. However since Pulp does not yet support v2 schema 2,
we will need to remove that local image and re-pull it from Crane to
discover the image ID Docker will give it.
"""

from __future__ import unicode_literals

from atomic_reactor.constants import (PLUGIN_PULP_PUSH_KEY, PLUGIN_PULP_SYNC_KEY,
                                      PLUGIN_GROUP_MANIFESTS_KEY,
                                      PLUGIN_CHECK_AND_SET_PLATFORMS_KEY,
                                      MEDIA_TYPE_DOCKER_V1, MEDIA_TYPE_DOCKER_V2_SCHEMA1,
                                      MEDIA_TYPE_DOCKER_V2_SCHEMA2,
                                      MEDIA_TYPE_DOCKER_V2_MANIFEST_LIST)

from atomic_reactor.plugin import PostBuildPlugin, ExitPlugin
from atomic_reactor.plugins.exit_remove_built_image import defer_removal
from atomic_reactor.util import get_manifest_digests
from atomic_reactor.plugins.pre_reactor_config import (get_prefer_schema1_digest,
                                                       get_platform_to_goarch_mapping)
import requests
from time import time, sleep


class CraneTimeoutError(Exception):
    """The expected image did not appear in the required time"""
    pass


# Note: We use multiple inheritance here only to make it explicit that
# this plugin needs to act as both an exit plugin (since arrangement
# version 4) and as a post-build plugin (arrangement version < 4). In
# fact, ExitPlugin is a subclass of PostBuildPlugin.
class PulpPullPlugin(ExitPlugin, PostBuildPlugin):
    key = 'pulp_pull'
    is_allowed_to_fail = False

    def __init__(self, tasker, workflow,
                 timeout=1200, retry_delay=30,
                 insecure=False, secret=None,
                 expect_v2schema2=False):
        """
        constructor

        :param tasker: DockerTasker instance
        :param workflow: DockerBuildWorkflow instance
        :param timeout: int, maximum number of seconds to wait
        :param retry_delay: int, seconds between pull attempts
        :param insecure: bool, allow non-https pull if true
        :param secret: str, path to secret
        :param expect_v2schema2: bool, require Pulp to return a schema 2 digest and
                                       retry until it does
        """
        # call parent constructor
        super(PulpPullPlugin, self).__init__(tasker, workflow)
        self.timeout = timeout
{'fraction_non_alphanumeric': 0.045863309352517985, 'fraction_numerical': 0.010611510791366907, 'mean_word_length': 2.592377260981912, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5311714', 'n_tokens_mistral': 1551, 'n_tokens_neox': 1458, 'n_words': 541}