Skip to content

Commit

Permalink
Merge branch '120722/simplify-idempotency-token'
Browse files Browse the repository at this point in the history
  • Loading branch information
mach-kernel committed Dec 7, 2022
2 parents 5eac87e + d0c04cd commit 4423c72
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 47 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion charts/databricks-kube-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.3.0
version: 0.3.1

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
2 changes: 1 addition & 1 deletion charts/databricks-kube-operator/templates/sts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
terminationGracePeriodSeconds: 10
containers:
- name: dko
image: ghcr.io/mach-kernel/databricks-kube-operator:0.3.0
image: ghcr.io/mach-kernel/databricks-kube-operator:0.3.1
imagePullPolicy: Always
env:
- name: DATABRICKS_KUBE_CONFIGMAP
Expand Down
2 changes: 1 addition & 1 deletion databricks-kube/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ path = "src/crdgen.rs"
[package]
name = "databricks_kube"
default-run = "databricks_kube"
version = "0.3.0"
version = "0.3.1"
edition = "2021"

[dependencies]
Expand Down
48 changes: 6 additions & 42 deletions databricks-kube/src/crds/databricks_job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,38 +230,10 @@ impl RemoteAPIResource<Job> for DatabricksJob {
return async { Ok(()) }.boxed();
}

log::info!(
"{} has a run request defined, looking for running jobs...",
self.name_unchecked()
);
log::info!("Ensuring defined run for {}...", self.name_unchecked());

async move {
let mut all_runs: Vec<Run> = Vec::new();

let config = Job::get_rest_config(context.clone()).await.unwrap();
while let JobsRunsList200Response { has_more, runs } = default_api::jobs_runs_list(
&config,
Some(true),
Some(false),
job_id,
Some(all_runs.len() as i32),
None,
None,
None,
None,
None,
)
.await?
{
all_runs.extend(runs.iter().flatten().map(Clone::clone));
if !has_more.unwrap_or(false) {
break;
}
}

log::info!("{} has {} active runs", &self_name, all_runs.len());

let newest_run_id = all_runs.first().map(|r| r.run_id).unwrap_or(Some(-1));

let mut run_request = JobsRunNowRequest {
job_id,
Expand All @@ -271,19 +243,11 @@ impl RemoteAPIResource<Job> for DatabricksJob {

let triggered = default_api::jobs_run_now(&config, Some(run_request)).await?;

if newest_run_id.unwrap() == triggered.run_id.unwrap() {
log::info!(
"{} idempotency token matches; run_id still {}",
&self_name,
newest_run_id.unwrap()
);
} else {
log::info!(
"{} triggered new run_id: {}",
&self_name,
triggered.run_id.unwrap(),
);
}
log::info!(
"Job {} reconciled run {}",
&self_name,
triggered.run_id.unwrap(),
);

Ok::<(), DatabricksKubeError>(())
}
Expand Down
2 changes: 1 addition & 1 deletion tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ In `Chart.yaml`, add a dependency to the operator chart:
dependencies:
- name: databricks-kube-operator
repository: https://mach-kernel.github.io/databricks-kube-operator
version: 0.2.0
version: 0.3.1
```
## Populating Databricks resources
Expand Down

0 comments on commit 4423c72

Please sign in to comment.