-
Notifications
You must be signed in to change notification settings - Fork 101
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
Support config file for server configuration #208
Support config file for server configuration #208
Conversation
022b1af
to
382e58a
Compare
Signed-off-by: Swapnil Mhamane <[email protected]>
382e58a
to
16cecba
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.
@swapnilgm Thanks for the well-written PR. I have a few suggestions/changes. Please address them.
- In all
init.go
files, bring the default values out of theNew___Config
method intotypes.go
, as constants. - Why is config-file not enabled for the other subcommands (restore, snapshot, initialize)? Given that server command config already has most of the flags for the other subcommands, it would be easier to use config-file option for those subcommands as well. WDYT? Just a suggestion.
pkg/etcdutil/init.go
Outdated
// NewEtcdConnectionConfig returns etcd connection config. | ||
func NewEtcdConnectionConfig() *EtcdConnectionConfig { | ||
return &EtcdConnectionConfig{ | ||
Endpoints: []string{"127.0.0.1:2379"}, |
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.
Define constants and then return them. That way it's easier to modify such default values in the future.
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.
done
func NewEtcdConnectionConfig() *EtcdConnectionConfig { | ||
return &EtcdConnectionConfig{ | ||
Endpoints: []string{"127.0.0.1:2379"}, | ||
ConnectionTimeout: wrappers.Duration{Duration: 30 * time.Second}, |
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.
See above comment
} | ||
|
||
var snapstoreConfig *snapstore.Config | ||
if storageProvider != "" { |
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.
Looks like this check is missed in the new code. How will etcd-events be handled in that case?
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.
etcd-events/empty storage provider case are handled in flow. We don't have to have any additional check here. The initialise rather restore api define inside have to deal with empty store. So, the check is defined internally.
pkg/snapshot/snapshotter/init.go
Outdated
return &Config{ | ||
FullSnapshotSchedule: "0 */1 * * *", | ||
DeltaSnapshotPeriod: wrappers.Duration{Duration: 20 * time.Second}, | ||
DeltaSnapshotMemoryLimit: 10 * 1024 * 1024, //10Mib |
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.
DeltaSnapshotMemoryLimit: 10 * 1024 * 1024, //10Mib | |
DeltaSnapshotMemoryLimit: DefaultDeltaSnapMemoryLimit, |
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.
Done
pkg/snapshot/snapshotter/init.go
Outdated
func NewSnapshotterConfig() *Config { | ||
return &Config{ | ||
FullSnapshotSchedule: "0 */1 * * *", | ||
DeltaSnapshotPeriod: wrappers.Duration{Duration: 20 * time.Second}, |
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.
DeltaSnapshotPeriod: wrappers.Duration{Duration: 20 * time.Second}, | |
DeltaSnapshotPeriod: wrappers.Duration{Duration: DefaultDeltaSnapshotInterval}, |
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.
Done
pkg/snapshot/snapshotter/init.go
Outdated
DeltaSnapshotMemoryLimit: 10 * 1024 * 1024, //10Mib | ||
GarbageCollectionPeriod: wrappers.Duration{Duration: time.Minute}, | ||
GarbageCollectionPolicy: GarbageCollectionPolicyExponential, | ||
MaxBackups: 7, |
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.
MaxBackups: 7, | |
MaxBackups: DefaultMaxBackups, |
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.
Done
port: 8080 | ||
# enableProfiling: true | ||
# server-cert: "ssl/etcdbr/tls.crt" | ||
# server-key: "ssl/etcdbr/tls.crt" |
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.
# server-key: "ssl/etcdbr/tls.crt" | |
# server-key: "ssl/etcdbr/tls.key" |
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.
Done
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.
Thanks for the review. I have done the the changes.
Regarding config for sub-commands, I think I had some good reason initially to not add config file for sub-commands. it was something around, we rarely use this sub commands, And sub-commands are mostly used for one time manual operation so it won't make much sense. But anyway we could add it later. I or one of us can add it later as a part of separate PR. WDYS?
} | ||
|
||
var snapstoreConfig *snapstore.Config | ||
if storageProvider != "" { |
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.
etcd-events/empty storage provider case are handled in flow. We don't have to have any additional check here. The initialise rather restore api define inside have to deal with empty store. So, the check is defined internally.
port: 8080 | ||
# enableProfiling: true | ||
# server-cert: "ssl/etcdbr/tls.crt" | ||
# server-key: "ssl/etcdbr/tls.crt" |
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.
Done
pkg/etcdutil/init.go
Outdated
// NewEtcdConnectionConfig returns etcd connection config. | ||
func NewEtcdConnectionConfig() *EtcdConnectionConfig { | ||
return &EtcdConnectionConfig{ | ||
Endpoints: []string{"127.0.0.1:2379"}, |
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.
done
pkg/snapshot/snapshotter/init.go
Outdated
func NewSnapshotterConfig() *Config { | ||
return &Config{ | ||
FullSnapshotSchedule: "0 */1 * * *", | ||
DeltaSnapshotPeriod: wrappers.Duration{Duration: 20 * time.Second}, |
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.
Done
pkg/snapshot/snapshotter/init.go
Outdated
return &Config{ | ||
FullSnapshotSchedule: "0 */1 * * *", | ||
DeltaSnapshotPeriod: wrappers.Duration{Duration: 20 * time.Second}, | ||
DeltaSnapshotMemoryLimit: 10 * 1024 * 1024, //10Mib |
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.
Done
pkg/snapshot/snapshotter/init.go
Outdated
DeltaSnapshotMemoryLimit: 10 * 1024 * 1024, //10Mib | ||
GarbageCollectionPeriod: wrappers.Duration{Duration: time.Minute}, | ||
GarbageCollectionPolicy: GarbageCollectionPolicyExponential, | ||
MaxBackups: 7, |
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.
Done
Signed-off-by: Swapnil Mhamane <[email protected]>
1026b83
to
8780687
Compare
Signed-off-by: Swapnil Mhamane [email protected]
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #201
Special notes for your reviewer:
Release note: