diff --git a/pulumi-operator-base/src/stack/service.rs b/pulumi-operator-base/src/stack/service.rs index 6daceb4..745525c 100644 --- a/pulumi-operator-base/src/stack/service.rs +++ b/pulumi-operator-base/src/stack/service.rs @@ -12,6 +12,9 @@ pub enum PulumiStackServiceError { #[error("Configuration error: {0}")] Config(Box), + + #[error("pulumi stack update failed: {0}")] + UpdateFailed(Box), } #[injectable] diff --git a/pulumi-operator-kubernetes-job/Cargo.toml b/pulumi-operator-kubernetes-job/Cargo.toml index 70d6f5c..c04d9eb 100644 --- a/pulumi-operator-kubernetes-job/Cargo.toml +++ b/pulumi-operator-kubernetes-job/Cargo.toml @@ -16,7 +16,7 @@ serde_json = "1.0.100" log = "0.4.19" futures = "0.3.28" tracing = "0.1.37" -pulumi-operator-kubernetes = { path = "../pulumi-operator-kubernetes" } +pulumi-operator-kubernetes = { path = "../pulumi-operator-kubernetes", default-features = false} pulumi-operator-base = { path = "../pulumi-operator-base" } k8s-openapi = { version = "0.19.0", features = ["v1_26"] } kube = { version = "0.85.0", features = ["runtime", "derive", "admission"] } diff --git a/pulumi-operator-kubernetes/Cargo.toml b/pulumi-operator-kubernetes/Cargo.toml index 4192ad3..23017b3 100644 --- a/pulumi-operator-kubernetes/Cargo.toml +++ b/pulumi-operator-kubernetes/Cargo.toml @@ -22,3 +22,5 @@ warp = "0.3.5" [features] install-crds = [] +boot = [] +default = ["boot"] \ No newline at end of file diff --git a/pulumi-operator-kubernetes/src/stack/controller_strategy.rs b/pulumi-operator-kubernetes/src/stack/controller_strategy.rs index d075dee..ac38d56 100644 --- a/pulumi-operator-kubernetes/src/stack/controller_strategy.rs +++ b/pulumi-operator-kubernetes/src/stack/controller_strategy.rs @@ -144,6 +144,7 @@ impl KubernetesPulumiStackControllerStrategy { // self.start_admission_controller().await?; *self.controller_stream.lock().await = Some(Box::pin(controller) as _); + println!("sososo"); Ok(()) } @@ -191,6 +192,7 @@ impl KubernetesPulumiStackControllerStrategy { #[async_trait] impl PulumiStackControllerStrategy for KubernetesPulumiStackControllerStrategy { async fn initialize(&self) -> Result<(), PulumiStackControllerStrategyError> { + #[cfg(feature = "boot")] self.start_controller().await?; Ok(()) } diff --git a/pulumi-operator-kubernetes/src/stack/service.rs b/pulumi-operator-kubernetes/src/stack/service.rs index efaa369..45edd66 100644 --- a/pulumi-operator-kubernetes/src/stack/service.rs +++ b/pulumi-operator-kubernetes/src/stack/service.rs @@ -38,12 +38,12 @@ impl PulumiStackService for KubernetesPulumiStackService { .operator_namespace() .map_err(|e| PulumiStackServiceError::Config(Box::new(e)))?; // TODO - dbg!("Update stack123"); let job = serde_json::from_value(json!({ "apiVersion": "batch/v1", "kind": "Job", "metadata": { - "name": name + "name": name, + "namespace": "pulumi-operator" }, "spec": { "template": { @@ -53,7 +53,7 @@ impl PulumiStackService for KubernetesPulumiStackService { "spec": { "containers": [{ "name": "pulumi", - "image": "ghcr.io/stromee/pulumi-operator/pulumi-operator-kubernetes-job:1.0.2", + "image": "ghcr.io/stromee/pulumi-operator/pulumi-operator-kubernetes-job:1.0.4", "env": [{ "name": "PULUMI_STACK", "value": name @@ -65,23 +65,27 @@ impl PulumiStackService for KubernetesPulumiStackService { "value": operator_namespace }] }], + "serviceAccountName": "superuser", "imagePullPolicy": "Always", "restartPolicy": "Never" } }, - "backoffLimit": 5 + "backoffLimit": 100 } })) - .expect("todo"); + .map_err(|err| PulumiStackServiceError::UpdateFailed(err.into()))?; let api = self .kubernetes_service - .all_in_namespace_api::(namespace) + .all_in_namespace_api::("pulumi-operator") .await; + api .create(&PostParams::default(), &job) .await - .expect("todo"); + .map_err(|err| PulumiStackServiceError::UpdateFailed(err.into()))?; + dbg!("Update stack123"); + Ok(()) } @@ -94,7 +98,7 @@ impl PulumiStackService for KubernetesPulumiStackService { let name = parts.next().unwrap(); let api = self .kubernetes_service - .all_in_namespace_api::(namespace) + .all_in_namespace_api::("pulumi-operator") .await; if api.get(name).await.is_err() {