Skip to content

Commit

Permalink
check FollowLink errors
Browse files Browse the repository at this point in the history
connection#FollowLink issues an additional HTTP call which may fail if ovirt-engine
suddenly becomes unavailable.

Currently it will panic, but once [1] is merged, an error will be
returned.

[1] oVirt/ovirt-engine-sdk-go#215

Signed-off-by: Benny Zlotnik <[email protected]>
  • Loading branch information
bennyz committed Oct 5, 2020
1 parent c4cddfb commit c4effc5
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pkg/operator/storageclass_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ func (c *OvirtStrogeClassController) getStorageDomain(ctx context.Context) (stri

for _, attachment := range attachments.MustAttachments().Slice() {
if attachment.MustBootable() {
d, _ := conn.FollowLink(attachment.MustDisk())
d, err := conn.FollowLink(attachment.MustDisk())
if err != nil {
klog.Errorf(fmt.Sprintf("Failed to follow disk: %v", err))
return "", err
}

disk, ok := d.(*ovirtsdk.Disk)
klog.Info(fmt.Sprintf("Extracting Storage Domain from disk: %s", disk.MustId()))

Expand All @@ -106,7 +111,11 @@ func (c *OvirtStrogeClassController) getStorageDomain(ctx context.Context) (stri
return "", err
}

s, _ := conn.FollowLink(disk.MustStorageDomains().Slice()[0])
s, err := conn.FollowLink(disk.MustStorageDomains().Slice()[0])
if err != nil {
klog.Errorf(fmt.Sprintf("Failed to follow Storage Domain: %v", err))
return "", err
}
sd, ok := s.(*ovirtsdk.StorageDomain)

klog.Info(fmt.Sprintf("Fetched Storage Domain %s", sd.MustName()))
Expand Down

0 comments on commit c4effc5

Please sign in to comment.