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

Support config file for server configuration #208

Merged
merged 2 commits into from
Mar 24, 2020

Conversation

swapnilgm
Copy link
Contributor

@swapnilgm swapnilgm commented Dec 6, 2019

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:

Configuring backup-restore server using config file is now supported.

@gardener-robot-ci-3 gardener-robot-ci-3 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Dec 6, 2019
@gardener-robot-ci-1 gardener-robot-ci-1 added needs/ok-to-test Needs approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Dec 6, 2019
@swapnilgm swapnilgm force-pushed the feature/support-config-file branch from 022b1af to 382e58a Compare December 9, 2019 09:07
@gardener-robot-ci-1 gardener-robot-ci-1 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Dec 9, 2019
@gardener-robot-ci-2 gardener-robot-ci-2 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Dec 9, 2019
Signed-off-by: Swapnil Mhamane <[email protected]>
@swapnilgm swapnilgm force-pushed the feature/support-config-file branch from 382e58a to 16cecba Compare December 10, 2019 06:29
@gardener-robot-ci-1 gardener-robot-ci-1 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Dec 10, 2019
Copy link
Collaborator

@shreyas-s-rao shreyas-s-rao left a 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.

  1. In all init.go files, bring the default values out of the New___Config method into types.go, as constants.
  2. 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.

// NewEtcdConnectionConfig returns etcd connection config.
func NewEtcdConnectionConfig() *EtcdConnectionConfig {
return &EtcdConnectionConfig{
Endpoints: []string{"127.0.0.1:2379"},
Copy link
Collaborator

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.

Copy link
Contributor Author

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},
Copy link
Collaborator

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 != "" {
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

return &Config{
FullSnapshotSchedule: "0 */1 * * *",
DeltaSnapshotPeriod: wrappers.Duration{Duration: 20 * time.Second},
DeltaSnapshotMemoryLimit: 10 * 1024 * 1024, //10Mib
Copy link
Collaborator

@shreyas-s-rao shreyas-s-rao Feb 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
DeltaSnapshotMemoryLimit: 10 * 1024 * 1024, //10Mib
DeltaSnapshotMemoryLimit: DefaultDeltaSnapMemoryLimit,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

func NewSnapshotterConfig() *Config {
return &Config{
FullSnapshotSchedule: "0 */1 * * *",
DeltaSnapshotPeriod: wrappers.Duration{Duration: 20 * time.Second},
Copy link
Collaborator

@shreyas-s-rao shreyas-s-rao Feb 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
DeltaSnapshotPeriod: wrappers.Duration{Duration: 20 * time.Second},
DeltaSnapshotPeriod: wrappers.Duration{Duration: DefaultDeltaSnapshotInterval},

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

DeltaSnapshotMemoryLimit: 10 * 1024 * 1024, //10Mib
GarbageCollectionPeriod: wrappers.Duration{Duration: time.Minute},
GarbageCollectionPolicy: GarbageCollectionPolicyExponential,
MaxBackups: 7,
Copy link
Collaborator

@shreyas-s-rao shreyas-s-rao Feb 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
MaxBackups: 7,
MaxBackups: DefaultMaxBackups,

Copy link
Contributor Author

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"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# server-key: "ssl/etcdbr/tls.crt"
# server-key: "ssl/etcdbr/tls.key"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor Author

@swapnilgm swapnilgm left a 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 != "" {
Copy link
Contributor Author

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"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

// NewEtcdConnectionConfig returns etcd connection config.
func NewEtcdConnectionConfig() *EtcdConnectionConfig {
return &EtcdConnectionConfig{
Endpoints: []string{"127.0.0.1:2379"},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

func NewSnapshotterConfig() *Config {
return &Config{
FullSnapshotSchedule: "0 */1 * * *",
DeltaSnapshotPeriod: wrappers.Duration{Duration: 20 * time.Second},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

return &Config{
FullSnapshotSchedule: "0 */1 * * *",
DeltaSnapshotPeriod: wrappers.Duration{Duration: 20 * time.Second},
DeltaSnapshotMemoryLimit: 10 * 1024 * 1024, //10Mib
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

DeltaSnapshotMemoryLimit: 10 * 1024 * 1024, //10Mib
GarbageCollectionPeriod: wrappers.Duration{Duration: time.Minute},
GarbageCollectionPolicy: GarbageCollectionPolicyExponential,
MaxBackups: 7,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@gardener-robot-ci-1 gardener-robot-ci-1 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Mar 18, 2020
@gardener-robot-ci-2 gardener-robot-ci-2 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Mar 18, 2020
Signed-off-by: Swapnil Mhamane <[email protected]>
@swapnilgm swapnilgm force-pushed the feature/support-config-file branch from 1026b83 to 8780687 Compare March 24, 2020 05:10
@gardener-robot-ci-1 gardener-robot-ci-1 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Mar 24, 2020
@gardener-robot-ci-2 gardener-robot-ci-2 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Mar 24, 2020
@swapnilgm swapnilgm merged commit c6a9cf5 into gardener:master Mar 24, 2020
@swapnilgm swapnilgm deleted the feature/support-config-file branch March 24, 2020 05:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs/ok-to-test Needs approval for testing (check PR in detail before setting this label because PR is run on CI/CD)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Use the config file for configuration
5 participants