Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: slow volume attach to server #269

Merged
merged 4 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [1.1.4]
- **Fixes**:
- Volume should populate the status ID from the bootvolume of the server, because it cannot store it on create. This can cause larger wait times for volume attach.

## [1.1.3]
- **Features**:
- Enable `publishConnectionDetails` option for s3 key, compute user and k8s clusters
Expand Down
10 changes: 5 additions & 5 deletions internal/controller/compute/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package server
import (
"context"
"fmt"
"reflect"

sdkgo "github.com/ionos-cloud/sdk-go/v6"

Expand Down Expand Up @@ -135,6 +134,9 @@ func (c *externalServer) Observe(ctx context.Context, mg resource.Managed) (mana
cr.Status.AtProvider.State = clients.GetCoreResourceState(&observed)
if observed.Properties != nil {
cr.Status.AtProvider.Name = *observed.Properties.Name
if observed.Properties.BootVolume != nil && observed.Properties.BootVolume.Id != nil {
cr.Status.AtProvider.VolumeID = *observed.Properties.BootVolume.Id
}
}
c.log.Debug(fmt.Sprintf("Observing state: %v", cr.Status.AtProvider.State))
clients.UpdateCondition(cr, cr.Status.AtProvider.State)
Expand Down Expand Up @@ -191,7 +193,7 @@ func (c *externalServer) Create(ctx context.Context, mg resource.Managed) (manag
// Set External Name
cr.Status.AtProvider.ServerID = *newInstance.Id
meta.SetExternalName(cr, *newInstance.Id)
if !utils.IsEmptyValue(reflect.ValueOf(cr.Spec.ForProvider.VolumeCfg.VolumeID)) {
if cr.Spec.ForProvider.VolumeCfg.VolumeID != "" {
c.log.Debug("Attaching Volume...", "volume", cr.Spec.ForProvider.VolumeCfg.VolumeID)
_, apiResponse, err = c.service.AttachVolume(ctx, cr.Spec.ForProvider.DatacenterCfg.DatacenterID,
cr.Status.AtProvider.ServerID, sdkgo.Volume{Id: &cr.Spec.ForProvider.VolumeCfg.VolumeID})
Expand All @@ -202,8 +204,6 @@ func (c *externalServer) Create(ctx context.Context, mg resource.Managed) (manag
if err = compute.WaitForRequest(ctx, c.service.GetAPIClient(), apiResponse); err != nil {
return creation, err
}
// Set Boot Volume ID
cr.Status.AtProvider.VolumeID = cr.Spec.ForProvider.VolumeCfg.VolumeID
}
return creation, nil
}
Expand All @@ -218,7 +218,7 @@ func (c *externalServer) Update(ctx context.Context, mg resource.Managed) (manag
return managed.ExternalUpdate{}, nil
}
// Attach or Detach Volume
if !utils.IsEmptyValue(reflect.ValueOf(cr.Spec.ForProvider.VolumeCfg.VolumeID)) {
if cr.Spec.ForProvider.VolumeCfg.VolumeID != "" {
c.log.Debug("Update, attaching Volume", "volume", cr.Spec.ForProvider.VolumeCfg.VolumeID)
_, apiResponse, err := c.service.AttachVolume(ctx, cr.Spec.ForProvider.DatacenterCfg.DatacenterID, cr.Status.AtProvider.ServerID,
sdkgo.Volume{Id: &cr.Spec.ForProvider.VolumeCfg.VolumeID})
Expand Down
Loading