(&self, infra_ctx: &InfrastructureContext, action: Action)
| 53 | ) -> Result<(), Box<EngineError>>; |
| 54 | |
| 55 | fn run(&self, infra_ctx: &InfrastructureContext, action: Action) -> Result<(), Box<EngineError>> { |
| 56 | let step = match action { |
| 57 | Action::Create => InfrastructureStep::Create, |
| 58 | Action::Pause => InfrastructureStep::Pause, |
| 59 | Action::Delete => InfrastructureStep::Delete, |
| 60 | Action::Restart => InfrastructureStep::RestartedError, |
| 61 | }; |
| 62 | let logger = mk_logger(infra_ctx.kubernetes(), step); |
| 63 | let kubernetes = infra_ctx.kubernetes(); |
| 64 | let cloud_provider = infra_ctx.cloud_provider(); |
| 65 | if infra_ctx.context().is_dry_run_deploy() { |
| 66 | logger.warn("👻 Dry run mode is enabled. No changes will be made to the infrastructure"); |
| 67 | } |
| 68 | |
| 69 | logger.info(format!( |
| 70 | "{} {} cluster {}", |
| 71 | action, |
| 72 | infra_ctx.kubernetes().kind(), |
| 73 | infra_ctx.kubernetes().name() |
| 74 | )); |
| 75 | |
| 76 | match action { |
| 77 | Action::Create => { |
| 78 | let mut cluster_has_been_upgraded = false; |
| 79 | if infra_ctx.context().is_first_cluster_deployment() { |
| 80 | self.bootstap_cluster(infra_ctx)?; |
| 81 | } else if let Some(upgrade_status) = self.is_upgrade_required(infra_ctx) { |
| 82 | let kube_client = infra_ctx.mk_kube_client()?; |
| 83 | let event_details = kubernetes.get_event_details(Infrastructure(InfrastructureStep::Upgrade)); |
| 84 | let cluster_id = infra_ctx.context().cluster_long_id(); |
| 85 | |
| 86 | logger.info("Check if cluster has no calls to deprecated kubernetes API in next version"); |
| 87 | info!( |
| 88 | "Running deprecated API compatibility check with scanner `pluto` for cluster `{}`", |
| 89 | cluster_id |
| 90 | ); |
| 91 | let compatibility_check = infra_ctx |
| 92 | .kubernetes_api_deprecation_service() |
| 93 | .is_cluster_fully_compatible_with_kubernetes_version( |
| 94 | kubernetes.kubeconfig_local_file_path().as_path(), |
| 95 | Some(&upgrade_status.requested_version), |
| 96 | &cloud_provider.credentials_environment_variables(), |
| 97 | KubernetesApiDeprecationServiceGranuality::WithQoveryMetadata { |
| 98 | kube_client: kube_client.as_ref(), |
| 99 | }, |
| 100 | ); |
| 101 | |
| 102 | match compatibility_check { |
| 103 | Ok(_) => logger.info("Cluster is compatible with the next version"), |
| 104 | Err(e) => { |
| 105 | return Err(Box::new(EngineError::new_k8s_deprecated_api_calls_found_error( |
| 106 | event_details.clone(), |
| 107 | &upgrade_status.requested_version, |
| 108 | e, |
| 109 | ))); |
| 110 | } |
| 111 | } |
| 112 |
no test coverage detected