(
&self,
kube_client: &kube::Client,
kubernetes_config: &Path,
envs: &[(&str, &str)],
payload: Option<ChartPayload>,
cmd_killer: &CommandKiller,
)
| 992 | } |
| 993 | |
| 994 | fn pre_exec( |
| 995 | &self, |
| 996 | kube_client: &kube::Client, |
| 997 | kubernetes_config: &Path, |
| 998 | envs: &[(&str, &str)], |
| 999 | payload: Option<ChartPayload>, |
| 1000 | cmd_killer: &CommandKiller, |
| 1001 | ) -> Result<Option<ChartPayload>, HelmChartError> { |
| 1002 | // Cleaning any existing crash looping pod for this helm chart |
| 1003 | if let Some(selector) = self.get_selector() { |
| 1004 | kubectl_delete_crash_looping_pods( |
| 1005 | kubernetes_config, |
| 1006 | Some(self.get_chart_info().get_namespace_string().as_str()), |
| 1007 | Some(selector.as_str()), |
| 1008 | envs.to_vec(), |
| 1009 | )?; |
| 1010 | } |
| 1011 | |
| 1012 | // Force install CRDs if needed |
| 1013 | let chart_info = &self.get_chart_info(); |
| 1014 | match chart_info.action { |
| 1015 | Deploy => { |
| 1016 | if let Some(crds_update) = &chart_info.crds_update |
| 1017 | && let Err(_e) = |
| 1018 | kubectl_update_crd(kube_client, chart_info.name.as_str(), crds_update.path.as_str()) |
| 1019 | { |
| 1020 | return Err(HelmChartError::CannotUpdateCrds { |
| 1021 | crd_path: crds_update.path.clone(), |
| 1022 | }); |
| 1023 | } |
| 1024 | } |
| 1025 | HelmAction::Destroy => {} |
| 1026 | } |
| 1027 | |
| 1028 | let helm = Helm::new(Some(kubernetes_config), envs)?; |
| 1029 | |
| 1030 | // deploy VPA if exists |
| 1031 | let vpa_chart = match &self.vertical_pod_autoscaler { |
| 1032 | Some(vpa) => self.get_vpa_chart_info(Some(vpa.clone())), |
| 1033 | None => self.get_vpa_chart_info(None), |
| 1034 | }; |
| 1035 | warn!("VPA CHART ++++++++++++++++++++++++++++++++ {:?}", &vpa_chart); |
| 1036 | // Deploy VPA if both VPA and parent are in Deploy mode, otherwise uninstall it |
| 1037 | match (&chart_info.action, &vpa_chart.action) { |
| 1038 | (Deploy, Deploy) => { |
| 1039 | warn!("UPGRADE VPA CHART ++++++++++++++++++++++++++++++++"); |
| 1040 | helm.upgrade(&vpa_chart, &[], cmd_killer)?; |
| 1041 | } |
| 1042 | _ => { |
| 1043 | warn!("UNINSTALL VPA CHART ++++++++++++++++++++++++++++++++"); |
| 1044 | helm.uninstall(&vpa_chart, &[], cmd_killer, &mut |_| {}, &mut |_| {})?; |
| 1045 | } |
| 1046 | } |
| 1047 | |
| 1048 | Ok(payload) |
| 1049 | } |
| 1050 | |
| 1051 | fn post_exec( |
no test coverage detected