This repository has been archived by the owner on Apr 24, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor cook so that we generate both k8s and mesos pool names. (#1305)
* Split default pools into parallel k8s and mesos pools. Refactor preparation for doing a hybrid k8s+mesos simultaneously. config-k8s and config pass integration tests for mesos + k8s. * Added seed_k8s_pools command for generating k8s pools.
- Loading branch information
Showing
8 changed files
with
68 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
(ns data.seed-k8s-pools | ||
(:require [cook.datomic :as datomic] | ||
[cook.quota :as quota] | ||
[datomic.api :as d])) | ||
|
||
(def uri (second *command-line-args*)) | ||
(println "Datomic URI is" uri) | ||
|
||
(defn create-pool | ||
[conn name state] | ||
(println "Creating pool" name) | ||
@(d/transact conn [{:db/id (d/tempid :db.part/user) | ||
:pool/name name | ||
:pool/purpose "This is a pool for testing purposes" | ||
:pool/state state | ||
:pool/dru-mode :pool.dru-mode/default}])) | ||
|
||
(defn pools | ||
[db] | ||
(->> (d/q '[:find [?p ...] | ||
:in $ [?state ...] | ||
:where | ||
[?p :pool/state ?state]] | ||
db [:pool.state/active :pool.state/inactive]) | ||
(map (partial d/entity db)) | ||
(map d/touch))) | ||
|
||
(try | ||
(let [conn (datomic/create-connection {:settings {:mesos-datomic-uri uri}})] | ||
(println "Connected to Datomic:" conn) | ||
(create-pool conn "k8s-alpha" :pool.state/active) | ||
(create-pool conn "k8s-beta" :pool.state/inactive) | ||
(create-pool conn "k8s-gamma" :pool.state/active) | ||
(create-pool conn "k8s-delta" :pool.state/inactive) | ||
(quota/set-quota! conn "default" "k8s-alpha" "For quota-related testing." :cpus 8 :mem 1024) | ||
(quota/set-quota! conn "default" "k8s-gamma" "For quota-related testing." :cpus 9 :mem 2048) | ||
(println "Pools & Quotas:") | ||
(run! (fn [{:keys [pool/name] :as p}] | ||
(clojure.pprint/pprint p) | ||
(clojure.pprint/pprint (quota/get-quota (d/db conn) "default" name))) | ||
(pools (d/db conn))) | ||
(System/exit 0)) | ||
(catch Throwable t | ||
(println "Failed to seed pools:" t) | ||
(System/exit 1))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters