Skip to content

Commit a404dab

Browse files
committed
feat(backupbackingimage): add parameters to backup backing image create proto
ref: longhorn/longhorn 8884 Signed-off-by: Jack Lin <[email protected]>
1 parent 1cd29fd commit a404dab

File tree

11 files changed

+49
-13
lines changed

11 files changed

+49
-13
lines changed

api/model.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ type BackupBackingImage struct {
185185
Labels map[string]string `json:"labels"`
186186
Messages map[string]string `json:"messages"`
187187
CompressionMethod string `json:"compressionMethod"`
188+
Secret string `json:"secret"`
189+
SecretNamespace string `json:"secretNamespace"`
188190
}
189191

190192
type Setting struct {
@@ -1873,6 +1875,8 @@ func toBackupBackingImageResource(bbi *longhorn.BackupBackingImage, apiContext *
18731875
Labels: bbi.Status.Labels,
18741876
Messages: bbi.Status.Messages,
18751877
CompressionMethod: string(bbi.Status.CompressionMethod),
1878+
Secret: bbi.Status.Secret,
1879+
SecretNamespace: bbi.Status.SecretNamespace,
18761880
}
18771881

18781882
backupBackingImage.Actions = map[string]string{

client/generated_backup_backing_image.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ type BackupBackingImage struct {
2121

2222
Progress int64 `json:"progress,omitempty" yaml:"progress,omitempty"`
2323

24+
Secret string `json:"secret,omitempty" yaml:"secret,omitempty"`
25+
26+
SecretNamespace string `json:"secretNamespace,omitempty" yaml:"secretNamespace,omitempty"`
27+
2428
Size int64 `json:"size,omitempty" yaml:"size,omitempty"`
2529

2630
State string `json:"state,omitempty" yaml:"state,omitempty"`

controller/backup_backing_image_controller.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,8 @@ func (bc *BackupBackingImageController) reconcile(backupBackingImageName string)
332332
bbi.Status.Checksum = backupBackingImageInfo.Checksum
333333
bbi.Status.Size = backupBackingImageInfo.Size
334334
bbi.Status.Labels = backupBackingImageInfo.Labels
335+
bbi.Status.Secret = backupBackingImageInfo.Secret
336+
bbi.Status.SecretNamespace = backupBackingImageInfo.SecretNamespace
335337
bbi.Status.CompressionMethod = longhorn.BackupCompressionMethod(backupBackingImageInfo.CompressionMethod)
336338
bbi.Status.LastSyncedAt = syncTime
337339
return nil

engineapi/backing_image_manager.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,12 @@ func (c *BackingImageManagerClient) VersionGet() (int, int, error) {
145145
return output.BackingImageManagerAPIMinVersion, output.BackingImageManagerAPIVersion, nil
146146
}
147147

148-
func (c *BackingImageManagerClient) BackupCreate(name, uuid, checksum, backupTargetURL string, labels, credential map[string]string, compressionMethod string, concurrentLimit int) error {
148+
func (c *BackingImageManagerClient) BackupCreate(name, uuid, checksum, backupTargetURL string, labels, credential map[string]string, compressionMethod string, concurrentLimit int, parameters map[string]string) error {
149149

150150
if err := CheckBackingImageManagerCompatibility(c.apiMinVersion, c.apiVersion); err != nil {
151151
return err
152152
}
153-
return c.grpcClient.BackupCreate(name, uuid, checksum, backupTargetURL, labels, credential, compressionMethod, concurrentLimit)
153+
return c.grpcClient.BackupCreate(name, uuid, checksum, backupTargetURL, labels, credential, compressionMethod, concurrentLimit, parameters)
154154
}
155155

156156
func (c *BackingImageManagerClient) BackupStatus(name string) (*longhorn.BackupBackingImageStatus, error) {

engineapi/backup_backing_image.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@ import (
1616
"k8s.io/apimachinery/pkg/util/wait"
1717
"k8s.io/utils/clock"
1818

19+
lhbackup "github.com/longhorn/go-common-libs/backup"
20+
1921
"github.com/longhorn/backupstore/backupbackingimage"
20-
"github.com/longhorn/longhorn-manager/datastore"
22+
2123
longhorn "github.com/longhorn/longhorn-manager/k8s/pkg/apis/longhorn/v1beta2"
24+
25+
"github.com/longhorn/longhorn-manager/datastore"
2226
"github.com/longhorn/longhorn-manager/types"
2327
)
2428

@@ -112,10 +116,12 @@ func NewBackupBackingImageMonitor(logger logrus.FieldLogger, ds *datastore.DataS
112116
quit: quit,
113117
}
114118

119+
backupBackingImageParameters := getBackupBackingImageParameters(backingImage)
120+
115121
// Call backing image manager API snapshot backup
116122
if bbi.Status.State == longhorn.BackupStateNew {
117123
err := m.client.BackupCreate(bbi.Name, backingImage.Status.UUID, bbi.Status.Checksum,
118-
backupTargetClient.URL, bbi.Spec.Labels, backupTargetClient.Credential, string(compressionMethod), concurrentLimit)
124+
backupTargetClient.URL, bbi.Spec.Labels, backupTargetClient.Credential, string(compressionMethod), concurrentLimit, backupBackingImageParameters)
119125
if err != nil {
120126
if !strings.Contains(err.Error(), "DeadlineExceeded") {
121127
m.logger.WithError(err).Warn("failed to take backing image backup")
@@ -258,3 +264,10 @@ func (m *BackupBackingImageMonitor) GetBackupBackingImageStatus() longhorn.Backu
258264
func (m *BackupBackingImageMonitor) Close() {
259265
m.quit()
260266
}
267+
268+
func getBackupBackingImageParameters(backingImage *longhorn.BackingImage) map[string]string {
269+
parameters := map[string]string{}
270+
parameters[lhbackup.LonghornBackupBackingImageParameterSecret] = string(backingImage.Spec.Secret)
271+
parameters[lhbackup.LonghornBackupBackingImageParameterSecretNamespace] = string(backingImage.Spec.SecretNamespace)
272+
return parameters
273+
}

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ require (
6060
github.com/gorilla/websocket v1.5.3
6161
github.com/jinzhu/copier v0.4.0
6262
github.com/kubernetes-csi/csi-lib-utils v0.19.0
63-
github.com/longhorn/backing-image-manager v1.7.0-dev.0.20240823042906-1ae3d5073f60
63+
github.com/longhorn/backing-image-manager v1.8.0-dev-20240825.0.20240828064910-e0449cbedcae
6464
github.com/longhorn/backupstore v0.0.0-20240827054225-fe89e488b75f
6565
github.com/longhorn/go-common-libs v0.0.0-20240821134112-907f57efd48f
6666
github.com/longhorn/go-iscsi-helper v0.0.0-20240811043302-df8de353dd58
6767
github.com/longhorn/go-spdk-helper v0.0.0-20240827171022-9fe38fff5b51
68-
github.com/longhorn/longhorn-engine v1.7.0-dev.0.20240824053610-9d2b194f765f
68+
github.com/longhorn/longhorn-engine v1.8.0-dev-20240825
6969
github.com/longhorn/longhorn-instance-manager v1.8.0-dev-20240825.0.20240828024302-1bdcacd93207
7070
github.com/longhorn/longhorn-share-manager v1.7.0-rc1
7171
github.com/pkg/errors v0.9.1

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0
157157
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
158158
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de h1:9TO3cAIGXtEhnIaL+V+BEER86oLrvS+kWobKpbJuye0=
159159
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9B/r2mtpb6U+EI2rYA5OAXxsYw6wTamcNW+zcE=
160-
github.com/longhorn/backing-image-manager v1.7.0-dev.0.20240823042906-1ae3d5073f60 h1:iZrC1Xq2k9fUVFkeZrD6X6UxaPZNr3jBZ5tyo+Efbhg=
161-
github.com/longhorn/backing-image-manager v1.7.0-dev.0.20240823042906-1ae3d5073f60/go.mod h1:uRo+kg+oA0+5jcFtBcajOzAv6pXjy7gKUgwMEndn698=
160+
github.com/longhorn/backing-image-manager v1.8.0-dev-20240825.0.20240828064910-e0449cbedcae h1:fPsMlEy7I7Qx2EbuTGOjVkfkwAjCkTatFIeF3+fz8l4=
161+
github.com/longhorn/backing-image-manager v1.8.0-dev-20240825.0.20240828064910-e0449cbedcae/go.mod h1:3IoBX6MkcjJefcwZNSoprmc/GgFfrTYYK44KtzaxI3g=
162162
github.com/longhorn/backupstore v0.0.0-20240827054225-fe89e488b75f h1:/Wo/leT2yrMmiDieCGhzqyzXb9FNsWoGeYWNfuf29KA=
163163
github.com/longhorn/backupstore v0.0.0-20240827054225-fe89e488b75f/go.mod h1:N4cqNhSs4VUw9aGbO2OfyiIvJL7/L53hUrNiT73UN+U=
164164
github.com/longhorn/go-common-libs v0.0.0-20240821134112-907f57efd48f h1:hjqUs3WVodkzrWwlUMVsnKAlom3uohoNlhZBGLsRvQY=
@@ -167,8 +167,8 @@ github.com/longhorn/go-iscsi-helper v0.0.0-20240811043302-df8de353dd58 h1:fzLAnC
167167
github.com/longhorn/go-iscsi-helper v0.0.0-20240811043302-df8de353dd58/go.mod h1:TobRDCXmF0Ni+jz6+nLJamw3uVu+gNDZoZre1JczGwc=
168168
github.com/longhorn/go-spdk-helper v0.0.0-20240827171022-9fe38fff5b51 h1:qU69qwOdcJyDG36Bgp4/b/lydmpJZsPVx+bpszrzQFc=
169169
github.com/longhorn/go-spdk-helper v0.0.0-20240827171022-9fe38fff5b51/go.mod h1:i9btdUP+14isigk+vOfANF7MQAbDO+u/ixeA/oOUwtA=
170-
github.com/longhorn/longhorn-engine v1.7.0-dev.0.20240824053610-9d2b194f765f h1:Nsal/5akxiEyoBL+M0NOXiV5R96ACEgC64rK5w0VKcY=
171-
github.com/longhorn/longhorn-engine v1.7.0-dev.0.20240824053610-9d2b194f765f/go.mod h1:E1ec7ub7SNGvASDtiFHL1dXX4bhEQiroBixD2GGeRbQ=
170+
github.com/longhorn/longhorn-engine v1.8.0-dev-20240825 h1:O0A7ebPjvVXXLN3r3oXYUV8D1v4qVC+6Cp/ATQstNQU=
171+
github.com/longhorn/longhorn-engine v1.8.0-dev-20240825/go.mod h1:E1ec7ub7SNGvASDtiFHL1dXX4bhEQiroBixD2GGeRbQ=
172172
github.com/longhorn/longhorn-instance-manager v1.8.0-dev-20240825.0.20240828024302-1bdcacd93207 h1:07e35ywxlYhF2yFgYko6Ni6tL4NyjeZU7eSm5pOvF6o=
173173
github.com/longhorn/longhorn-instance-manager v1.8.0-dev-20240825.0.20240828024302-1bdcacd93207/go.mod h1:D6ciWSaUShhjZGK3V/IHgO0o1XOOmdIRUSGX59GDjiY=
174174
github.com/longhorn/longhorn-share-manager v1.7.0-rc1 h1:LsSkSajhG8tCfORKKfwK+8XHVrT/8rI9DRWb7fuoVls=

k8s/crds.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,12 @@ spec:
712712
progress:
713713
description: The backing image backup progress.
714714
type: integer
715+
secret:
716+
description: Record the secret if this backup backing image is encrypted
717+
type: string
718+
secretNamespace:
719+
description: Record the secret namespace if this backup backing image is encrypted
720+
type: string
715721
size:
716722
description: The backing image size.
717723
format: int64

k8s/pkg/apis/longhorn/v1beta2/backupbackingimage.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ type BackupBackingImageStatus struct {
6464
// Compression method
6565
// +optional
6666
CompressionMethod BackupCompressionMethod `json:"compressionMethod"`
67+
// Record the secret if this backup backing image is encrypted
68+
// +optional
69+
Secret string `json:"secret"`
70+
// Record the secret namespace if this backup backing image is encrypted
71+
// +optional
72+
SecretNamespace string `json:"secretNamespace"`
6773
}
6874

6975
// +genclient

vendor/github.com/longhorn/backing-image-manager/pkg/client/manager_client.go

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/modules.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ github.com/kylelemons/godebug/diff
232232
# github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de
233233
## explicit
234234
github.com/liggitt/tabwriter
235-
# github.com/longhorn/backing-image-manager v1.7.0-dev.0.20240823042906-1ae3d5073f60
235+
# github.com/longhorn/backing-image-manager v1.8.0-dev-20240825.0.20240828064910-e0449cbedcae
236236
## explicit; go 1.22.2
237237
github.com/longhorn/backing-image-manager/api
238238
github.com/longhorn/backing-image-manager/pkg/client
@@ -271,7 +271,7 @@ github.com/longhorn/go-iscsi-helper/util
271271
# github.com/longhorn/go-spdk-helper v0.0.0-20240827171022-9fe38fff5b51
272272
## explicit; go 1.22.0
273273
github.com/longhorn/go-spdk-helper/pkg/types
274-
# github.com/longhorn/longhorn-engine v1.7.0-dev.0.20240824053610-9d2b194f765f
274+
# github.com/longhorn/longhorn-engine v1.8.0-dev-20240825
275275
## explicit; go 1.22.2
276276
github.com/longhorn/longhorn-engine/pkg/interceptor
277277
github.com/longhorn/longhorn-engine/pkg/meta

0 commit comments

Comments
 (0)