diff --git a/changelogs/unreleased/8093-Lyndon-Li b/changelogs/unreleased/8093-Lyndon-Li new file mode 100644 index 0000000000..a43c47e09a --- /dev/null +++ b/changelogs/unreleased/8093-Lyndon-Li @@ -0,0 +1 @@ +Fix issue #7620, add backup repository configuration implementation and support cacheLimit configuration for Kopia repo \ No newline at end of file diff --git a/design/backup-repo-config.md b/design/backup-repo-config.md index 9e4b168c8b..f6a25e8ec3 100644 --- a/design/backup-repo-config.md +++ b/design/backup-repo-config.md @@ -86,18 +86,6 @@ For any reason, if the configMap doesn't effect, nothing is specified to the bac The BackupRepository configMap supports backup repository type specific configurations, even though users can only specify one configMap. So in the configMap struct, multiple entries are supported, indexed by the backup repository type. During the backup repository creation, the configMap is searched by the repository type. -Below are the struct for the configMap: -``` golang -type RepoConfig struct { - CacheLimitMB int `json:"cacheLimitMB,omitempty"` - EnableCompression int `json:"enableCompression,omitempty"` -} - -type RepoConfigs struct { - Configs map[string]RepoConfig `json:"configs"` -} -``` - ### Configurations With the above mechanisms, any kind of configuration could be added. Here list the configurations defined at present: @@ -105,23 +93,7 @@ With the above mechanisms, any kind of configuration could be added. Here list t ```enableCompression```: specifies to enable/disable compression for a backup repsotiory. Most of the backup repositories support the data compression feature, if it is not supported by a backup repository, this parameter is ignored. Most of the backup repositories support to dynamically enable/disable compression, so this parameter is defined to be used whenever creating a write connection to the backup repository, if the dynamically changing is not supported, this parameter will be hornored only when initializing the backup repository. For Kopia repository, this parameter is supported and can be dynamically modified. ### Sample -Below is an example of the BackupRepository configMap with the configurations: -json format: -```json -{ - "configs": { - "repo-type-1": { - "cacheLimitMB": 2048, - "enableCompression": true - }, - "repo-type-2": { - "cacheLimitMB": 1024, - "enableCompression": false - } - } -} -``` -yaml format: +Below is an example of the BackupRepository configMap with the configurations: ```yaml apiVersion: v1 kind: ConfigMap @@ -129,25 +101,20 @@ metadata: name: namespace: velero data: - configs: | + : | { - "repo-type-1": { - "cacheLimitMB": 2048, - "enableCompression": true - }, - "repo-type-2": { - "cacheLimitMB": 1024, - "enableCompression": false - } - } + "cacheLimitMB": 2048, + "enableCompression": true + } + : | + { + "cacheLimitMB": 1, + "enableCompression": false + } ``` To create the configMap, users need to save something like the above sample to a file and then run below commands: ``` -kubectl create cm -n velero --from-file= -``` -Or -``` kubectl apply -f ``` diff --git a/pkg/repository/udmrepo/kopialib/backend/common.go b/pkg/repository/udmrepo/kopialib/backend/common.go index 6e5facdecb..08a58ace13 100644 --- a/pkg/repository/udmrepo/kopialib/backend/common.go +++ b/pkg/repository/udmrepo/kopialib/backend/common.go @@ -68,7 +68,7 @@ func SetupNewRepositoryOptions(ctx context.Context, flags map[string]string) rep func SetupConnectOptions(ctx context.Context, repoOptions udmrepo.RepoOptions) repo.ConnectOptions { cacheLimit := optionalHaveIntWithDefault(ctx, udmrepo.StoreOptionCacheLimit, repoOptions.StorageOptions, defaultCacheLimitMB) << 20 - // 80% for data cache and 20% for metadata cahce and align to KB + // 80% for data cache and 20% for metadata cache and align to KB dataCacheLimit := (cacheLimit / 5 * 4) >> 10 metadataCacheLimit := (cacheLimit / 5) >> 10