Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor/workload-service #75

Merged
merged 6 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
NSC_PATH = "<path/to/nsc_dir>"
# ALL
NSC_PATH="<path/to/nsc_dir>"
NATS_URL="nats:/<domain>:<port>"
NATS_LISTEN_PORT="<port>"
LOCAL_CREDS_PATH="<path/to/dir>"

# HOSTING AGENT
HOST_CREDS_FILE_PATH = "ops/admin.creds"
MONGO_URI = "mongodb://<host>:<port>"
NATS_HUB_SERVER_URL = "nats://<path/to/leaf>:<port>"
LEAF_SERVER_DEFAULT_LISTEN_PORT="4111"
LEAF_SERVER_USER = "test-user"
LEAF_SERVER_PW = "pw-123456789"
LEAF_SERVER_PW = "pw-123456789"
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ target/
rust/*/tmp
rust/*/jwt
rust/*/*/test_leaf_server/*
rust/*/*/test_leaf_server.conf
rust/*/*/*.conf
rust/*/*/leaf_server.conf
rust/*/*/resolver.conf
leaf_server.conf
Expand Down
30 changes: 29 additions & 1 deletion Cargo.lock

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

13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,11 @@ The code is grouped by language or framework name.
/Cargo.toml
/Cargo.lock
/rust/ # all rust code lives here
/rust/common/Cargo.toml
/rust/common/src/lib.rs
/rust/holo-agentctl/Cargo.toml
/rust/holo-agentctl/src/main.rs
/rust/holo-agentd/Cargo.toml
/rust/holo-agentd/src/main.rs
/rust/holo-hqd/Cargo.toml
/rust/holo-hqd/src/main.rs
/rust/clients/
/rust/services/
/rust/hpos-hal/
/rust/netdiag/
/rust/util_libs/
```

### Pulumi for Infrastructure-as-Code
Expand Down
6 changes: 5 additions & 1 deletion nix/lib/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{ inputs, flake, ... }:
{
inputs,
flake,
...
}:

{
mkCraneLib =
Expand Down
2 changes: 1 addition & 1 deletion nix/modules/nixos/holo-nats-server.nix
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,4 @@ in
}
);
};
}
}
17 changes: 8 additions & 9 deletions rust/clients/host_agent/src/gen_leaf_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ use std::{path::PathBuf, time::Duration};

use anyhow::Context;
use tempfile::tempdir;
use util_libs::{
nats_js_client,
nats_server::{
use util_libs::nats::{
jetstream_client,
leaf_server::{
JetStreamConfig, LeafNodeRemote, LeafNodeRemoteTlsConfig, LeafServer, LoggingOptions,
LEAF_SERVER_CONFIG_PATH, LEAF_SERVER_DEFAULT_LISTEN_PORT,
},
types::JsClientBuilder,
};

pub async fn run(
Expand All @@ -17,7 +18,7 @@ pub async fn run(
hub_url: String,
hub_tls_insecure: bool,
nats_connect_timeout_secs: u64,
) -> anyhow::Result<nats_js_client::JsClient> {
) -> anyhow::Result<jetstream_client::JsClient> {
let leaf_client_conn_domain = "127.0.0.1";
let leaf_client_conn_port = std::env::var("NATS_LISTEN_PORT")
.map(|var| var.parse().expect("can't parse into number"))
Expand Down Expand Up @@ -95,22 +96,20 @@ pub async fn run(
// Spin up Nats Client
// Nats takes a moment to become responsive, so we try to connecti in a loop for a few seconds.
// TODO: how do we recover from a connection loss to Nats in case it crashes or something else?
let nats_url = nats_js_client::get_nats_url();
let nats_url = jetstream_client::get_nats_url();
log::info!("nats_url : {}", nats_url);

const HOST_AGENT_CLIENT_NAME: &str = "Host Agent Bare";

let nats_client = tokio::select! {
client = async {loop {
let host_workload_client = nats_js_client::JsClient::new(nats_js_client::NewJsClientParams {
let host_workload_client = jetstream_client::JsClient::new(JsClientBuilder {
nats_url:nats_url.clone(),
name:HOST_AGENT_CLIENT_NAME.to_string(),
ping_interval:Some(Duration::from_secs(10)),
request_timeout:Some(Duration::from_secs(29)),

inbox_prefix: Default::default(),
service_params:Default::default(),
opts: Default::default(),
listeners: Default::default(),
credentials_path: Default::default()
})
.await
Expand Down
Loading