Skip to content

Commit

Permalink
Merge pull request #8380 from sseago/worker-count
Browse files Browse the repository at this point in the history
Add --item-block-worker-count flag to velero install and server
  • Loading branch information
reasonerjt authored Nov 15, 2024
2 parents 5a64df9 + 6588141 commit dacd5ef
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelogs/unreleased/8380-sseago
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add --item-block-worker-count flag to velero install and server
8 changes: 8 additions & 0 deletions pkg/cmd/cli/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ type Options struct {
BackupRepoConfigMap string
RepoMaintenanceJobConfigMap string
NodeAgentConfigMap string
ItemBlockWorkerCount int
}

// BindFlags adds command line values to the options struct.
Expand Down Expand Up @@ -182,6 +183,12 @@ func (o *Options) BindFlags(flags *pflag.FlagSet) {
o.NodeAgentConfigMap,
"The name of ConfigMap containing node-agent configurations.",
)
flags.IntVar(
&o.ItemBlockWorkerCount,
"item-block-worker-count",
o.ItemBlockWorkerCount,
"Number of worker threads to process ItemBlocks. Default is one. Optional.",
)
}

// NewInstallOptions instantiates a new, default InstallOptions struct.
Expand Down Expand Up @@ -283,6 +290,7 @@ func (o *Options) AsVeleroOptions() (*install.VeleroOptions, error) {
BackupRepoConfigMap: o.BackupRepoConfigMap,
RepoMaintenanceJobConfigMap: o.RepoMaintenanceJobConfigMap,
NodeAgentConfigMap: o.NodeAgentConfigMap,
ItemBlockWorkerCount: o.ItemBlockWorkerCount,
}, nil
}

Expand Down
10 changes: 10 additions & 0 deletions pkg/cmd/server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ const (
DefaultMaintenanceJobCPULimit = "0"
DefaultMaintenanceJobMemRequest = "0"
DefaultMaintenanceJobMemLimit = "0"

DefaultItemBlockWorkerCount = 1
)

var (
Expand Down Expand Up @@ -179,6 +181,7 @@ type Config struct {
RepoMaintenanceJobConfig string
PodResources kube.PodResources
KeepLatestMaintenanceJobs int
ItemBlockWorkerCount int
}

func GetDefaultConfig() *Config {
Expand Down Expand Up @@ -216,6 +219,7 @@ func GetDefaultConfig() *Config {
MemoryLimit: DefaultMaintenanceJobMemLimit,
},
KeepLatestMaintenanceJobs: DefaultKeepLatestMaintenanceJobs,
ItemBlockWorkerCount: DefaultItemBlockWorkerCount,
}

return config
Expand Down Expand Up @@ -294,4 +298,10 @@ func (c *Config) BindFlags(flags *pflag.FlagSet) {
c.RepoMaintenanceJobConfig,
"The name of ConfigMap containing repository maintenance Job configurations.",
)
flags.IntVar(
&c.ItemBlockWorkerCount,
"item-block-worker-count",
c.ItemBlockWorkerCount,
"Number of worker threads to process ItemBlocks. Default is one. Optional.",
)
}
1 change: 1 addition & 0 deletions pkg/cmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,7 @@ func (s *server) runControllers(defaultVolumeSnapshotLocations map[string]string
s.credentialFileStore,
s.config.MaxConcurrentK8SConnections,
s.config.DefaultSnapshotMoveData,
s.config.ItemBlockWorkerCount,
s.crClient,
).SetupWithManager(s.mgr); err != nil {
s.logger.Fatal(err, "unable to create controller", "controller", constant.ControllerBackup)
Expand Down
3 changes: 3 additions & 0 deletions pkg/controller/backup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ type backupReconciler struct {
maxConcurrentK8SConnections int
defaultSnapshotMoveData bool
globalCRClient kbclient.Client
itemBlockWorkerCount int
}

func NewBackupReconciler(
Expand All @@ -110,6 +111,7 @@ func NewBackupReconciler(
credentialStore credentials.FileStore,
maxConcurrentK8SConnections int,
defaultSnapshotMoveData bool,
itemBlockWorkerCount int,
globalCRClient kbclient.Client,
) *backupReconciler {
b := &backupReconciler{
Expand All @@ -135,6 +137,7 @@ func NewBackupReconciler(
credentialFileStore: credentialStore,
maxConcurrentK8SConnections: maxConcurrentK8SConnections,
defaultSnapshotMoveData: defaultSnapshotMoveData,
itemBlockWorkerCount: itemBlockWorkerCount,
globalCRClient: globalCRClient,
}
b.updateTotalBackupMetric()
Expand Down
11 changes: 11 additions & 0 deletions pkg/install/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type podTemplateConfig struct {
backupRepoConfigMap string
repoMaintenanceJobConfigMap string
nodeAgentConfigMap string
itemBlockWorkerCount int
}

func WithImage(image string) podTemplateOption {
Expand Down Expand Up @@ -212,6 +213,12 @@ func WithRepoMaintenanceJobConfigMap(repoMaintenanceJobConfigMap string) podTemp
}
}

func WithItemBlockWorkerCount(itemBlockWorkerCount int) podTemplateOption {
return func(c *podTemplateConfig) {
c.itemBlockWorkerCount = itemBlockWorkerCount
}
}

func Deployment(namespace string, opts ...podTemplateOption) *appsv1.Deployment {
// TODO: Add support for server args
c := &podTemplateConfig{
Expand Down Expand Up @@ -297,6 +304,10 @@ func Deployment(namespace string, opts ...podTemplateOption) *appsv1.Deployment
args = append(args, fmt.Sprintf("--repo-maintenance-job-configmap=%s", c.repoMaintenanceJobConfigMap))
}

if c.itemBlockWorkerCount > 0 {
args = append(args, fmt.Sprintf("--item-block-worker-count=%d", c.itemBlockWorkerCount))
}

deployment := &appsv1.Deployment{
ObjectMeta: objectMeta(namespace, "velero"),
TypeMeta: metav1.TypeMeta{
Expand Down
2 changes: 2 additions & 0 deletions pkg/install/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ type VeleroOptions struct {
BackupRepoConfigMap string
RepoMaintenanceJobConfigMap string
NodeAgentConfigMap string
ItemBlockWorkerCount int
}

func AllCRDs() *unstructured.UnstructuredList {
Expand Down Expand Up @@ -353,6 +354,7 @@ func AllResources(o *VeleroOptions) *unstructured.UnstructuredList {
WithScheduleSkipImmediately(o.ScheduleSkipImmediately),
WithPodResources(o.PodResources),
WithKeepLatestMaintenanceJobs(o.KeepLatestMaintenanceJobs),
WithItemBlockWorkerCount(o.ItemBlockWorkerCount),
}

if len(o.Features) > 0 {
Expand Down

0 comments on commit dacd5ef

Please sign in to comment.