Beispiel #1
0
    def delete_test_pods(self):
        """Deletes any existing test pods for the release, as identified by the
        wait labels for the chart, to avoid test pod name conflicts when
        creating the new test pod as well as just for general cleanup since
        the new test pod should supercede it.
        """
        labels = get_wait_labels(self.chart)

        # Guard against labels being left empty, so we don't delete other
        # chart's test pods.
        if labels:
            label_selector = label_selectors(labels)

            namespace = self.chart['namespace']

            list_args = {
                'namespace': namespace,
                'label_selector': label_selector,
                'timeout_seconds': self.k8s_timeout
            }

            pod_list = self.tiller.k8s.client.list_namespaced_pod(**list_args)
            test_pods = [pod for pod in pod_list.items if is_test_pod(pod)]

            if test_pods:
                LOG.info(
                    'Found existing test pods for release with '
                    'namespace=%s, labels=(%s)', namespace, label_selector)

            for test_pod in test_pods:
                pod_name = test_pod.metadata.name
                LOG.info('Deleting existing test pod: %s', pod_name)
                self.tiller.k8s.delete_pod_action(pod_name,
                                                  namespace,
                                                  timeout=self.k8s_timeout)
Beispiel #2
0
    def get_exclude_reason(self, resource):
        pod = resource

        # Exclude helm test pods
        # TODO: Possibly exclude other helm hook pods/jobs (besides tests)?
        if is_test_pod(pod):
            return 'helm test pod'

        # Exclude job pods
        # TODO: Once controller-based waits are enabled by default, ignore
        # controller-owned pods as well.
        if has_owner(pod, 'Job'):
            return 'generated by job (wait on that instead if not already)'

        return None
Beispiel #3
0
    def get_exclude_reason(self, resource):
        pod = resource

        # Exclude helm test pods
        # TODO: Possibly exclude other helm hook pods/jobs (besides tests)?
        if is_test_pod(pod):
            return 'helm test pod'

        if pod.status.phase == 'Evicted':
            return "pod was evicted"

        schema_info = get_schema_info(self.chart_wait.chart['schema'])
        # TODO: Remove when v1 doc support is removed.
        if schema_info.version < 2:
            # Exclude job pods
            if has_owner(pod, 'Job'):
                return 'owned by job'
        else:
            # Exclude all pods with an owner (only include raw pods)
            if has_owner(pod):
                return 'owned by another resource'

        return None
Beispiel #4
0
    def get_exclude_reason(self, resource):
        pod = resource

        # Exclude helm test pods
        # TODO: Possibly exclude other helm hook pods/jobs (besides tests)?
        if is_test_pod(pod):
            return 'helm test pod'

        schema_info = get_schema_info(self.chart_wait.chart['schema'])
        # TODO: Remove when v1 doc support is removed.
        if schema_info.version < 2:
            # Exclude job pods
            if has_owner(pod, 'Job'):
                return 'owned by job'
        else:
            # Exclude all pods with an owner (only include raw pods)
            # TODO: In helm 3, all resources will likely have the release CR as
            # an owner, so this will need to be updated to not exclude pods
            # directly owned by the release.
            if has_owner(pod):
                return 'owned by another resource'

        return None