1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Fix bugs in helm releases (#4785)

* Fix opening of upgrade release tab

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Bring back ability to rollback to specific revision

Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com>

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Fix helm releases not updating after rollback

Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com>

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Fix helm releases not updating after upgrade

Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com>

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne Savolainen 2022-02-01 15:18:43 +01:00 committed by GitHub
parent c1d557aeee
commit e8205a64b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 11 deletions

View File

@ -179,12 +179,13 @@ export async function getHistory(name: string, namespace: string, kubeconfigPath
} }
export async function rollback(name: string, namespace: string, revision: number, kubeconfigPath: string) { export async function rollback(name: string, namespace: string, revision: number, kubeconfigPath: string) {
return JSON.parse(await execHelm([ await execHelm([
"rollback", "rollback",
name, name,
`${revision}`,
"--namespace", namespace, "--namespace", namespace,
"--kubeconfig", kubeconfigPath, "--kubeconfig", kubeconfigPath,
])); ]);
} }
async function getResources(name: string, namespace: string, kubeconfigPath: string, kubectlPath: string) { async function getResources(name: string, namespace: string, kubeconfigPath: string, kubectlPath: string) {

View File

@ -102,9 +102,7 @@ class HelmService {
const proxyKubeconfig = await cluster.getProxyKubeconfigPath(); const proxyKubeconfig = await cluster.getProxyKubeconfigPath();
logger.debug("Rollback release"); logger.debug("Rollback release");
const output = rollback(releaseName, namespace, revision, proxyKubeconfig); await rollback(releaseName, namespace, revision, proxyKubeconfig);
return { message: output };
} }
} }

View File

@ -71,9 +71,9 @@ export class HelmApiRoute {
const { cluster, params, payload, response } = request; const { cluster, params, payload, response } = request;
try { try {
const result = await helmService.rollback(cluster, params.release, params.namespace, payload.revision); await helmService.rollback(cluster, params.release, params.namespace, payload.revision);
respondJson(response, result); response.end();
} catch (error) { } catch (error) {
logger.debug(error); logger.debug(error);
respondText(response, error?.toString() || "Error rolling back chart", 422); respondText(response, error?.toString() || "Error rolling back chart", 422);

View File

@ -3,10 +3,29 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable"; import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { updateRelease } from "../../../../common/k8s-api/endpoints/helm-releases.api"; import {
IReleaseUpdatePayload,
updateRelease,
} from "../../../../common/k8s-api/endpoints/helm-releases.api";
import releasesInjectable from "../releases.injectable";
const updateReleaseInjectable = getInjectable({ const updateReleaseInjectable = getInjectable({
instantiate: () => updateRelease, instantiate: (di) => {
const releases = di.inject(releasesInjectable);
return async (
name: string,
namespace: string,
payload: IReleaseUpdatePayload,
) => {
const result = await updateRelease(name, namespace, payload);
releases.invalidate();
return result;
};
},
lifecycle: lifecycleEnum.singleton, lifecycle: lifecycleEnum.singleton,
}); });

View File

@ -136,8 +136,8 @@ export class NonInjectedUpgradeChart extends React.Component<Props & Dependencie
const { tabId, release, value, error, onChange, onError, upgrade, versions, version } = this; const { tabId, release, value, error, onChange, onError, upgrade, versions, version } = this;
const { className } = this.props; const { className } = this.props;
if (!release || this.props.upgradeChartTabStore.isReady(tabId) || !version) { if (!release || !this.props.upgradeChartTabStore.isReady(tabId) || !version) {
return <Spinner center/>; return <Spinner center />;
} }
const currentVersion = release.getVersion(); const currentVersion = release.getVersion();
const controlsAndInfo = ( const controlsAndInfo = (