def get_installed_app_version(self, id_token): """ Returns the version of the deployed tool NOTE: This is the version coming from the helm chart `appVersion` field, **not** the version of the chart released in the user namespace. e.g. if user has `rstudio-2.2.5` (chart version) installed in his namespace, this would return "RStudio: 1.2.1335+conda, R: 3.5.1, Python: 3.7.1, patch: 10" **not** "2.2.5". Also bear in mind that Helm added this `appVersion` field only "recently" so if a user has an old version of a tool chart installed this would return `None` as we can't determine the tool version as this information is simply not available in the helm repository index. """ td = cluster.ToolDeployment(self.user, self.tool) chart_version = td.get_installed_chart_version(id_token) if chart_version: chart_info = HelmRepository.get_chart_info(self.tool.chart_name) version_info = chart_info.get(chart_version, None) if version_info: return version_info.app_version return None
def save(self, *args, **kwargs): """ Deploy the tool to the cluster (asynchronous) """ self._subprocess = cluster.ToolDeployment(self.user, self.tool).install()
def get_installed_chart_version(self, id_token): """ Returns the installed chart version for this tool Returns None if the chart is not installed for the user """ td = cluster.ToolDeployment(self.user, self.tool) return td.get_installed_chart_version(id_token)
def get_status(self, id_token): """ Get the current status of the deployment. Polls the subprocess if running, otherwise returns idled status. """ if self._subprocess: # poll subprocess and maybe parse any output to get status status = self._poll() if status: return status return cluster.ToolDeployment(self.user, self.tool).get_status(id_token)
def outdated(self, id_token): """ Returns true if the tool helm chart version is old NOTE: This is simple/naive at the moment and it returns true if the installed chart for the tool has a different version than the one in the corresponding Tool record. """ td = cluster.ToolDeployment(self.user, self.tool) chart_version = td.get_installed_chart_version(id_token) if chart_version: return self.tool.version != chart_version return False
def restart(self, id_token): """ Restart the tool deployment """ cluster.ToolDeployment(self.user, self.tool).restart(id_token)
def delete(self, id_token): """ Remove the release from the cluster """ cluster.ToolDeployment(self.user, self.tool).uninstall(id_token)