Skip to content

Commit

Permalink
Disable operator logic for pulumi job
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-br committed Sep 14, 2023
1 parent 693b84d commit 02ba5ad
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
3 changes: 3 additions & 0 deletions pulumi-operator-base/src/stack/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ pub enum PulumiStackServiceError {

#[error("Configuration error: {0}")]
Config(Box<dyn Error + Sync + Send>),

#[error("pulumi stack update failed: {0}")]
UpdateFailed(Box<dyn Error + Sync + Send>),
}

#[injectable]
Expand Down
2 changes: 1 addition & 1 deletion pulumi-operator-kubernetes-job/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
2 changes: 2 additions & 0 deletions pulumi-operator-kubernetes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ warp = "0.3.5"

[features]
install-crds = []
boot = []
default = ["boot"]
2 changes: 2 additions & 0 deletions pulumi-operator-kubernetes/src/stack/controller_strategy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ impl KubernetesPulumiStackControllerStrategy {
// self.start_admission_controller().await?;

*self.controller_stream.lock().await = Some(Box::pin(controller) as _);
println!("sososo");
Ok(())
}

Expand Down Expand Up @@ -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(())
}
Expand Down
20 changes: 12 additions & 8 deletions pulumi-operator-kubernetes/src/stack/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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
Expand All @@ -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::<Job>(namespace)
.all_in_namespace_api::<Job>("pulumi-operator")
.await;

api
.create(&PostParams::default(), &job)
.await
.expect("todo");
.map_err(|err| PulumiStackServiceError::UpdateFailed(err.into()))?;
dbg!("Update stack123");

Ok(())
}

Expand All @@ -94,7 +98,7 @@ impl PulumiStackService for KubernetesPulumiStackService {
let name = parts.next().unwrap();
let api = self
.kubernetes_service
.all_in_namespace_api::<Job>(namespace)
.all_in_namespace_api::<Job>("pulumi-operator")
.await;

if api.get(name).await.is_err() {
Expand Down

0 comments on commit 02ba5ad

Please sign in to comment.