Skip to content

Commit

Permalink
👌 Addressed the review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Swapnil Mhamane <[email protected]>
  • Loading branch information
Swapnil Mhamane committed Mar 24, 2020
1 parent 16cecba commit 8780687
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 18 deletions.
2 changes: 1 addition & 1 deletion example/00-backup-restore-server-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ serverConfig:
port: 8080
# enableProfiling: true
# server-cert: "ssl/etcdbr/tls.crt"
# server-key: "ssl/etcdbr/tls.crt"
# server-key: "ssl/etcdbr/tls.key"

snapshotterConfig:
schedule: "0 */1 * * *"
Expand Down
2 changes: 1 addition & 1 deletion pkg/etcdutil/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
// NewEtcdConnectionConfig returns etcd connection config.
func NewEtcdConnectionConfig() *EtcdConnectionConfig {
return &EtcdConnectionConfig{
Endpoints: []string{"127.0.0.1:2379"},
Endpoints: []string{defaultEtcdConnectionEndpoint},
ConnectionTimeout: wrappers.Duration{Duration: 30 * time.Second},
InsecureTransport: true,
InsecureSkipVerify: false,
Expand Down
2 changes: 2 additions & 0 deletions pkg/etcdutil/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"github.com/gardener/etcd-backup-restore/pkg/wrappers"
)

const defaultEtcdConnectionEndpoint string = "127.0.0.1:2379"

// EtcdConnectionConfig holds the etcd connection config.
type EtcdConnectionConfig struct {
// Endpoints are the endpoints from which the backup will be take or defragmentation will be called.
Expand Down
2 changes: 1 addition & 1 deletion pkg/server/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func NewBackupRestoreComponentConfig() *BackupRestoreComponentConfig {
SnapshotterConfig: snapshotter.NewSnapshotterConfig(),
SnapstoreConfig: snapstore.NewSnapstoreConfig(),
RestorationConfig: restorer.NewRestorationConfig(),
DefragmentationSchedule: "0 0 */3 * *",
DefragmentationSchedule: defaultDefragmentationSchedule,
}
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/server/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import (
)

const (
defaultServerPort = 8080
defaultServerPort = 8080
defaultDefragmentationSchedule = "0 0 */3 * *"
)

// BackupRestoreComponentConfig holds the component configuration.
Expand Down
11 changes: 3 additions & 8 deletions pkg/snapshot/restorer/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,17 @@ import (
flag "github.com/spf13/pflag"
)

const (
defaultName = "default"
defaultInitialAdvertisePeerURLs = "http://localhost:2380"
)

// NewRestorationConfig returns the restoration config.
func NewRestorationConfig() *RestorationConfig {
return &RestorationConfig{
InitialCluster: initialClusterFromName(defaultName),
InitialClusterToken: "etcd-cluster",
InitialClusterToken: defaultInitialClusterToken,
RestoreDataDir: fmt.Sprintf("%s.etcd", defaultName),
InitialAdvertisePeerURLs: []string{defaultInitialAdvertisePeerURLs},
Name: defaultName,
SkipHashCheck: false,
MaxFetchers: 6,
EmbeddedEtcdQuotaBytes: int64(8 * 1024 * 1024 * 1024),
MaxFetchers: defaultMaxFetchers,
EmbeddedEtcdQuotaBytes: int64(defaultEmbeddedEtcdQuotaBytes),
}
}

Expand Down
6 changes: 6 additions & 0 deletions pkg/snapshot/restorer/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ import (
const (
tmpDir = "/tmp"
tmpEventsDataFilePrefix = "etcd-restore-"

defaultName = "default"
defaultInitialAdvertisePeerURLs = "http://localhost:2380"
defaultInitialClusterToken = "etcd-cluster"
defaultMaxFetchers = 6
defaultEmbeddedEtcdQuotaBytes = 8 * 1024 * 1024 * 1024 //8Gib
)

// Restorer is a struct for etcd data directory restorer
Expand Down
11 changes: 5 additions & 6 deletions pkg/snapshot/snapshotter/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package snapshotter

import (
"fmt"
"time"

"github.com/gardener/etcd-backup-restore/pkg/wrappers"
cron "github.com/robfig/cron/v3"
Expand All @@ -27,12 +26,12 @@ import (
// NewSnapshotterConfig returns the snapshotter config.
func NewSnapshotterConfig() *Config {
return &Config{
FullSnapshotSchedule: "0 */1 * * *",
DeltaSnapshotPeriod: wrappers.Duration{Duration: 20 * time.Second},
DeltaSnapshotMemoryLimit: 10 * 1024 * 1024, //10Mib
GarbageCollectionPeriod: wrappers.Duration{Duration: time.Minute},
FullSnapshotSchedule: defaultFullSnapshotSchedule,
DeltaSnapshotPeriod: wrappers.Duration{Duration: DefaultDeltaSnapshotInterval},
DeltaSnapshotMemoryLimit: DefaultDeltaSnapMemoryLimit,
GarbageCollectionPeriod: wrappers.Duration{Duration: defaultGarbageCollectionPeriod},
GarbageCollectionPolicy: GarbageCollectionPolicyExponential,
MaxBackups: 7,
MaxBackups: DefaultMaxBackups,
}
}

Expand Down
3 changes: 3 additions & 0 deletions pkg/snapshot/snapshotter/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,16 @@ const (
GarbageCollectionPolicyExponential = "Exponential"
// GarbageCollectionPolicyLimitBased defines the limit based policy for garbage collecting old backups
GarbageCollectionPolicyLimitBased = "LimitBased"
defaultGarbageCollectionPeriod = time.Minute
// DefaultMaxBackups is default number of maximum backups for limit based garbage collection policy.
DefaultMaxBackups = 7

// SnapshotterInactive is set when the snapshotter has not started taking snapshots.
SnapshotterInactive State = 0
// SnapshotterActive is set when the snapshotter has started taking snapshots.
SnapshotterActive State = 1

defaultFullSnapshotSchedule string = "0 */1 * * *"
// DefaultDeltaSnapMemoryLimit is default memory limit for delta snapshots.
DefaultDeltaSnapMemoryLimit = 10 * 1024 * 1024 //10Mib
// DefaultDeltaSnapshotInterval is the default interval for delta snapshots.
Expand Down

0 comments on commit 8780687

Please sign in to comment.