-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat(env): patchable environments, named timelines #119
Conversation
b469daa
to
f7c856e
Compare
pool: &'a HashMap<AgentId, Agent>, | ||
) -> impl Iterator<Item = &'a Agent> + 'a { | ||
pool: &'a DashMap<AgentId, Agent>, | ||
) -> impl Iterator<Item = dashmap::mapref::one::Ref<'a, AgentId, Agent>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dashmap::mapref::one::Ref
impls Deref<Target = Agent>
, so you should be able to make the iterator item a &'a Agent
again if you return &*pool.get(&id)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried your suggestion and a few other methods for getting an &Agent
but none of them worked out.
&*pool.get(&id)
-> can't deref an Optionpool.get(&id).map(|r| &*r)
-> returns a value referencing data owned by the current functionpool.get(&id).map(|a| a.value())
-> same as ^
@@ -576,24 +653,28 @@ pub async fn initial_reconcile(env_id: EnvId, state: &GlobalState) -> Result<(), | |||
let not_me = |agent: &AgentPeer| !matches!(agent, AgentPeer::Internal(candidate_id, _) if *candidate_id == id); | |||
|
|||
node_state.peers = env | |||
.matching_nodes(&node.peers, &pool_lock, PortType::Node) | |||
.matching_nodes(&node.peers, &state.pool, PortType::Node) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this is a non-issue but part of the problem of not keeping a lock on the whole pool as you make these changes sequentially is that you can introduce race conditions where other tasks can modify the pool state in between operations. Locking the whole pool for the start of this function did not have that problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer a lock for only agents within the given environment or this approach to globally locking any agents from making changes for an unrelated timeline locking unrelated agents out of state updates
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Holding locks on the pool is always instantaneous; locks are never held over asynchronously executing code. DashMaps introduce scary new deadlock possibilities since locking is implicit and handled internally
Signed-off-by: Zander Franks <[email protected]>
env prepare
now can add/remove new nodes without restarting the entire environment automatically restarts agents with updated peersdefault
. this means runningsnops-cli env prepare ./spec/my-test.yaml
will automatically prepare thedefault
env