-
Notifications
You must be signed in to change notification settings - Fork 267
Add UUID to DnaConfig and disable integrity check if UUID is specified #1724
Conversation
bde5478
to
0548876
Compare
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.
Hi! I'm trying out reviewing PRs so I can get more familiar with the code. I hope you take a look at these suggestions :)
// self.config.dnas.iter_mut().fing(|dna_config| dna_config.id == instance_config.dna) | ||
// .map(|dna_config| { | ||
|
||
// }) |
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.
Did you mean to leave this comment here?
conductor_api/src/conductor/base.rs
Outdated
@@ -750,7 +750,11 @@ impl Conductor { | |||
|
|||
// Get DNA | |||
|
|||
let mut dna_config = self.config.dna_by_id(&instance_config.dna).unwrap(); |
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.
Was this a latent bug before? dna_by_id
clones its result so I doubt that mutating it has the desired effect. If so, it might be good to add a regression test.
@@ -478,6 +478,15 @@ impl Configuration { | |||
self.dnas.iter().find(|dc| &dc.id == id).cloned() | |||
} | |||
|
|||
/// Returns the DNA configuration with the given ID if present |
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 think this comment got copy-pasted unchanged :)
/// Returns the DNA configuration with the given ID if present | |
/// Updates the hash of the DNA with the given ID, returns true if it was present. |
let msg = format!("Conductor: Could not load DNA file {:?}.", &dna_file); | ||
log_error!(context, "{}", msg); |
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.
No need to use format!
and allocate a String
just to pass it as a format-arg. Just format it in the log macro
let msg = format!("Conductor: Could not load DNA file {:?}.", &dna_file); | |
log_error!(context, "{}", msg); | |
log_error!(context, "Conductor: Could not load DNA file {:?}.", &dna_file); |
let msg = format!("\ | ||
Conductor: DNA hashes mismatch: 'Conductor config' != 'Conductor instance': \ | ||
'{}' != '{}'", | ||
&dna_hash_from_conductor_config, | ||
&dna_hash_computed); | ||
log_error!(context, "{}", msg); |
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.
No need to use format! and allocate a String just to pass it as a format-arg. Just format it in the log macro
let msg = format!("\ | |
Conductor: DNA hashes mismatch: 'Conductor config' != 'Conductor instance': \ | |
'{}' != '{}'", | |
&dna_hash_from_conductor_config, | |
&dna_hash_computed); | |
log_error!(context, "{}", msg); | |
log_error!( | |
context, | |
"Conductor: DNA hashes mismatch: \ | |
'Conductor config' != 'Conductor instance': \ | |
'{}' != '{}'", | |
&dna_hash_from_conductor_config, | |
&dna_hash_computed | |
); |
self.config.instances.push(new_instance_config); | ||
self.config.check_consistency(&mut self.dna_loader)?; | ||
let instance = self.instantiate_from_config(id)?; | ||
self.instances | ||
.insert(id.clone(), Arc::new(RwLock::new(instance))); | ||
self.config = new_config; | ||
self.save_config()?; |
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.
Hm, this change seems problematic to me. The old code would jump out in line 213 if the new config is bogus and not change self
at all. Now the new instance will always get added to self.config.instances
.
I don't understand why we need to change these lines at all. What is wrong with the old code?
new_config.instances.push(new_instance_config); | ||
new_config.check_consistency(&mut self.dna_loader)?; | ||
let instance = self.instantiate_from_config(id, Some(&mut new_config))?; | ||
self.config.instances.push(new_instance_config); |
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.
self.config.instances.push(new_instance_config); | |
// TODO: use cloned config to check consistency first, before setting self.confg | |
self.config.instances.push(new_instance_config); |
This got merged with #1725 |
PR summary
Allow dna.uuid to be specified as config. Previously the only way to set a UUID on a dna was by installing through the admin interface.
changelog
Please check one of the following, relating to the CHANGELOG-UNRELEASED.md
- summary of change [PR#1234](https://github.com/holochain/holochain-rust/pull/1234)