Skip to content

Commit

Permalink
Merge branch 'main' into users/jocarde/housekeeping
Browse files Browse the repository at this point in the history
  • Loading branch information
jocardeMSFT authored Nov 18, 2024
2 parents 8ca4b91 + 6b4846e commit d19911c
Show file tree
Hide file tree
Showing 10 changed files with 530 additions and 422 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ require (
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/net v0.31.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/text v0.20.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28 // indirect
google.golang.org/protobuf v1.35.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo=
golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand Down
2 changes: 1 addition & 1 deletion pkg/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func getSingleMocErrorCode(err error) moccodes.MocCode {

// Get the cause of the error
cerr := perrors.Cause(err)
if cerr == nil || cerr == err {
if cerr == nil {
return moccodes.Unknown
}

Expand Down
46 changes: 46 additions & 0 deletions pkg/errors/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ import (
"github.com/microsoft/moc/rpc/common"
)

type NotComparableError struct {
msg string
data []byte // Slices make structs not comparable
}

func (e NotComparableError) Error() string {
return e.msg
}

func TestNewMocErrorWithError(t *testing.T) {
tests := []struct {
name string
Expand Down Expand Up @@ -159,6 +168,43 @@ func TestGetMocErrorCode(t *testing.T) {
}
}

func TestGetSingleMocErrorCodeAvoidsPanicOnUncomparable(t *testing.T) {
defer func() {
if r := recover(); r != nil {
t.Errorf("unexpected panic occurred: %v", r)
}
}()

// Create a NotComparableError
detailedErr := NotComparableError{
msg: "detailed error",
}

// Call getSingleMocErrorCode with the NotComparableError
code := getSingleMocErrorCode(detailedErr)

// Check the result
if code != moccodes.Unknown {
t.Errorf("expected %v, got %v", moccodes.Unknown, code)
}
}

func TestCheckErrorAvoidsPanicOnUncomparable(t *testing.T) {
defer func() {
if r := recover(); r != nil {
t.Errorf("unexpected panic occurred: %v", r)
}
}()

// Create a NotComparableError
detailedErr := NotComparableError{
msg: "detailed error",
}

// Make sure checkError doesn't panic
checkError(detailedErr, NotFound)
}

func TestCheckError(t *testing.T) {
tests := []struct {
name string
Expand Down
241 changes: 125 additions & 116 deletions rpc/cloudagent/compute/moc_cloudagent_virtualmachine.pb.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ message VirtualMachine {
AvailabilitySetReference availabilitySet = 19;
ZoneConfiguration zoneConfiguration = 20;
PlacementGroupReference placementGroup = 21;
Priority priority = 22;
}

message VirtualMachineOperationRequest {
Expand Down
405 changes: 220 additions & 185 deletions rpc/common/moc_common_common.pb.go

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions rpc/common/moc_common_common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ enum HealthState {
NOTREADY = 7;
}

enum Priority {
DEFAULT = 0;
LOW = 1;
MEDIUM = 2;
HIGH = 3;
}

message Error {
string Message = 1;
uint32 Code = 2;
Expand Down
241 changes: 125 additions & 116 deletions rpc/nodeagent/compute/moc_nodeagent_virtualmachine.pb.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ message VirtualMachine {
GuestAgentConfiguration guestAgent = 15;
VirtualMachineAgentInstanceView guestAgentInstanceView = 16;
ZoneConfiguration zoneConfiguration = 17;
Priority priority = 18;
}

message VirtualMachineOperationRequest {
Expand Down

0 comments on commit d19911c

Please sign in to comment.