From f1873ef3c1fa696ea0a5462bbc1e53342a112e85 Mon Sep 17 00:00:00 2001 From: J Robert Ray Date: Tue, 8 Aug 2023 14:21:50 -0700 Subject: [PATCH] Change SPK_REQUEST_PRIORITY_ORDER to use spk config Pull the default value for this, if any, from the spk config file. Remove custom env var name in lieu of using the standard method of setting config settings via env vars. Signed-off-by: J Robert Ray --- .site/spi/spk.toml | 1 + Cargo.lock | 1 + crates/spk-config/src/config.rs | 4 ++++ crates/spk-solve/crates/graph/Cargo.toml | 10 ++++++---- crates/spk-solve/crates/graph/src/graph.rs | 7 +++---- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/.site/spi/spk.toml b/.site/spi/spk.toml index 21a57bbfd8..ffa3fd720b 100644 --- a/.site/spi/spk.toml +++ b/.site/spi/spk.toml @@ -6,6 +6,7 @@ username_override_var = "GITLAB_USER_LOGIN" [solver] build_key_name_order = "gcc,python" +request_priority_order = "*platform*" [statsd] host = "statsd.k8s.spimageworks.com" diff --git a/Cargo.lock b/Cargo.lock index a156a5c9e9..799a168f17 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3930,6 +3930,7 @@ dependencies = [ "serde_json", "serde_yaml 0.9.25", "spfs", + "spk-config", "spk-schema", "spk-solve-package-iterator", "spk-solve-solution", diff --git a/crates/spk-config/src/config.rs b/crates/spk-config/src/config.rs index 001ea24835..bcee0f5feb 100644 --- a/crates/spk-config/src/config.rs +++ b/crates/spk-config/src/config.rs @@ -75,6 +75,10 @@ pub struct Solver { /// Comma-separated list of option names to promote to the front of the /// build key order. pub build_key_name_order: String, + + /// Comma-separated list of option names to promote to the front of the + /// resolve order. + pub request_priority_order: String, } #[derive(Clone, Default, Debug, Deserialize, Serialize)] diff --git a/crates/spk-solve/crates/graph/Cargo.toml b/crates/spk-solve/crates/graph/Cargo.toml index 3a49e8c995..eb814dbc37 100644 --- a/crates/spk-solve/crates/graph/Cargo.toml +++ b/crates/spk-solve/crates/graph/Cargo.toml @@ -6,10 +6,11 @@ version = { workspace = true } [features] migration-to-components = [ - "spk-solve-package-iterator/migration-to-components", - "spk-solve-solution/migration-to-components", - "spk-schema/migration-to-components", - "spk-storage/migration-to-components", + "spk-config/migration-to-components", + "spk-solve-package-iterator/migration-to-components", + "spk-solve-solution/migration-to-components", + "spk-schema/migration-to-components", + "spk-storage/migration-to-components", ] [dependencies] @@ -25,6 +26,7 @@ once_cell = { workspace = true } priority-queue = "1.2" serde_json = { workspace = true } spfs = { path = "../../../spfs" } +spk-config = { path = "../../../spk-config" } spk-solve-package-iterator = { path = "../package-iterator" } spk-solve-solution = { path = "../solution" } spk-schema = { path = "../../../spk-schema" } diff --git a/crates/spk-solve/crates/graph/src/graph.rs b/crates/spk-solve/crates/graph/src/graph.rs index 724aac6500..515b418abb 100644 --- a/crates/spk-solve/crates/graph/src/graph.rs +++ b/crates/spk-solve/crates/graph/src/graph.rs @@ -4,7 +4,6 @@ use std::collections::hash_map::{DefaultHasher, Entry}; use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque}; -use std::ffi::OsString; use std::hash::{Hash, Hasher}; use std::iter::FromIterator; use std::sync::atomic::{AtomicU64, Ordering}; @@ -48,9 +47,9 @@ const BRANCH_ALREADY_ATTEMPTED: &str = "Branch already attempted"; /// front of the request list. static REQUESTS_PRIORITY_ORDER: Lazy = Lazy::new(|| { PromotionPatterns::new( - std::env::var_os("SPK_REQUEST_PRIORITY_ORDER") - .unwrap_or_else(|| OsString::from("*platform*")) - .to_string_lossy() + spk_config::get_config() + .map(|c| c.solver.request_priority_order.clone()) + .unwrap_or_else(|_| "".to_string()) .as_ref(), ) });