-
Notifications
You must be signed in to change notification settings - Fork 427
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
move server file configuration parameter to relevant stores #2199
base: main
Are you sure you want to change the base?
move server file configuration parameter to relevant stores #2199
Conversation
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 had not started working on this so thanks for jumping in.
To me, this looks like a step in the right direction. Nice work.
My next ZoneConfig
question would be: are all of the existing ZoneType
variants compatible with all the store types, e.g. does ZoneType::Hint
make sense as an argument to FileAuthority::try_from_config
? does ZoneType::Primary
make sense as an argument to RecursorAuthority::try_from_config
?, etc.
It seems to me that ZoneType
should only have two variants: Primary
and Secondary
and that the {Recursive,Forward}Authority::try_from_config
constructors should have no ZoneType
parameters. Hence the zones.zone_type
setting should move into zones.stores.zone_type
, and only for the File
and Sqlite
variants of StoreConfig
.
pub fn get_file(&self) -> PathBuf { | ||
// TODO: Option on PathBuf | ||
PathBuf::from(self.file.as_ref().expect("file was none")) | ||
pub fn get_file(&self) -> Option<PathBuf> { |
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.
AFAICT this is currently not being used in the codebase so I don't know how this utility getter is meant to be used in practice but I think it may make sense to preserve what the underlying StoreConfig
variant was and return an enum alongside the path, e.g.
pub struct ZoneFile {
pub path: PathBuf,
pub kind: ZoneFileKind,
}
pub enum ZoneFileKind {
PlainText,
Sqlite,
}
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 also noticed this isn't used anywhere. Maybe one of the maintainers can shed some light on its purpose.
As I mentioned
to external users it previously generated a panic in valid None cases
so I wonder if anyone uses it at all
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.
Some of this was related to me being overly cautious when I had migrated some file formats in the past. It's probably fine for us to remove a lot of the deprecated use cases.
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 agree, it's worth us cleaning this up. I think we can change it how we want, this will be in a breaking change release. So it's ok to clean all this up right now, the public API is possibly desirable for anything using this crate to build a server.
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.
Separately, I wonder if we should stop using the term file
for plain_text, and instead refer to it as either TxtZone
or just Zone
, as Wikipedia refers to it? Most things are going to be files in this context, so it seems wrong to use a generic name for plain text.
Since it was created by BIND alternatively it could be BINDZoneFile
. Or RFC1035Zone
or something?
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.
Please avoid further proliferation of UPPER acronyms -- the idiomatic spelling would be Bind
or Rfc
.
(I do agree with the sentiment but feel both the references to bind and the RFC are probably too verbose to this? Maybe just ZoneFile
? Unadorned Zone
seems a little too ambiguous for my taste.)
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'm ok with just Zone
(and agree on the proper naming style)
So far I can't really tell since I started to check out this repo yesterday. Happy to continue work towards reducing these discrepancies/states in subsequent PRs, as my understanding of the maintainers' style is more towards very self contained changes. I'll check about zone type and store compatibility while we wait for maintainer review |
@bluejekyll want to have a look at this? |
Getting to this now. |
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.
Overall, I like this change, it cleans things up. Sorry for the lateness of this review.
let recursor = | ||
RecursiveAuthority::try_from_config(zone_name, zone_type, config, Some(zone_dir)); | ||
let authority = recursor.await?; | ||
|
||
Box::new(Arc::new(authority)) as Box<dyn AuthorityObject> | ||
} | ||
#[cfg(feature = "sqlite")] | ||
None if zone_config.is_update_allowed() => { |
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.
This was originally to deal with an old update from previous config files. I think I'm ok with this, but it's worth us making sure to note this has a breaking change in the CHANGELOG
pub fn get_file(&self) -> PathBuf { | ||
// TODO: Option on PathBuf | ||
PathBuf::from(self.file.as_ref().expect("file was none")) | ||
pub fn get_file(&self) -> Option<PathBuf> { |
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.
Some of this was related to me being overly cautious when I had migrated some file formats in the past. It's probably fine for us to remove a lot of the deprecated use cases.
pub fn get_file(&self) -> PathBuf { | ||
// TODO: Option on PathBuf | ||
PathBuf::from(self.file.as_ref().expect("file was none")) | ||
pub fn get_file(&self) -> Option<PathBuf> { |
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 agree, it's worth us cleaning this up. I think we can change it how we want, this will be in a breaking change release. So it's ok to clean all this up right now, the public API is possibly desirable for anything using this crate to build a server.
@@ -186,8 +187,6 @@ pub struct ZoneConfig { | |||
pub zone: String, // TODO: make Domain::Name decodable | |||
/// type of the zone | |||
pub zone_type: ZoneType, | |||
/// location of the file (short for StoreConfig::FileConfig{zone_file_path}) | |||
pub file: Option<String>, |
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.
Just leaving a note that we need to add this as a breaking change to the CHANGELOG
pub fn get_file(&self) -> PathBuf { | ||
// TODO: Option on PathBuf | ||
PathBuf::from(self.file.as_ref().expect("file was none")) | ||
pub fn get_file(&self) -> Option<PathBuf> { |
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.
Separately, I wonder if we should stop using the term file
for plain_text, and instead refer to it as either TxtZone
or just Zone
, as Wikipedia refers to it? Most things are going to be files in this context, so it seems wrong to use a generic name for plain text.
Since it was created by BIND alternatively it could be BINDZoneFile
. Or RFC1035Zone
or something?
Small part of #2195
As stated in the issue, the file parameter as a shortcut allows to create configurations that are not quite valid and generate warnings in logs. This PR removes the higher level path parameter down to the two store configurations where it's valid. This has some consequences triggering other changes:
sqlite
feature and settingis_update_allowed
. This was previously logged as deprecated.get_file
returns anOption<PathBuf>
. It seems to me this should have always been the case. Also note this method is not used anywhere in this repository and to external users it previously generated a panic in validNone
cases.None
cases map to an error.basic-toml
does not support externally tagged enums which makes me wonder why is the more wildly usedtoml
crate not used instead.@japaric I hope this isn't colliding with any started work and helps instead. The great description in the issue made it an attractive way to do a first contribution. Would appreciate a review as well