Skip to content
This repository was archived by the owner on Oct 10, 2023. It is now read-only.

Commit 6280ee1

Browse files
authored
return error if context canceled during getting virtual machine images (#4415) (#4444)
if context deadline exceeded when retrieving vm metadata we need correct error message instead of partially retrieving results (cherry picked from commit e403941)
1 parent 2f244e3 commit 6280ee1

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

tkg/vc/client.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,9 @@ func (c *DefaultClient) GetVirtualMachineImages(ctx context.Context, datacenterM
697697
if ovaVersion, distroName, distroVersion, distroArch := c.getVMMetadata(&vms[i]); ovaVersion != "" {
698698
path, _, err := c.GetPath(ctx, vms[i].Self.Value)
699699
if err != nil {
700+
if ctx.Err() != nil {
701+
return results, err
702+
}
700703
continue
701704
}
702705
obj := &tkgtypes.VSphereVirtualMachine{

tkg/vsphere-template-resolver/templateresolver/resolver_impl.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ func (r *Resolver) GetVSphereEndpoint(svrContext *VSphereContext) (vc.Client, er
3838
vcURL.Path = "/sdk"
3939

4040
r.Log.Info(fmt.Sprintf("Creating client with endpoint: %v", vcURL))
41+
// TODO: setup a cache to reuse vc sessions
4142
vcClient, err := vc.NewClient(vcURL, svrContext.TLSThumbprint, svrContext.InsecureSkipVerify)
4243
if err != nil {
4344
return nil, errors.Wrap(err, "failed to create vc client")

0 commit comments

Comments
 (0)