Skip to content

Commit

Permalink
Pass db quota size config to embedded etcd used by restorer
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyas-s-rao committed Mar 12, 2019
1 parent 870517f commit 2c38dce
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 37 deletions.
3 changes: 3 additions & 0 deletions chart/templates/etcd-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ spec:
- --data-dir=/var/etcd/data/new.etcd
- --storage-provider={{ .Values.backup.storageProvider }}
- --store-prefix=etcd-{{ .Values.role }}
{{- if .Values.backup.embeddedEtcdQuotaBytes }}
- --embeddedEtcdQuotaBytes={{ .Values.backup.embeddedEtcdQuotaBytes }}
{{- end }}
{{- if .Values.tls }}
- --cert=/var/etcd/ssl/client/tls.crt
- --key=/var/etcd/ssl/client/tls.key
Expand Down
2 changes: 2 additions & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ backup:

storageContainer: ""

embeddedEtcdQuotaBytes: 8589934592

# env should include the right list of values for the
# storageProvider you use, follow the comments below
env: [] # Follow comments below
Expand Down
15 changes: 8 additions & 7 deletions cmd/initializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ func NewInitializeCommand(stopCh <-chan struct{}) *cobra.Command {
}

options := &restorer.RestoreOptions{
RestoreDataDir: path.Clean(restoreDataDir),
Name: restoreName,
ClusterURLs: clusterUrlsMap,
PeerURLs: peerUrls,
ClusterToken: restoreClusterToken,
SkipHashCheck: skipHashCheck,
MaxFetchers: restoreMaxFetchers,
RestoreDataDir: path.Clean(restoreDataDir),
Name: restoreName,
ClusterURLs: clusterUrlsMap,
PeerURLs: peerUrls,
ClusterToken: restoreClusterToken,
SkipHashCheck: skipHashCheck,
MaxFetchers: restoreMaxFetchers,
EmbeddedEtcdQuotaBytes: embeddedEtcdQuotaBytes,
}

var snapstoreConfig *snapstore.Config
Expand Down
20 changes: 11 additions & 9 deletions cmd/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,16 @@ func NewRestoreCommand(stopCh <-chan struct{}) *cobra.Command {
rs := restorer.NewRestorer(store, logger)

options := &restorer.RestoreOptions{
RestoreDataDir: path.Clean(restoreDataDir),
Name: restoreName,
BaseSnapshot: *baseSnap,
DeltaSnapList: deltaSnapList,
ClusterURLs: clusterUrlsMap,
PeerURLs: peerUrls,
ClusterToken: restoreClusterToken,
SkipHashCheck: skipHashCheck,
MaxFetchers: restoreMaxFetchers,
RestoreDataDir: path.Clean(restoreDataDir),
Name: restoreName,
BaseSnapshot: *baseSnap,
DeltaSnapList: deltaSnapList,
ClusterURLs: clusterUrlsMap,
PeerURLs: peerUrls,
ClusterToken: restoreClusterToken,
SkipHashCheck: skipHashCheck,
MaxFetchers: restoreMaxFetchers,
EmbeddedEtcdQuotaBytes: embeddedEtcdQuotaBytes,
}

err = rs.Restore(*options)
Expand All @@ -107,6 +108,7 @@ func initializeEtcdFlags(cmd *cobra.Command) {
cmd.Flags().StringVar(&restoreName, "name", defaultName, "human-readable name for this member")
cmd.Flags().BoolVar(&skipHashCheck, "skip-hash-check", false, "ignore snapshot integrity hash value (required if copied from data directory)")
cmd.Flags().IntVar(&restoreMaxFetchers, "max-fetchers", 6, "maximum number of threads that will fetch delta snapshots in parallel")
cmd.Flags().Int64Var(&embeddedEtcdQuotaBytes, "embedded-etcd-quota-bytes", int64(8*1024*1024*1024), "maximum backend quota for the embedded etcd used for applying delta snapshots")
}

func initialClusterFromName(name string) string {
Expand Down
15 changes: 8 additions & 7 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,14 @@ func NewServerCommand(stopCh <-chan struct{}) *cobra.Command {
}

options := &restorer.RestoreOptions{
RestoreDataDir: path.Clean(restoreDataDir),
Name: restoreName,
ClusterURLs: clusterUrlsMap,
PeerURLs: peerUrls,
ClusterToken: restoreClusterToken,
SkipHashCheck: skipHashCheck,
MaxFetchers: restoreMaxFetchers,
RestoreDataDir: path.Clean(restoreDataDir),
Name: restoreName,
ClusterURLs: clusterUrlsMap,
PeerURLs: peerUrls,
ClusterToken: restoreClusterToken,
SkipHashCheck: skipHashCheck,
MaxFetchers: restoreMaxFetchers,
EmbeddedEtcdQuotaBytes: embeddedEtcdQuotaBytes,
}

if storageProvider != "" {
Expand Down
15 changes: 8 additions & 7 deletions cmd/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ var (
enableProfiling bool

//restore flags
restoreCluster string
restoreClusterToken string
restoreDataDir string
restorePeerURLs []string
restoreName string
skipHashCheck bool
restoreMaxFetchers int
restoreCluster string
restoreClusterToken string
restoreDataDir string
restorePeerURLs []string
restoreName string
skipHashCheck bool
restoreMaxFetchers int
embeddedEtcdQuotaBytes int64

//snapstore flags
storageProvider string
Expand Down
4 changes: 4 additions & 0 deletions pkg/snapshot/restorer/restorer.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ func (r *Restorer) Restore(ro RestoreOptions) error {
if ro.MaxFetchers < 1 {
return fmt.Errorf("Maximum number of fetchers should be greater than zero. Input MaxFetchers: %d", ro.MaxFetchers)
}
if ro.EmbeddedEtcdQuotaBytes <= 0 {
return fmt.Errorf("Quota size for etcd must be greater than 0. Input EmbeddedEtcdQuotaBytes: %d", ro.EmbeddedEtcdQuotaBytes)
}
if err := r.restoreFromBaseSnapshot(ro); err != nil {
return fmt.Errorf("failed to restore from the base snapshot :%v", err)
}
Expand Down Expand Up @@ -308,6 +311,7 @@ func makeWALAndSnap(waldir, snapdir string, cl *membership.RaftCluster, restoreN
func startEmbeddedEtcd(ro RestoreOptions) (*embed.Etcd, error) {
cfg := embed.NewConfig()
cfg.Dir = filepath.Join(ro.RestoreDataDir)
cfg.QuotaBackendBytes = ro.EmbeddedEtcdQuotaBytes
e, err := embed.StartEtcd(cfg)
if err != nil {
return nil, err
Expand Down
15 changes: 8 additions & 7 deletions pkg/snapshot/restorer/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ type Restorer struct {

// RestoreOptions hold all snapshot restore related fields
type RestoreOptions struct {
ClusterURLs types.URLsMap
ClusterToken string
RestoreDataDir string
PeerURLs types.URLs
SkipHashCheck bool
Name string
MaxFetchers int
ClusterURLs types.URLsMap
ClusterToken string
RestoreDataDir string
PeerURLs types.URLs
SkipHashCheck bool
Name string
MaxFetchers int
EmbeddedEtcdQuotaBytes int64
// Base full snapshot + delta snapshots to restore from
BaseSnapshot snapstore.Snapshot
DeltaSnapList snapstore.SnapList
Expand Down

0 comments on commit 2c38dce

Please sign in to comment.