Skip to content

Commit

Permalink
add iops configuration and importing from snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
Codelax committed Dec 27, 2024
1 parent eaa5f8a commit ee2186a
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .web-docs/components/builder/scaleway/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ can also be supplied to override the typical auto-generated key:

- `size` (uint64) - Size of the newly created volume

- `iops` (\*uint32) - IOPS is the number of requested iops for the server's volume. This will not impact created snapshot.

<!-- End of code generated from the comments of the ConfigBlockVolume struct in builder/scaleway/config.go; -->


Expand Down
2 changes: 2 additions & 0 deletions builder/scaleway/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ type ConfigBlockVolume struct {
SnapshotID string `mapstructure:"snapshot_id"`
// Size of the newly created volume
Size uint64 `mapstructure:"size"`
// IOPS is the number of requested iops for the server's volume. This will not impact created snapshot.
IOPS *uint32 `mapstructure:"iops"`
}

type Config struct {
Expand Down
2 changes: 2 additions & 0 deletions builder/scaleway/config.hcl2spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions builder/scaleway/step_backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ func backupVolumesFromServer(server *instance.Server) map[string]*instance.Serve
backupVolumes := map[string]*instance.ServerActionRequestVolumeBackupTemplate{}

for _, volume := range server.Volumes {
backupVolumes[volume.ID] = &instance.ServerActionRequestVolumeBackupTemplate{
//VolumeType: instance.SnapshotVolumeTypeUnified,
}
backupVolumes[volume.ID] = &instance.ServerActionRequestVolumeBackupTemplate{}
}
return backupVolumes
}
Expand Down
17 changes: 10 additions & 7 deletions builder/scaleway/step_create_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,20 @@ func (s *stepCreateVolume) Run(ctx context.Context, state multistep.StateBag) mu

volumeTemplates := []*instance.VolumeServerTemplate(nil)
for _, requestedVolume := range c.BlockVolumes {
volume, err := blockAPI.CreateVolume(&block.CreateVolumeRequest{
req := &block.CreateVolumeRequest{
Zone: scw.Zone(c.Zone),
Name: requestedVolume.Name,
PerfIops: scw.Uint32Ptr(5000), // TODO: configuration
PerfIops: requestedVolume.IOPS,
ProjectID: c.ProjectID,
FromEmpty: &block.CreateVolumeRequestFromEmpty{
}
if requestedVolume.SnapshotID != "" {
req.FromSnapshot = &block.CreateVolumeRequestFromSnapshot{}
} else {
req.FromEmpty = &block.CreateVolumeRequestFromEmpty{
Size: scw.Size(requestedVolume.Size),
},
FromSnapshot: nil, // TODO
Tags: nil, // TODO
}, scw.WithContext(ctx))
}
}
volume, err := blockAPI.CreateVolume(req, scw.WithContext(ctx))
if err != nil {
state.Put("error", err)
ui.Error(err.Error())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@

- `size` (uint64) - Size of the newly created volume

- `iops` (\*uint32) - IOPS is the number of requested iops for the server's volume. This will not impact created snapshot.

<!-- End of code generated from the comments of the ConfigBlockVolume struct in builder/scaleway/config.go; -->

0 comments on commit ee2186a

Please sign in to comment.