@@ -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+
842877func (s * Server ) VolumeUpdateFreezeFilesystemForSnapshot (rw http.ResponseWriter , req * http.Request ) error {
843878 var input UpdateFreezeFilesystemForSnapshotInput
844879 id := mux .Vars (req )["name" ]
0 commit comments