Skip to content

Commit

Permalink
update scaler and fix dockerfile ems download
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Kunde committed Jul 28, 2022
1 parent 10f86c6 commit 4d46c55
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM rust as emslibs
# fetch an update version of the link under
# https://www.tibco.com/products/tibco-messaging/downloads
RUN curl -O 'https://edownloads.tibco.com/Installers/tap/EMS-CE/10.1.0/TIB_ems-ce_10.1.0_linux_x86_64.zip?SJCDPTPG=1657851245_a779bde8aa7f49b2b394698b7a2e043d&ext=.zip'
RUN curl -O 'https://edownloads.tibco.com/Installers/tap/EMS-CE/10.1.0/TIB_ems-ce_10.1.0_linux_x86_64.zip?SJCDPTPG=1661559829_550d23e46bbb9e77f41490c38569103e&ext=.zip'
RUN unzip TIB*
RUN tar xzf TIB_ems-ce_10.1.0/tar/TIB_ems-ce_10.1.0_linux_x86_64-c_dev_kit.tar.gz
RUN tar xzf TIB_ems-ce_10.1.0/tar/TIB_ems-ce_10.1.0_linux_x86_64-c_dotnet_client.tar.gz
Expand Down
18 changes: 14 additions & 4 deletions src/scaler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,18 @@ pub async fn run(){
let client = Client::try_default().await.expect("getting default client");
let namespace = env_var!(required "KUBERNETES_NAMESPACE");
let deployments: Api<Deployment> = Api::namespaced(client, &namespace);
let lp = ListParams::default()
let mut lp = ListParams::default()
.labels("tibcoems.apimeister.com/scaling=true");

let responsible_for = super::RESPONSIBLE_FOR.lock().unwrap().clone();
if !responsible_for.is_empty() {
info!("scaling Deployments for instance {responsible_for}");
lp = lp.labels(format!("tibcoems.apimeister.com/owner={responsible_for}").as_str());
} else {
lp = lp.labels("!tibcoems.apimeister.com/owner");
info!("scaling Deployments without label: tibcoems.apimeister.com/owner ");
}

let mut interval = time::interval(Duration::from_millis(12000));
interval.tick().await;

Expand Down Expand Up @@ -282,9 +292,9 @@ pub async fn run(){
let mut max_scale = 10u32;
for (key,val) in labels {
if key.starts_with("tibcoems.apimeister.com/queue") {
//check known queues
//check queues on EMS Server
let queue_name = val;
let all_queues = super::queue::KNOWN_QUEUES.lock().unwrap();
let all_queues = super::queue::QUEUES.lock().unwrap();
if all_queues.contains_key(&queue_name) {
//known queue
if scale_targets.contains_key(&queue_name) {
Expand All @@ -301,7 +311,7 @@ pub async fn run(){
}
}else{
//queue does not exist
warn!("queue cannot be monitored, because it does not exists: {queue_name}");
warn!("queue cannot be monitored, because it does not exist on EMS: {queue_name}");
}
//add to trigger map
trigger_map.insert(d_name.clone(),0);
Expand Down

0 comments on commit 4d46c55

Please # to comment.