Skip to content

Commit ff3b867

Browse files
committed
PR: spelling, error handling
Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
1 parent 31a6a0a commit ff3b867

5 files changed

Lines changed: 19 additions & 10 deletions

File tree

Protobuild.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ generators = ["go", "go-grpc"]
66
before = ["./protobuf"]
77

88
# defaults are "/usr/local/include" and "/usr/include", which don't exist on Windows.
9-
# override defaults to supress errors about non-existant directories.
9+
# override defaults to supress errors about non-existent directories.
1010
after = []
1111

1212
# This section maps protobuf imports to Go packages.

internal/guest/runtime/hcsv2/uvm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1589,7 +1589,7 @@ func (h *Host) cleanupVirtualPod(ctx context.Context, virtualSandboxID string) {
15891589

15901590
vp, exists := h.virtualPods[virtualSandboxID]
15911591
if !exists {
1592-
entry.Warn("attempted to cleanup non-existant virtual sandbox pod")
1592+
entry.Warn("attempted to cleanup non-existent virtual sandbox pod")
15931593
return // virtual pod does not exist
15941594
}
15951595

internal/uvm/network.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package uvm
44

55
import (
66
"context"
7+
"errors"
78
"fmt"
89
"os"
910
"slices"
@@ -12,7 +13,6 @@ import (
1213
"github.com/Microsoft/go-winio"
1314
"github.com/Microsoft/go-winio/pkg/guid"
1415
"github.com/containerd/ttrpc"
15-
"github.com/pkg/errors"
1616
"github.com/sirupsen/logrus"
1717

1818
"github.com/Microsoft/hcsshim/hcn"
@@ -147,7 +147,7 @@ func (n *ncproxyClient) Close() error {
147147
func (uvm *UtilityVM) GetNCProxyClient() (*ncproxyClient, error) {
148148
conn, err := winio.DialPipe(uvm.ncProxyClientAddress, nil)
149149
if err != nil {
150-
return nil, errors.Wrap(err, "failed to connect to ncproxy service")
150+
return nil, fmt.Errorf("failed to connect to ncproxy service: %w", err)
151151
}
152152
raw := ttrpc.NewClient(conn, ttrpc.WithOnClose(func() { conn.Close() }))
153153
return &ncproxyClient{raw, ncproxyttrpc.NewNetworkConfigProxyClient(raw)}, nil
@@ -298,7 +298,7 @@ func (e *externalNetworkSetup) ConfigureNetworking(ctx context.Context, namespac
298298

299299
client, err := e.vm.GetNCProxyClient()
300300
if err != nil {
301-
return errors.Wrapf(err, "no ncproxy client for UVM %q", e.vm.ID())
301+
return fmt.Errorf("no ncproxy client for UVM %q: %w", e.vm.ID(), err)
302302
}
303303
defer client.Close()
304304

@@ -523,16 +523,25 @@ func (uvm *UtilityVM) RemoveNetNS(ctx context.Context, id string) error {
523523

524524
ns, ok := uvm.namespaces[id]
525525
if !ok {
526-
entry.Warn("cannot remove non-existant namespace from uVM")
526+
entry.Warn("cannot remove non-existent namespace from uVM")
527527
return nil
528528
}
529529

530530
entry.WithField("nics", log.Format(ctx, ns.nics)).Debug("removing NICs from namespace")
531+
var errs []error
531532
for _, ninfo := range ns.nics {
532533
if err := uvm.removeNIC(ctx, ninfo.ID, ninfo.Endpoint); err != nil {
533-
return err
534+
entry.WithFields(logrus.Fields{
535+
logrus.ErrorKey: err,
536+
"nic-id": ninfo.ID,
537+
}).Warn("failed to remove NIC from uVM")
538+
errs = append(errs, err)
539+
} else {
540+
ns.nics[ninfo.Endpoint.Id] = nil
534541
}
535-
ns.nics[ninfo.Endpoint.Id] = nil
542+
}
543+
if len(errs) > 0 {
544+
return fmt.Errorf("remove nic from uVM %q: %w", uvm.ID(), errors.Join(errs...))
536545
}
537546

538547
// Remove the Guest Network namespace

internal/uvm/virtual_device.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ func (uvm *UtilityVM) RemoveDevice(ctx context.Context, deviceInstanceID string,
182182

183183
vpci := uvm.vpciDevices[key]
184184
if vpci == nil {
185-
entry.Error("failed to remove nonexistant vPCI device ")
185+
entry.Error("failed to remove nonexistent vPCI device ")
186186
return fmt.Errorf("no device with ID %s and index %d is present on the uvm %s", deviceInstanceID, index, uvm.ID())
187187
}
188188

scripts/Testing.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ function Invoke-TestCommand {
139139
Write-Verbose "Running output command: $oc"
140140
Invoke-Expression $oc
141141
} else {
142-
Write-Warning "Cannot run output command with non-existant output file: $oc"
142+
Write-Warning "Cannot run output command with non-existent output file: $oc"
143143
}
144144
}
145145
}

0 commit comments

Comments
 (0)