Skip to content

Commit

Permalink
Use project revision with gordo-components (#79)
Browse files Browse the repository at this point in the history
* Update to match gordo-components using project-revision

From: equinor/gordo#804

* Bump version 0.5.0 -> 0.6.0

* Keep setting old workflow gen ..PROJECT_VERSION

For backward compatability
  • Loading branch information
milesgranger authored Dec 19, 2019
1 parent df9bb58 commit 38d0e8b
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 11 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 Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "gordo-controller"
version = "0.5.0"
version = "0.6.0"
authors = ["Miles Granger <[email protected]>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion examples/apply_gordo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async fn main() {

// Update the model to match the project-revision set by the controller
model.metadata.labels.insert(
"applications.gordo.equinor.com/project-version".to_owned(),
"applications.gordo.equinor.com/project-revision".to_owned(),
gordo.status.unwrap().project_revision,
);

Expand Down
4 changes: 2 additions & 2 deletions examples/query_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
while let Ok(gordo) = gordo_api.get(&gordo.metadata.name).await {
match gordo.status {
Some(status) => {
// Update this model's project-version to match the revision number given to the owning Gordo
// Update this model's project-revision to match the revision number given to the owning Gordo
model.metadata.labels.insert(
"applications.gordo.equinor.com/project-version".to_string(),
"applications.gordo.equinor.com/project-revision".to_string(),
status.project_revision,
);
break;
Expand Down
6 changes: 3 additions & 3 deletions k8s/model-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ spec:
description: Current status of the model
name: ModelStatus
type: string
- JSONPath: .metadata.labels.applications\.gordo\.equinor\.com/project-version
description: Project version
name: Project version
- JSONPath: .metadata.labels.applications\.gordo\.equinor\.com/project-revision
description: Project revision
name: Project revision
type: string
- JSONPath: .metadata.labels.applications\.gordo\.equinor\.com/project-name
description: Project name
Expand Down
12 changes: 10 additions & 2 deletions src/crd/model/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub fn load_model_resource(client: &APIClient, namespace: &str) -> Api<Model> {
}

/// Filter a collection of models to match a `Gordo` based on `OwnerReference`
/// and the project-version of the `Model` matches the project-revision of the `Gordo`
/// and the project-revision of the `Model` matches the project-revision of the `Gordo`
pub fn filter_models_on_gordo<'a>(gordo: &'a Gordo, models: &'a [Model]) -> impl Iterator<Item = &'a Model> {
models
.iter()
Expand All @@ -59,7 +59,15 @@ pub fn filter_models_on_gordo<'a>(gordo: &'a Gordo, models: &'a [Model]) -> impl
model
.metadata
.labels
.get("applications.gordo.equinor.com/project-version")
.get("applications.gordo.equinor.com/project-revision")
// TODO: Here for compatibility when gordo-components <= 0.46.0 used 'project-version' to refer to 'project-revision'
// TODO: can remove when people have >= 0.47.0 of gordo
.or_else(|| {
model
.metadata
.labels
.get("applications.gordo.equinor.com/project-version")
})
== Some(&status.project_revision)
}
None => false,
Expand Down
3 changes: 3 additions & 0 deletions src/deploy_job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ impl DeployJob {
Self::env_var("ARGO_SUBMIT", "true"),
Self::env_var("WORKFLOW_GENERATOR_PROJECT_NAME", &gordo.metadata.name),
Self::env_var("WORKFLOW_GENERATOR_OWNER_REFERENCES", &owner_ref_as_string),
Self::env_var("WORKFLOW_GENERATOR_PROJECT_REVISION", &project_revision),

// TODO: Backward compat. Until all have moved >=0.47.0 of gordo-components
Self::env_var("WORKFLOW_GENERATOR_PROJECT_VERSION", &project_revision),
];

Expand Down
2 changes: 1 addition & 1 deletion tests/test_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ fn test_deploy_job_injects_project_version() {
.as_ref()
.unwrap()
.iter()
.any(|ev| ev.name == "WORKFLOW_GENERATOR_PROJECT_VERSION"));
.any(|ev| ev.name == "WORKFLOW_GENERATOR_PROJECT_REVISION"));
}

#[test]
Expand Down

0 comments on commit 38d0e8b

Please sign in to comment.