예제 #1
0
    def insubstantiate(self, fast=False, force_substantiation_build=None):
        # If force_substantiation_build is not None, we'll try to substantiate the given build
        # after insubstantiation concludes. This parameter allows to go directly to the
        # SUBSTANTIATING state without going through NOT_SUBSTANTIATED state.

        log.msg("insubstantiating worker {}".format(self))

        if self.state == States.INSUBSTANTIATING_SUBSTANTIATING:
            self.state = States.INSUBSTANTIATING
            self.substantiation_build = None
            self._fireSubstantiationNotifier(
                failure.Failure(LatentWorkerSubstantiatiationCancelled()))

        try:
            self._log_start_stop_locked('insubstantiating')
            yield self._start_stop_lock.acquire()

            assert self.state not in [States.INSUBSTANTIATING,
                                      States.INSUBSTANTIATING_SUBSTANTIATING]

            if self.state == States.NOT_SUBSTANTIATED:
                return

            prev_state = self.state

            if force_substantiation_build is not None:
                self.state = States.INSUBSTANTIATING_SUBSTANTIATING
                self.substantiation_build = force_substantiation_build
            else:
                self.state = States.INSUBSTANTIATING

            if prev_state == States.SUBSTANTIATING:
                self._fireSubstantiationNotifier(
                    failure.Failure(LatentWorkerSubstantiatiationCancelled()))

            self._clearBuildWaitTimer()
            try:
                yield self.stop_instance(fast)
            except Exception as e:
                # The case of failure for insubstantiation is bad as we have a
                # left-over costing resource There is not much thing to do here
                # generically, so we must put the problem of stop_instance
                # reliability to the backend driver
                log.err(e, "while insubstantiating")

            assert self.state in [States.INSUBSTANTIATING,
                                  States.INSUBSTANTIATING_SUBSTANTIATING]

            if self.state == States.INSUBSTANTIATING_SUBSTANTIATING:
                build, self.substantiation_build = self.substantiation_build, None
                self.state = States.SUBSTANTIATING
                self._substantiate(build)
            else:  # self.state == States.INSUBSTANTIATING:
                self.state = States.NOT_SUBSTANTIATED

        finally:
            self._start_stop_lock.release()

        self.botmaster.maybeStartBuildsForWorker(self.name)
예제 #2
0
    def insubstantiate(self, fast=False, _force_substantiation=False):
        # _force_substantiation=True means we'll try to substantiate a build
        # with stored substantiation_build at the end of substantiation

        log.msg("insubstantiating worker {}".format(self))
        if self.state == States.NOT_SUBSTANTIATED:
            return

        if self.state in [
                States.INSUBSTANTIATING, States.INSUBSTANTIATING_SUBSTANTIATING
        ]:
            yield self._insubstantiation_notifier.wait()
            return

        notify_cancel = self.state == States.SUBSTANTIATING

        if _force_substantiation:
            self.state = States.INSUBSTANTIATING_SUBSTANTIATING
        else:
            self.state = States.INSUBSTANTIATING
        self._clearBuildWaitTimer()
        d = self.stop_instance(fast)
        try:
            yield d
        except Exception as e:
            # The case of failure for insubstantiation is bad as we have a
            # left-over costing resource There is not much thing to do here
            # generically, so we must put the problem of stop_instance
            # reliability to the backend driver
            log.err(e, "while insubstantiating")

        assert self.state in [
            States.INSUBSTANTIATING, States.INSUBSTANTIATING_SUBSTANTIATING
        ]

        if notify_cancel:
            self._fireSubstantiationNotifier(
                failure.Failure(LatentWorkerSubstantiatiationCancelled()))

        if self.state == States.INSUBSTANTIATING_SUBSTANTIATING:
            self.state = States.SUBSTANTIATING
            if self._insubstantiation_notifier:
                self._insubstantiation_notifier.notify(True)
            self._substantiate(self.substantiation_build)
        elif self.state == States.INSUBSTANTIATING:
            self.state = States.NOT_SUBSTANTIATED
            if self._insubstantiation_notifier:
                self._insubstantiation_notifier.notify(True)
        else:
            pass
        self.botmaster.maybeStartBuildsForWorker(self.name)
예제 #3
0
    def insubstantiate(self, fast=False):
        self.insubstantiating = True
        self._clearBuildWaitTimer()
        d = self.stop_instance(fast)
        try:
            yield d
        except Exception as e:
            # The case of failure for insubstantiation is bad as we have a left-over costing ressource
            # There is not much thing to do here generically, so we must put the problem of stop_instance
            # reliability to the backend driver
            log.err(e, "while insubstantiating")

        self.insubstantiating = False
        if self._substantiation_notifier:
            self._substantiation_notifier.notify(
                failure.Failure(LatentWorkerSubstantiatiationCancelled()))
        self.botmaster.maybeStartBuildsForWorker(self.name)