Exemplo n.º 1
0
 async def get_upgrade_intent(self) -> UpgradeIntent:
     """
     Returns the desired version for the gateway.
     We don't support downgrading, and so checks are made to update
     only if the target version is higher than the current version.
     """
     tgt_version = self.service.mconfig.package_version
     curr_version = self.service.version
     if (tgt_version == "0.0.0-0"
             or compare_package_versions(curr_version, tgt_version) <= 0):
         tgt_version = curr_version
     return UpgradeIntent(stable=VersionT(tgt_version), canary=VersionT(""))
Exemplo n.º 2
0
    async def get_upgrade_intent(self) -> UpgradeIntent:
        """
        Returns the desired version tag for the gateway.
        """
        version_info = await asyncio.gather(self.get_versions())
        current_version = version_info[0].current_version
        tgt_version = self.service.mconfig.package_version
        if tgt_version is None or tgt_version == "":
            logging.warning(
                'magmad package_version not found, '
                'using current tag: %s as target tag.', current_version)
            return UpgradeIntent(stable=VersionT(current_version),
                                 canary=VersionT(""))

        return UpgradeIntent(stable=VersionT(tgt_version), canary=VersionT(""))
Exemplo n.º 3
0
 def version_to_image_name(self, version: VersionT) -> ImageNameT:
     split_version = version.split('|')
     if len(split_version) > 2:
         raise ValueError(
             'Expected version formatted as '
             '<image tag>|<git hash>, got {}'.format(version), )
     return ImageNameT(version)
Exemplo n.º 4
0
 def version_to_image_name(self, version: VersionT) -> ImageNameT:
     """
     Returns the image tag from the version string.
     (i.e) 0.3.68-1541626353-d1c29db1 -> d1c29db1
     """
     parts = version.split("-")
     if len(parts) != 3:
         raise ValueError("Unknown version format: %s" % version)
     return ImageNameT("%s" % parts[2])