Skip to content

Commit

Permalink
Apply nice/ionice settings from env (#746)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dipta Das authored and tamalsaha committed Apr 17, 2019
1 parent 42ed76b commit 550ab37
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 0 deletions.
12 changes: 12 additions & 0 deletions backup_mongo.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/appscode/go/flags"
"github.com/appscode/stash/pkg/restic"
"github.com/appscode/stash/pkg/util"
"github.com/spf13/cobra"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/errors"
Expand Down Expand Up @@ -50,6 +51,17 @@ func NewCmdBackupMongo() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
flags.EnsureRequiredFlags(cmd, "app-binding", "provider", "secret-dir")

// apply nice, ionice settings from env
var err error
setupOpt.Nice, err = util.NiceSettingsFromEnv()
if err != nil {
return handleResticError(outputDir, restic.DefaultOutputFileName, err)
}
setupOpt.IONice, err = util.IONiceSettingsFromEnv()
if err != nil {
return handleResticError(outputDir, restic.DefaultOutputFileName, err)
}

// prepare client
config, err := clientcmd.BuildConfigFromFlags(masterURL, kubeconfigPath)
if err != nil {
Expand Down
12 changes: 12 additions & 0 deletions backup_mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/appscode/go/flags"
"github.com/appscode/stash/pkg/restic"
"github.com/appscode/stash/pkg/util"
"github.com/spf13/cobra"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/errors"
Expand Down Expand Up @@ -50,6 +51,17 @@ func NewCmdBackupMySql() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
flags.EnsureRequiredFlags(cmd, "app-binding", "provider", "secret-dir")

// apply nice, ionice settings from env
var err error
setupOpt.Nice, err = util.NiceSettingsFromEnv()
if err != nil {
return handleResticError(outputDir, restic.DefaultOutputFileName, err)
}
setupOpt.IONice, err = util.IONiceSettingsFromEnv()
if err != nil {
return handleResticError(outputDir, restic.DefaultOutputFileName, err)
}

// prepare client
config, err := clientcmd.BuildConfigFromFlags(masterURL, kubeconfigPath)
if err != nil {
Expand Down
12 changes: 12 additions & 0 deletions backup_pg.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/appscode/go/flags"
"github.com/appscode/go/log"
"github.com/appscode/stash/pkg/restic"
"github.com/appscode/stash/pkg/util"
"github.com/spf13/cobra"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/errors"
Expand Down Expand Up @@ -54,6 +55,17 @@ func NewCmdBackupPG() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
flags.EnsureRequiredFlags(cmd, "app-binding", "provider", "secret-dir")

// apply nice, ionice settings from env
var err error
setupOpt.Nice, err = util.NiceSettingsFromEnv()
if err != nil {
return handleResticError(outputDir, restic.DefaultOutputFileName, err)
}
setupOpt.IONice, err = util.IONiceSettingsFromEnv()
if err != nil {
return handleResticError(outputDir, restic.DefaultOutputFileName, err)
}

// prepare client
config, err := clientcmd.BuildConfigFromFlags(masterURL, kubeconfigPath)
if err != nil {
Expand Down
12 changes: 12 additions & 0 deletions backup_pvc.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/appscode/go/log"
api_v1beta1 "github.com/appscode/stash/apis/stash/v1beta1"
"github.com/appscode/stash/pkg/restic"
"github.com/appscode/stash/pkg/util"
"github.com/spf13/cobra"
"k8s.io/apimachinery/pkg/util/errors"
)
Expand Down Expand Up @@ -35,6 +36,17 @@ func NewCmdBackupPVC() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
flags.EnsureRequiredFlags(cmd, "backup-dirs", "provider", "secret-dir")

// apply nice, ionice settings from env
var err error
setupOpt.Nice, err = util.NiceSettingsFromEnv()
if err != nil {
return handleResticError(outputDir, restic.DefaultOutputFileName, err)
}
setupOpt.IONice, err = util.IONiceSettingsFromEnv()
if err != nil {
return handleResticError(outputDir, restic.DefaultOutputFileName, err)
}

// init restic wrapper
resticWrapper, err := restic.NewResticWrapper(setupOpt)
if err != nil {
Expand Down
12 changes: 12 additions & 0 deletions restore_mongo.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/appscode/go/flags"
"github.com/appscode/stash/pkg/restic"
"github.com/appscode/stash/pkg/util"
"github.com/spf13/cobra"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/errors"
Expand Down Expand Up @@ -41,6 +42,17 @@ func NewCmdRestoreMongo() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
flags.EnsureRequiredFlags(cmd, "app-binding", "provider", "secret-dir")

// apply nice, ionice settings from env
var err error
setupOpt.Nice, err = util.NiceSettingsFromEnv()
if err != nil {
return handleResticError(outputDir, restic.DefaultOutputFileName, err)
}
setupOpt.IONice, err = util.IONiceSettingsFromEnv()
if err != nil {
return handleResticError(outputDir, restic.DefaultOutputFileName, err)
}

// prepare client
config, err := clientcmd.BuildConfigFromFlags(masterURL, kubeconfigPath)
if err != nil {
Expand Down
12 changes: 12 additions & 0 deletions restore_mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/appscode/go/flags"
"github.com/appscode/stash/pkg/restic"
"github.com/appscode/stash/pkg/util"
"github.com/spf13/cobra"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/errors"
Expand Down Expand Up @@ -40,6 +41,17 @@ func NewCmdRestoreMySql() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
flags.EnsureRequiredFlags(cmd, "app-binding", "provider", "secret-dir")

// apply nice, ionice settings from env
var err error
setupOpt.Nice, err = util.NiceSettingsFromEnv()
if err != nil {
return handleResticError(outputDir, restic.DefaultOutputFileName, err)
}
setupOpt.IONice, err = util.IONiceSettingsFromEnv()
if err != nil {
return handleResticError(outputDir, restic.DefaultOutputFileName, err)
}

// prepare client
config, err := clientcmd.BuildConfigFromFlags(masterURL, kubeconfigPath)
if err != nil {
Expand Down
12 changes: 12 additions & 0 deletions restore_pg.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/appscode/go/flags"
"github.com/appscode/stash/pkg/restic"
"github.com/appscode/stash/pkg/util"
"github.com/spf13/cobra"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/errors"
Expand Down Expand Up @@ -40,6 +41,17 @@ func NewCmdRestorePG() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
flags.EnsureRequiredFlags(cmd, "app-binding", "provider", "secret-dir")

// apply nice, ionice settings from env
var err error
setupOpt.Nice, err = util.NiceSettingsFromEnv()
if err != nil {
return handleResticError(outputDir, restic.DefaultOutputFileName, err)
}
setupOpt.IONice, err = util.IONiceSettingsFromEnv()
if err != nil {
return handleResticError(outputDir, restic.DefaultOutputFileName, err)
}

// prepare client
config, err := clientcmd.BuildConfigFromFlags(masterURL, kubeconfigPath)
if err != nil {
Expand Down
13 changes: 13 additions & 0 deletions restore_pvc.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/appscode/go/flags"
"github.com/appscode/stash/pkg/restic"
"github.com/appscode/stash/pkg/util"
"github.com/spf13/cobra"
"k8s.io/apimachinery/pkg/util/errors"
)
Expand Down Expand Up @@ -32,6 +33,18 @@ func NewCmdRestorePVC() *cobra.Command {
DisableAutoGenTag: true,
RunE: func(cmd *cobra.Command, args []string) error {
flags.EnsureRequiredFlags(cmd, "restore-dirs", "provider", "secret-dir")

// apply nice, ionice settings from env
var err error
setupOpt.Nice, err = util.NiceSettingsFromEnv()
if err != nil {
return handleResticError(outputDir, restic.DefaultOutputFileName, err)
}
setupOpt.IONice, err = util.IONiceSettingsFromEnv()
if err != nil {
return handleResticError(outputDir, restic.DefaultOutputFileName, err)
}

// init restic wrapper
resticWrapper, err := restic.NewResticWrapper(setupOpt)
if err != nil {
Expand Down

0 comments on commit 550ab37

Please sign in to comment.