Beispiel #1
0
    def all_deps(self, dep_cache):
        # This is not necessarily 100% consistent with the dependencies used by StateManager
        # when the job was submitted (e.g. other models which get_deps queries may have
        # changed), but that is a *good thing* -- this is a last check before running
        # which will safely cancel the job if something has changed that breaks our deps.
        if isinstance(self, StateChangeJob):
            stateful_object = self.get_stateful_object()
            target_klass, origins, new_state = self.state_transition

            # Generate dependencies (which will fail) for any dependents
            # which depend on our old state (bit of a roundabout way of doing it)
            dependent_deps = []
            dependents = stateful_object.get_dependent_objects()
            for dependent in dependents:
                for dependent_dependency in dep_cache.get(dependent).all():
                    if (
                        dependent_dependency.stateful_object == stateful_object
                        and not new_state in dependent_dependency.acceptable_states
                    ):
                        dependent_deps.append(DependOn(dependent, dependent_dependency.fix_state))

            return DependAll(
                DependAll(dependent_deps),
                dep_cache.get(self),
                dep_cache.get(stateful_object, new_state),
                DependOn(stateful_object, self.old_state),
            )
        else:
            return dep_cache.get(self)
    def get_deps(self, state=None):
        if not state:
            state = self.state

        t = get_target_by_name(self.name)
        active_host_id = t["active_host_id"]

        deps = []
        if state == "mounted" and active_host_id and not self.immutable_state:
            from chroma_core.models import LNetConfiguration

            # Depend on the active mount's host having LNet up, so that if
            # LNet is stopped on that host this target will be stopped first.
            host = ObjectCache.get_one(ManagedHost,
                                       lambda mh: mh.id == active_host_id,
                                       fill_on_miss=True)

            lnet_configuration = ObjectCache.get_by_id(
                LNetConfiguration, host.lnet_configuration.id)
            deps.append(
                DependOn(lnet_configuration, "lnet_up", fix_state="unmounted"))

            if host.pacemaker_configuration:
                pacemaker_configuration = ObjectCache.get_by_id(
                    PacemakerConfiguration, host.pacemaker_configuration.id)
                deps.append(
                    DependOn(pacemaker_configuration,
                             "started",
                             fix_state="unmounted"))

            # TODO: also express that this situation may be resolved by migrating
            # the target instead of stopping it.

        if state not in ["removed", "forgotten"]:
            from chroma_core.models import LNetConfiguration

            for host in self.hosts:
                fix_state = "forgotten" if self.immutable_state else "removed"

                lnet_configuration = ObjectCache.get_by_id(
                    LNetConfiguration, host.lnet_configuration.id)
                deps.append(
                    DependOn(lnet_configuration,
                             "lnet_up",
                             unacceptable_states=["unconfigured"],
                             fix_state=fix_state))

                if host.pacemaker_configuration:
                    pacemaker_configuration = ObjectCache.get_by_id(
                        PacemakerConfiguration,
                        host.pacemaker_configuration.id)
                    deps.append(
                        DependOn(
                            pacemaker_configuration,
                            "started",
                            unacceptable_states=["unconfigured"],
                            fix_state=fix_state,
                        ))

        return DependAll(deps)
    def get_deps(self, state=None):
        if not state:
            state = self.state

        client_mount = ObjectCache.get_one(LustreClientMount, lambda cm: cm.id == self.client_mount_id)

        deps = []
        if state == "started":
            # Depend on the client mount being mounted in order to
            # start or stay running.
            deps.append(DependOn(client_mount, "mounted", fix_state="stopped"))

        if state != "removed":
            # If the client mount is going to be removed, then the
            # copytool should also be removed.
            deps.append(
                DependOn(
                    client_mount,
                    "mounted",
                    acceptable_states=list(set(self.client_mount.states) - set(["removed"])),
                    fix_state="removed",
                )
            )

        return DependAll(deps)
Beispiel #4
0
    def get_deps(self):
        """
        Before Pacemaker operations are possible the host must have had its packages installed.
        Maybe we need a packages object, but this routine at least keeps the detail in one place.

        Also corosync needs to be up and running. This is because configuring pacemaker requires starting pacemaker.

        Or maybe we need an unacceptable_states lists.
        :return:
        """
        if self.pacemaker_configuration.host.state in [
                "unconfigured", "undeployed"
        ]:
            deps = [
                DependOn(self.pacemaker_configuration.host,
                         "packages_installed")
            ]
        else:
            deps = []

        deps.append(
            DependOn(self.pacemaker_configuration.host.corosync_configuration,
                     "started"))

        # Any targets will have to be removed.
        from chroma_core.models.target import get_host_targets

        for t in get_host_targets(self.pacemaker_configuration.host.id):
            deps.append(DependOn(target, "removed"))

        return DependAll(deps)
    def get_deps(self):
        '''
        Before Pacemaker operations are possible the host must have had its packages installed.
        Maybe we need a packages object, but this routine at least keeps the detail in one place.

        Also corosync needs to be up and running. This is because configuring pacemaker requires starting pacemaker.

        Or maybe we need an unacceptable_states lists.
        :return:
        '''
        if self.pacemaker_configuration.host.state in [
                'unconfigured', 'undeployed'
        ]:
            deps = [
                DependOn(self.pacemaker_configuration.host,
                         'packages_installed')
            ]
        else:
            deps = []

        deps.append(
            DependOn(self.pacemaker_configuration.host.corosync_configuration,
                     'started'))

        return DependAll(deps)
    def get_deps(self, state=None):
        if not state:
            state = self.state

        deps = []
        if state == "mounted":
            # Depend on this mount's host having LNet up. If LNet is stopped
            # on the host, this filesystem will be unmounted first.
            deps.append(DependOn(self.host.lnet_configuration, "lnet_up", fix_state="unmounted"))

        if state != "removed":
            # Depend on the fs being available.
            deps.append(DependOn(self.filesystem, "available", fix_state="unmounted"))

            # But if either the host or the filesystem are removed, the
            # mount should follow.
            deps.append(
                DependOn(
                    self.host,
                    "lnet_up",
                    acceptable_states=list(set(self.host.states) - set(["removed", "forgotten"])),
                    fix_state="removed",
                )
            )
            deps.append(
                DependOn(
                    self.filesystem,
                    "available",
                    acceptable_states=list(set(self.filesystem.states) - set(["removed", "forgotten"])),
                    fix_state="removed",
                )
            )

        return DependAll(deps)
    def get_deps(self):
        mgs = self.mgs.downcast()
        deps = [DependOn(self.mgs, "mounted")]
        new_params = ConfParam.objects.filter(
            version__gt=mgs.conf_param_version_applied,
            mgs=mgs).order_by("version")
        targets = set()
        for param in new_params:
            param = param.downcast()
            if hasattr(param, "mdt"):
                targets.add(param.mdt.managedtarget_ptr)
            if hasattr(param, "ost"):
                targets.add(param.ost.managedtarget_ptr)
            if hasattr(param, "filesystem"):
                targets.add(
                    ManagedMdt._base_manager.get(
                        filesystem=param.filesystem).managedtarget_ptr)

        for target in targets:
            deps.append(
                DependOn(target,
                         "mounted",
                         acceptable_states=target.not_states(
                             ["unformatted", "formatted"])))

        return DependAll(deps)
    def get_deps(self):
        '''
        Before Pacemaker operations are possible the host must have had its packages installed.
        Maybe we need a packages object, but this routine at least keeps the detail in one place.

        Also corosync needs to be up and running. This is because configuring pacemaker requires starting pacemaker.

        Or maybe we need an unacceptable_states lists.
        :return:
        '''
        if self.pacemaker_configuration.host.state in [
                'unconfigured', 'undeployed'
        ]:
            deps = [
                DependOn(self.pacemaker_configuration.host,
                         'packages_installed')
            ]
        else:
            deps = []

        deps.append(
            DependOn(self.pacemaker_configuration.host.corosync_configuration,
                     'started'))

        # Any targets will have to be removed.
        from chroma_core.models import ManagedTargetMount

        for managed_target_mount in ManagedTargetMount.objects.filter(
                host=self.pacemaker_configuration.host):
            deps.append(DependOn(managed_target_mount.target, 'removed'))

        return DependAll(deps)
    def get_deps(self):
        deps = []
        ticket = self.filesystem.get_ticket()
        if ticket:
            deps.append(DependOn(ticket, "forgotten", fix_state=ticket.state))

        for t in self.filesystem.get_filesystem_targets():
            deps.append(DependOn(t, "forgotten"))

        return DependAll(deps)
 def get_deps(self):
     deps = [
         DependOn(self.target, "mounted"),
         DependOn(self.target.inactive_hosts[0].lnet_configuration,
                  "lnet_up"),
     ]
     if self.target.inactive_hosts[0].pacemaker_configuration:
         deps.append(
             DependOn(self.target.inactive_hosts[0].pacemaker_configuration,
                      "started"))
     return DependAll(deps)
Beispiel #11
0
    def get_deps(self, state=None):
        if not state:
            state = self.state

        deps = []
        if state == "mounted":
            # Depend on this mount's host having LNet up. If LNet is stopped
            # on the host, this filesystem will be unmounted first.
            deps.append(
                DependOn(self.host.lnet_configuration,
                         "lnet_up",
                         fix_state="unmounted"))

        if state != "removed":
            try:
                fs = ManagedFilesystem.objects.get(name=self.filesystem)

                # Depend on the fs being available.
                deps.append(
                    DependOn(
                        fs,
                        "available",
                        acceptable_states=list(
                            set(fs.states) - set(["stopped", "removed"])),
                        fix_state="unmounted",
                    ))

                # If the filesystem is removed, the
                # mount should follow.
                deps.append(
                    DependOn(
                        fs,
                        "available",
                        acceptable_states=list(
                            set(fs.states) - set(["removed", "forgotten"])),
                        fix_state="forgotten",
                    ))
            except ManagedFilesystem.DoesNotExist:
                pass

            # If the host is removed, the
            # mount should follow.
            deps.append(
                DependOn(
                    self.host,
                    "lnet_up",
                    acceptable_states=list(
                        set(self.host.states) - set(["removed", "forgotten"])),
                    fix_state="removed",
                ))

        return DependAll(deps)
    def get_deps(self):
        ticket = self.filesystem.get_ticket()
        if ticket:
            return DependAll(
                DependOn(ticket, "granted", fix_state="unavailable"))

        deps = []
        for t in ObjectCache.get_targets_by_filesystem(self.filesystem_id):
            # Report filesystem available if MDTs other than 0 are unmounted
            (_, label, index) = target_label_split(t.get_label())
            if label == "MDT" and index != 0:
                continue
            deps.append(DependOn(t, "mounted", fix_state="unavailable"))
        return DependAll(deps)
Beispiel #13
0
    def get_deps(self):
        deps = []

        ticket = self.filesystem.get_ticket()
        if ticket:
            deps.append(DependOn(ticket, "revoked", fix_state="unavailable"))

        mgs_target = ObjectCache.get_one(
            ManagedTarget, lambda t: t.id == self.filesystem.mgs_id)

        # Can't start a MGT that hasn't made it past formatting.
        if mgs_target.state not in ["unformatted", "formatted"]:
            deps.append(
                DependOn(mgs_target, "mounted", fix_state="unavailable"))
        return DependAll(deps)
 def get_deps(self):
     return DependOn(
         ObjectCache.get_one(
             ManagedHost, lambda mh: mh.id == self.lustre_client_mount.
             host_id).lnet_configuration,
         "lnet_up",
     )
 def get_deps(self):
     if issubclass(self.target.downcast_class, ManagedMgs):
         ticket = self.target.downcast().get_ticket()
         if ticket:
             return DependAll(
                 DependOn(ticket, "revoked", fix_state="mounted"))
     return super(StopTargetJob, self).get_deps()
    def get_deps(self):
        ticket = self.ticket.downcast()

        if isinstance(ticket, FilesystemTicket):
            mt = MasterTicket.objects.filter(mgs=ticket.filesystem.mgs)[0]
            return DependOn(mt.ticket, "granted")

        return DependAll()
    def get_deps(self):
        ticket = self.filesystem.get_ticket()
        if ticket:
            return DependAll(
                [DependOn(ticket, "revoked", fix_state="unavailable")])

        deps = []
        targets = ObjectCache.get_targets_by_filesystem(self.filesystem_id)
        targets = [
            t for t in targets if not issubclass(t.downcast_class, ManagedMgs)
        ]
        for t in targets:
            deps.append(
                DependOn(t,
                         "unmounted",
                         acceptable_states=t.not_state("mounted"),
                         fix_state="unavailable"))
        return DependAll(deps)
    def get_deps(self):
        deps = []
        if issubclass(self.target.downcast_class, ManagedMgs):
            mgs = self.target.downcast()
            ticket = mgs.get_ticket()
            if ticket:
                deps.append(
                    DependOn(ticket, "forgotten", fix_state=ticket.state))

        return DependAll(deps)
    def get_deps(self):
        deps = []

        mgs_target = ObjectCache.get_one(
            ManagedTarget, lambda t: t.id == self.filesystem.mgs_id)

        # Can't start a MGT that hasn't made it past formatting.
        if mgs_target.state not in ['unformatted', 'formatted']:
            deps.append(
                DependOn(mgs_target, 'mounted', fix_state='unavailable'))
        return DependAll(deps)
    def get_deps(self, state=None):
        if not state:
            state = self.state

        deps = []
        if state != "removed":
            # Depend on the filesystem being available.
            deps.append(DependOn(self.filesystem, "available", fix_state="unconfigured"))

            # move to the removed state if the filesystem is removed.
            deps.append(
                DependOn(
                    self.filesystem,
                    "available",
                    acceptable_states=list(set(self.filesystem.states) - set(["removed", "forgotten"])),
                    fix_state="removed",
                )
            )

        return DependAll(deps)
    def get_deps(self):
        if issubclass(self.target.downcast_class, ManagedMgs):
            ticket = self.target.downcast().get_ticket()
            if ticket:
                return DependAll(
                    DependOn(ticket, "granted", fix_state="unmounted"))

        if self.target.downcast_class in [ManagedMdt, ManagedOst]:
            from chroma_core.models import FilesystemTicket

            target = self.target.downcast()

            ticket = FilesystemTicket.objects.filter(
                filesystem=target.filesystem_id).first()

            if ticket:
                return DependAll(
                    DependOn(ticket.ticket, "granted", fix_state="unmounted"))

        deps = []

        # Depend on at least one targetmount having lnet up
        for host in self.target.hosts:
            from chroma_core.models import LNetConfiguration

            lnet_configuration = ObjectCache.get_one(
                LNetConfiguration, lambda l: l.host_id == host.id)
            deps.append(
                DependOn(lnet_configuration, "lnet_up", fix_state="unmounted"))

            try:
                pacemaker_configuration = ObjectCache.get_one(
                    PacemakerConfiguration, lambda pm: pm.host_id == host.id)
                deps.append(
                    DependOn(pacemaker_configuration,
                             "started",
                             fix_state="unmounted"))
            except PacemakerConfiguration.DoesNotExist:
                pass

        return DependAny(deps)
    def get_deps(self):
        search = lambda ct: ct.host == self.copytool.host
        copytools = ObjectCache.get(Copytool, search)

        # Only force an unmount if this is the only copytool associated
        # with the host.
        if len(copytools) == 1:
            search = lambda cm: cm.id == self.copytool.client_mount_id
            client_mount = ObjectCache.get_one(LustreClientMount, search)
            return DependOn(client_mount, "unmounted")
        else:
            return DependAll()
    def get_deps(self):
        """
        Before ntp operations are possible some dependencies are need, basically the host must have had its packages installed.
        Maybe we need a packages object, but this routine at least keeps the detail in one place.

        Or maybe we need an unacceptable_states lists.
        :return:
        """
        if self.ntp_configuration.host.state in ["unconfigured", "undeployed"]:
            return DependOn(self.ntp_configuration.host, "packages_installed")
        else:
            return DependAll()
    def get_deps(self):
        '''
        Before LNet operations are possible some dependencies are need, basically the host must have had its packages installed.
        Maybe we need a packages object, but this routine at least keeps the detail in one place.

        Or maybe we need an unacceptable_states lists.
        :return:
        '''
        if self.target_object.host.state in ['unconfigured', 'undeployed']:
            return DependOn(self.target_object.host, 'packages_installed')
        else:
            return DependAll()
 def get_deps(self):
     deps = []
     targets = ObjectCache.get_targets_by_filesystem(self.filesystem_id)
     targets = [
         t for t in targets if not issubclass(t.downcast_class, ManagedMgs)
     ]
     for t in targets:
         deps.append(
             DependOn(t,
                      'unmounted',
                      acceptable_states=t.not_state('mounted'),
                      fix_state='unavailable'))
     return DependAll(deps)
Beispiel #26
0
    def get_deps(self, state=None):
        if not state:
            state = self.state

        deps = []

        mgs = ObjectCache.get_one(ManagedTarget, lambda t: t.id == self.mgs_id)

        remove_state = "forgotten" if self.immutable_state else "removed"

        if state not in ["removed", "forgotten"]:
            deps.append(
                DependOn(mgs,
                         "unmounted",
                         acceptable_states=mgs.not_states(
                             ["removed", "forgotten"]),
                         fix_state=remove_state))

        return DependAll(deps)
Beispiel #27
0
 def get_deps(self):
     return DependOn(
         LNetConfiguration.objects.get(
             host_id=self.lustre_client_mount.host_id), "lnet_up")
 def get_deps(self):
     return DependOn(self.stratagem_configuration, "unconfigured")
 def get_deps(self):
     return DependOn(
         self.corosync_configuration.host.pacemaker_configuration,
         'stopped',
         unacceptable_states=['started'])
 def get_deps(self):
     return DependOn(self.corosync_configuration, 'stopped')