Skip to content

Commit a918dca

Browse files
authored
Merge branch 'master' into issue11286
2 parents a8a98cd + fe5e0b5 commit a918dca

File tree

1,253 files changed

+141110
-46183
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,253 files changed

+141110
-46183
lines changed

Dockerfile.dapper

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM registry.suse.com/bci/golang:1.24
1+
FROM registry.suse.com/bci/golang:1.25
22

33
ARG DAPPER_HOST_ARCH
44
ARG http_proxy
@@ -18,6 +18,9 @@ WORKDIR ${DAPPER_SOURCE}
1818
ENTRYPOINT ["./scripts/entry"]
1919
CMD ["ci"]
2020

21+
RUN zypper -n ref && \
22+
zypper update -y
23+
2124
RUN zypper -n install gcc ca-certificates git wget curl vim less file python3-tox python3-devel iptables libdevmapper1_03 libltdl7 awk docker zip unzip && \
2225
rm -rf /var/cache/zypp/*
2326

api/model.go

Lines changed: 130 additions & 57 deletions
Large diffs are not rendered by default.

api/router.go

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,21 +69,22 @@ func NewRouter(s *Server) *mux.Router {
6969
r.Methods("DELETE").Path("/v1/volumes/{name}").Handler(f(schemas, s.VolumeDelete))
7070
r.Methods("POST").Path("/v1/volumes").Handler(f(schemas, s.fwd.Handler(s.fwd.HandleProxyRequestByNodeID, s.fwd.GetHTTPAddressByNodeID(NodeHasDefaultEngineImage(s.m)), s.VolumeCreate)))
7171
volumeActions := map[string]func(http.ResponseWriter, *http.Request) error{
72-
"attach": s.VolumeAttach,
73-
"detach": s.VolumeDetach,
74-
"salvage": s.VolumeSalvage,
75-
"updateDataLocality": s.VolumeUpdateDataLocality,
76-
"updateAccessMode": s.VolumeUpdateAccessMode,
77-
"updateUnmapMarkSnapChainRemoved": s.VolumeUpdateUnmapMarkSnapChainRemoved,
78-
"updateSnapshotMaxCount": s.VolumeUpdateSnapshotMaxCount,
79-
"updateSnapshotMaxSize": s.VolumeUpdateSnapshotMaxSize,
80-
"updateReplicaSoftAntiAffinity": s.VolumeUpdateReplicaSoftAntiAffinity,
81-
"updateReplicaZoneSoftAntiAffinity": s.VolumeUpdateReplicaZoneSoftAntiAffinity,
82-
"updateReplicaDiskSoftAntiAffinity": s.VolumeUpdateReplicaDiskSoftAntiAffinity,
83-
"activate": s.VolumeActivate,
84-
"expand": s.VolumeExpand,
85-
"cancelExpansion": s.VolumeCancelExpansion,
86-
"offlineReplicaRebuilding": s.VolumeOfflineRebuilding,
72+
"attach": s.VolumeAttach,
73+
"detach": s.VolumeDetach,
74+
"salvage": s.VolumeSalvage,
75+
"updateDataLocality": s.VolumeUpdateDataLocality,
76+
"updateAccessMode": s.VolumeUpdateAccessMode,
77+
"updateUnmapMarkSnapChainRemoved": s.VolumeUpdateUnmapMarkSnapChainRemoved,
78+
"updateSnapshotMaxCount": s.VolumeUpdateSnapshotMaxCount,
79+
"updateSnapshotMaxSize": s.VolumeUpdateSnapshotMaxSize,
80+
"updateReplicaRebuildingBandwidthLimit": s.VolumeUpdateReplicaRebuildingBandwidthLimit,
81+
"updateReplicaSoftAntiAffinity": s.VolumeUpdateReplicaSoftAntiAffinity,
82+
"updateReplicaZoneSoftAntiAffinity": s.VolumeUpdateReplicaZoneSoftAntiAffinity,
83+
"updateReplicaDiskSoftAntiAffinity": s.VolumeUpdateReplicaDiskSoftAntiAffinity,
84+
"activate": s.VolumeActivate,
85+
"expand": s.VolumeExpand,
86+
"cancelExpansion": s.VolumeCancelExpansion,
87+
"offlineReplicaRebuilding": s.VolumeOfflineRebuilding,
8788

8889
"updateReplicaCount": s.VolumeUpdateReplicaCount,
8990
"updateReplicaAutoBalance": s.VolumeUpdateReplicaAutoBalance,
@@ -291,5 +292,13 @@ func NewRouter(s *Server) *mux.Router {
291292
r.Path("/v1/ws/events").Handler(f(schemas, eventListStream))
292293
r.Path("/v1/ws/{period}/events").Handler(f(schemas, eventListStream))
293294

295+
// VolumeAttachment routes
296+
r.Methods("GET").Path("/v1/volumeattachments").Handler(f(schemas, s.VolumeAttachmentList))
297+
r.Methods("GET").Path("/v1/volumeattachments/{name}").Handler(f(schemas, s.VolumeAttachmentGet))
298+
299+
volumeAttachmentListStream := NewStreamHandlerFunc("volumeattachments", s.wsc.NewWatcher("volumeAttachment"), s.volumeAttachmentList)
300+
r.Path("/v1/ws/volumeattachments").Handler(f(schemas, volumeAttachmentListStream))
301+
r.Path("/v1/ws/{period}/volumeattachments").Handler(f(schemas, volumeAttachmentListStream))
302+
294303
return r
295304
}

api/volume.go

Lines changed: 64 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -172,36 +172,44 @@ func (s *Server) VolumeCreate(rw http.ResponseWriter, req *http.Request) error {
172172
return errors.Wrap(err, "failed to parse snapshot max size")
173173
}
174174

175+
backupBlockSize, err := util.ConvertSize(volume.BackupBlockSize)
176+
if err != nil {
177+
return errors.Wrapf(err, "failed to parse backup block size %v", volume.BackupBlockSize)
178+
}
179+
175180
v, err := s.m.Create(volume.Name, &longhorn.VolumeSpec{
176-
Size: size,
177-
AccessMode: volume.AccessMode,
178-
Migratable: volume.Migratable,
179-
Encrypted: volume.Encrypted,
180-
Frontend: volume.Frontend,
181-
FromBackup: volume.FromBackup,
182-
RestoreVolumeRecurringJob: volume.RestoreVolumeRecurringJob,
183-
DataSource: volume.DataSource,
184-
NumberOfReplicas: volume.NumberOfReplicas,
185-
ReplicaAutoBalance: volume.ReplicaAutoBalance,
186-
DataLocality: volume.DataLocality,
187-
StaleReplicaTimeout: volume.StaleReplicaTimeout,
188-
BackingImage: volume.BackingImage,
189-
Standby: volume.Standby,
190-
RevisionCounterDisabled: volume.RevisionCounterDisabled,
191-
DiskSelector: volume.DiskSelector,
192-
NodeSelector: volume.NodeSelector,
193-
SnapshotDataIntegrity: volume.SnapshotDataIntegrity,
194-
SnapshotMaxCount: volume.SnapshotMaxCount,
195-
SnapshotMaxSize: snapshotMaxSize,
196-
BackupCompressionMethod: volume.BackupCompressionMethod,
197-
UnmapMarkSnapChainRemoved: volume.UnmapMarkSnapChainRemoved,
198-
ReplicaSoftAntiAffinity: volume.ReplicaSoftAntiAffinity,
199-
ReplicaZoneSoftAntiAffinity: volume.ReplicaZoneSoftAntiAffinity,
200-
ReplicaDiskSoftAntiAffinity: volume.ReplicaDiskSoftAntiAffinity,
201-
DataEngine: volume.DataEngine,
202-
FreezeFilesystemForSnapshot: volume.FreezeFilesystemForSnapshot,
203-
BackupTargetName: volume.BackupTargetName,
204-
OfflineRebuilding: volume.OfflineRebuilding,
181+
Size: size,
182+
AccessMode: volume.AccessMode,
183+
Migratable: volume.Migratable,
184+
Encrypted: volume.Encrypted,
185+
Frontend: volume.Frontend,
186+
FromBackup: volume.FromBackup,
187+
RestoreVolumeRecurringJob: volume.RestoreVolumeRecurringJob,
188+
DataSource: volume.DataSource,
189+
CloneMode: volume.CloneMode,
190+
NumberOfReplicas: volume.NumberOfReplicas,
191+
ReplicaAutoBalance: volume.ReplicaAutoBalance,
192+
DataLocality: volume.DataLocality,
193+
StaleReplicaTimeout: volume.StaleReplicaTimeout,
194+
BackingImage: volume.BackingImage,
195+
Standby: volume.Standby,
196+
RevisionCounterDisabled: volume.RevisionCounterDisabled,
197+
DiskSelector: volume.DiskSelector,
198+
NodeSelector: volume.NodeSelector,
199+
SnapshotDataIntegrity: volume.SnapshotDataIntegrity,
200+
SnapshotMaxCount: volume.SnapshotMaxCount,
201+
SnapshotMaxSize: snapshotMaxSize,
202+
ReplicaRebuildingBandwidthLimit: volume.ReplicaRebuildingBandwidthLimit,
203+
BackupCompressionMethod: volume.BackupCompressionMethod,
204+
BackupBlockSize: backupBlockSize,
205+
UnmapMarkSnapChainRemoved: volume.UnmapMarkSnapChainRemoved,
206+
ReplicaSoftAntiAffinity: volume.ReplicaSoftAntiAffinity,
207+
ReplicaZoneSoftAntiAffinity: volume.ReplicaZoneSoftAntiAffinity,
208+
ReplicaDiskSoftAntiAffinity: volume.ReplicaDiskSoftAntiAffinity,
209+
DataEngine: volume.DataEngine,
210+
FreezeFilesystemForSnapshot: volume.FreezeFilesystemForSnapshot,
211+
BackupTargetName: volume.BackupTargetName,
212+
OfflineRebuilding: volume.OfflineRebuilding,
205213
}, volume.RecurringJobSelector)
206214
if err != nil {
207215
return errors.Wrap(err, "failed to create volume")
@@ -839,6 +847,33 @@ func (s *Server) VolumeUpdateSnapshotMaxSize(rw http.ResponseWriter, req *http.R
839847
return s.responseWithVolume(rw, req, "", v)
840848
}
841849

850+
func (s *Server) VolumeUpdateReplicaRebuildingBandwidthLimit(rw http.ResponseWriter, req *http.Request) error {
851+
var input UpdateReplicaRebuildingBandwidthLimit
852+
id := mux.Vars(req)["name"]
853+
854+
apiContext := api.GetApiContext(req)
855+
if err := apiContext.Read(&input); err != nil {
856+
return errors.Wrap(err, "failed to read ReplicaRebuildingBandwidthLimit input")
857+
}
858+
859+
replicaRebuildingBandwidthLimit, err := util.ConvertSize(input.ReplicaRebuildingBandwidthLimit)
860+
if err != nil {
861+
return fmt.Errorf("failed to parse replica rebuilding bandwidth limit %v", err)
862+
}
863+
864+
obj, err := util.RetryOnConflictCause(func() (interface{}, error) {
865+
return s.m.UpdateReplicaRebuildingBandwidthLimit(id, replicaRebuildingBandwidthLimit)
866+
})
867+
if err != nil {
868+
return err
869+
}
870+
v, ok := obj.(*longhorn.Volume)
871+
if !ok {
872+
return fmt.Errorf("failed to convert to volume %v object", id)
873+
}
874+
return s.responseWithVolume(rw, req, "", v)
875+
}
876+
842877
func (s *Server) VolumeUpdateFreezeFilesystemForSnapshot(rw http.ResponseWriter, req *http.Request) error {
843878
var input UpdateFreezeFilesystemForSnapshotInput
844879
id := mux.Vars(req)["name"]

api/volumeattachment.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package api
2+
3+
import (
4+
"net/http"
5+
6+
"github.com/gorilla/mux"
7+
"github.com/pkg/errors"
8+
9+
"github.com/rancher/go-rancher/api"
10+
"github.com/rancher/go-rancher/client"
11+
)
12+
13+
func (s *Server) VolumeAttachmentGet(rw http.ResponseWriter, req *http.Request) error {
14+
apiContext := api.GetApiContext(req)
15+
16+
id := mux.Vars(req)["name"]
17+
18+
volumeAttachment, err := s.m.GetVolumeAttachment(id)
19+
if err != nil {
20+
return errors.Wrapf(err, "failed to get volume attachment '%s'", id)
21+
}
22+
apiContext.Write(toVolumeAttachmentResource(volumeAttachment))
23+
return nil
24+
}
25+
26+
func (s *Server) VolumeAttachmentList(rw http.ResponseWriter, req *http.Request) (err error) {
27+
apiContext := api.GetApiContext(req)
28+
29+
volumeAttachmentList, err := s.m.ListVolumeAttachment()
30+
if err != nil {
31+
return errors.Wrap(err, "failed to list volume attachments")
32+
}
33+
apiContext.Write(toVolumeAttachmentCollection(volumeAttachmentList, apiContext))
34+
return nil
35+
}
36+
37+
func (s *Server) volumeAttachmentList(apiContext *api.ApiContext) (*client.GenericCollection, error) {
38+
volumeAttachmentList, err := s.m.ListVolumeAttachment()
39+
if err != nil {
40+
return nil, errors.Wrap(err, "failed to list volume attachments")
41+
}
42+
return toVolumeAttachmentCollection(volumeAttachmentList, apiContext), nil
43+
}

app/daemon.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ func startWebhooksByLeaderElection(ctx context.Context, kubeconfigPath, currentN
182182
if err != nil {
183183
return err
184184
}
185-
if err := webhook.CheckWebhookServiceAvailability(types.WebhookTypeConversion); err != nil {
185+
if err := webhook.CheckWebhookServiceAvailability(types.WebhookTypeConversion, clientsWithoutDatastore); err != nil {
186186
return err
187187
}
188188
}
@@ -200,7 +200,7 @@ func startWebhooksByLeaderElection(ctx context.Context, kubeconfigPath, currentN
200200
return err
201201
}
202202

203-
if err := webhook.CheckWebhookServiceAvailability(types.WebhookTypeAdmission); err != nil {
203+
if err := webhook.CheckWebhookServiceAvailability(types.WebhookTypeAdmission, clients); err != nil {
204204
return err
205205
}
206206

client/generated_backup.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ const (
77
type Backup struct {
88
Resource `yaml:"-"`
99

10+
BackupMode string `json:"backupMode,omitempty" yaml:"backup_mode,omitempty"`
11+
1012
BackupTargetName string `json:"backupTargetName,omitempty" yaml:"backup_target_name,omitempty"`
1113

14+
BlockSize string `json:"blockSize,omitempty" yaml:"block_size,omitempty"`
15+
1216
CompressionMethod string `json:"compressionMethod,omitempty" yaml:"compression_method,omitempty"`
1317

1418
Created string `json:"created,omitempty" yaml:"created,omitempty"`
@@ -21,8 +25,12 @@ type Backup struct {
2125

2226
Name string `json:"name,omitempty" yaml:"name,omitempty"`
2327

28+
NewlyUploadDataSize string `json:"newlyUploadDataSize,omitempty" yaml:"newly_upload_data_size,omitempty"`
29+
2430
Progress int64 `json:"progress,omitempty" yaml:"progress,omitempty"`
2531

32+
ReUploadedDataSize string `json:"reUploadedDataSize,omitempty" yaml:"re_uploaded_data_size,omitempty"`
33+
2634
Size string `json:"size,omitempty" yaml:"size,omitempty"`
2735

2836
SnapshotCreated string `json:"snapshotCreated,omitempty" yaml:"snapshot_created,omitempty"`

client/generated_backup_backing_image.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ const (
77
type BackupBackingImage struct {
88
Resource `yaml:"-"`
99

10+
BackingImageName string `json:"backingImageName,omitempty" yaml:"backing_image_name,omitempty"`
11+
12+
BackupTargetName string `json:"backupTargetName,omitempty" yaml:"backup_target_name,omitempty"`
13+
1014
CompressionMethod string `json:"compressionMethod,omitempty" yaml:"compression_method,omitempty"`
1115

1216
Created string `json:"created,omitempty" yaml:"created,omitempty"`
@@ -23,7 +27,7 @@ type BackupBackingImage struct {
2327

2428
Secret string `json:"secret,omitempty" yaml:"secret,omitempty"`
2529

26-
SecretNamespace string `json:"secretNamespace,omitempty" yaml:"secretNamespace,omitempty"`
30+
SecretNamespace string `json:"secretNamespace,omitempty" yaml:"secret_namespace,omitempty"`
2731

2832
Size int64 `json:"size,omitempty" yaml:"size,omitempty"`
2933

client/generated_backup_target.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ type BackupTargetOperations interface {
3636
Update(existing *BackupTarget, updates interface{}) (*BackupTarget, error)
3737
ById(id string) (*BackupTarget, error)
3838
Delete(container *BackupTarget) error
39+
40+
ActionBackupTargetSync(*BackupTarget, *SyncBackupResource) (*BackupTargetListOutput, error)
41+
42+
ActionBackupTargetUpdate(*BackupTarget, *BackupTarget) (*BackupTargetListOutput, error)
3943
}
4044

4145
func newBackupTargetClient(rancherClient *RancherClient) *BackupTargetClient {
@@ -87,3 +91,21 @@ func (c *BackupTargetClient) ById(id string) (*BackupTarget, error) {
8791
func (c *BackupTargetClient) Delete(container *BackupTarget) error {
8892
return c.rancherClient.doResourceDelete(BACKUP_TARGET_TYPE, &container.Resource)
8993
}
94+
95+
func (c *BackupTargetClient) ActionBackupTargetSync(resource *BackupTarget, input *SyncBackupResource) (*BackupTargetListOutput, error) {
96+
97+
resp := &BackupTargetListOutput{}
98+
99+
err := c.rancherClient.doAction(BACKUP_TARGET_TYPE, "backupTargetSync", &resource.Resource, input, resp)
100+
101+
return resp, err
102+
}
103+
104+
func (c *BackupTargetClient) ActionBackupTargetUpdate(resource *BackupTarget, input *BackupTarget) (*BackupTargetListOutput, error) {
105+
106+
resp := &BackupTargetListOutput{}
107+
108+
err := c.rancherClient.doAction(BACKUP_TARGET_TYPE, "backupTargetUpdate", &resource.Resource, input, resp)
109+
110+
return resp, err
111+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package client
2+
3+
const (
4+
BACKUP_TARGET_LIST_OUTPUT_TYPE = "backupTargetListOutput"
5+
)
6+
7+
type BackupTargetListOutput struct {
8+
Resource `yaml:"-"`
9+
10+
Data []BackupTarget `json:"data,omitempty" yaml:"data,omitempty"`
11+
}
12+
13+
type BackupTargetListOutputCollection struct {
14+
Collection
15+
Data []BackupTargetListOutput `json:"data,omitempty"`
16+
client *BackupTargetListOutputClient
17+
}
18+
19+
type BackupTargetListOutputClient struct {
20+
rancherClient *RancherClient
21+
}
22+
23+
type BackupTargetListOutputOperations interface {
24+
List(opts *ListOpts) (*BackupTargetListOutputCollection, error)
25+
Create(opts *BackupTargetListOutput) (*BackupTargetListOutput, error)
26+
Update(existing *BackupTargetListOutput, updates interface{}) (*BackupTargetListOutput, error)
27+
ById(id string) (*BackupTargetListOutput, error)
28+
Delete(container *BackupTargetListOutput) error
29+
}
30+
31+
func newBackupTargetListOutputClient(rancherClient *RancherClient) *BackupTargetListOutputClient {
32+
return &BackupTargetListOutputClient{
33+
rancherClient: rancherClient,
34+
}
35+
}
36+
37+
func (c *BackupTargetListOutputClient) Create(container *BackupTargetListOutput) (*BackupTargetListOutput, error) {
38+
resp := &BackupTargetListOutput{}
39+
err := c.rancherClient.doCreate(BACKUP_TARGET_LIST_OUTPUT_TYPE, container, resp)
40+
return resp, err
41+
}
42+
43+
func (c *BackupTargetListOutputClient) Update(existing *BackupTargetListOutput, updates interface{}) (*BackupTargetListOutput, error) {
44+
resp := &BackupTargetListOutput{}
45+
err := c.rancherClient.doUpdate(BACKUP_TARGET_LIST_OUTPUT_TYPE, &existing.Resource, updates, resp)
46+
return resp, err
47+
}
48+
49+
func (c *BackupTargetListOutputClient) List(opts *ListOpts) (*BackupTargetListOutputCollection, error) {
50+
resp := &BackupTargetListOutputCollection{}
51+
err := c.rancherClient.doList(BACKUP_TARGET_LIST_OUTPUT_TYPE, opts, resp)
52+
resp.client = c
53+
return resp, err
54+
}
55+
56+
func (cc *BackupTargetListOutputCollection) Next() (*BackupTargetListOutputCollection, error) {
57+
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
58+
resp := &BackupTargetListOutputCollection{}
59+
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
60+
resp.client = cc.client
61+
return resp, err
62+
}
63+
return nil, nil
64+
}
65+
66+
func (c *BackupTargetListOutputClient) ById(id string) (*BackupTargetListOutput, error) {
67+
resp := &BackupTargetListOutput{}
68+
err := c.rancherClient.doById(BACKUP_TARGET_LIST_OUTPUT_TYPE, id, resp)
69+
if apiError, ok := err.(*ApiError); ok {
70+
if apiError.StatusCode == 404 {
71+
return nil, nil
72+
}
73+
}
74+
return resp, err
75+
}
76+
77+
func (c *BackupTargetListOutputClient) Delete(container *BackupTargetListOutput) error {
78+
return c.rancherClient.doResourceDelete(BACKUP_TARGET_LIST_OUTPUT_TYPE, &container.Resource)
79+
}

0 commit comments

Comments
 (0)