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

Port and AllocatedPortMapping msgpack omitempty #23980

Merged
merged 1 commit into from
Sep 17, 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
2 changes: 1 addition & 1 deletion nomad/plan_normalization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,5 @@ func TestPlanNormalize(t *testing.T) {

optimizedLogSize := buf.Len()
ratio := float64(optimizedLogSize) / float64(unoptimizedLogSize)
must.Less(t, 0.66, ratio)
must.Less(t, 0.6, ratio)
}
4 changes: 2 additions & 2 deletions nomad/structs/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -2809,10 +2809,10 @@ func portDiffs(old, new []Port, dynamic bool, contextual bool) []*ObjectDiff {
oldPorts := makeSet(old)
newPorts := makeSet(new)

var filter []string
filter := []string{"_struct"}
name := "Static Port"
if dynamic {
filter = []string{"Value"}
filter = []string{"_struct", "Value"}
name = "Dynamic Port"
}

Expand Down
46 changes: 8 additions & 38 deletions nomad/structs/diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6843,9 +6843,7 @@ func TestTaskDiff(t *testing.T) {
"a": 1,
"b": 2,
},
"boom": &Port{
Label: "boom_port",
},
"boom": []string{"boom_port"},
Copy link
Member Author

@gulducat gulducat Sep 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these diff tests are for task.config, which doesn't actually know what a Port is. for the docker driver, for example, ports is a list of strings (which arguably is already tested with bam above here), or a MapStrInt port_map (baz).

maybe Port here made sense at some point in the past, but doesn't seem right to me now.

},
},
New: &Task{
Expand All @@ -6857,9 +6855,7 @@ func TestTaskDiff(t *testing.T) {
"a": 1,
"b": 2,
},
"boom": &Port{
Label: "boom_port",
},
"boom": []string{"boom_port"},
},
},
Expected: &TaskDiff{
Expand All @@ -6877,9 +6873,7 @@ func TestTaskDiff(t *testing.T) {
"a": 1,
"b": 2,
},
"boom": &Port{
Label: "boom_port",
},
"boom": []string{"boom_port"},
},
},
New: &Task{
Expand All @@ -6891,9 +6885,7 @@ func TestTaskDiff(t *testing.T) {
"b": 3,
"c": 4,
},
"boom": &Port{
Label: "boom_port2",
},
"boom": []string{"boom_port2"},
},
},
Expected: &TaskDiff{
Expand Down Expand Up @@ -6935,7 +6927,7 @@ func TestTaskDiff(t *testing.T) {
},
{
Type: DiffTypeEdited,
Name: "boom.Label",
Name: "boom[0]",
Old: "boom_port",
New: "boom_port2",
},
Expand All @@ -6962,9 +6954,7 @@ func TestTaskDiff(t *testing.T) {
"a": 1,
"b": 2,
},
"boom": &Port{
Label: "boom_port",
},
"boom": []string{"boom_port"},
},
},
New: &Task{
Expand All @@ -6976,9 +6966,7 @@ func TestTaskDiff(t *testing.T) {
"a": 1,
"b": 2,
},
"boom": &Port{
Label: "boom_port",
},
"boom": []string{"boom_port"},
},
},
Expected: &TaskDiff{
Expand Down Expand Up @@ -7026,28 +7014,10 @@ func TestTaskDiff(t *testing.T) {
},
{
Type: DiffTypeNone,
Name: "boom.HostNetwork",
Old: "",
New: "",
},
{
Type: DiffTypeNone,
Name: "boom.Label",
Name: "boom[0]",
Old: "boom_port",
New: "boom_port",
},
{
Type: DiffTypeNone,
Name: "boom.To",
Old: "0",
New: "0",
},
{
Type: DiffTypeNone,
Name: "boom.Value",
Old: "0",
New: "0",
},
{
Type: DiffTypeEdited,
Name: "foo",
Expand Down
8 changes: 4 additions & 4 deletions nomad/structs/funcs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func TestAllocsFit(t *testing.T) {
{
Mode: "host",
IP: "10.0.0.1",
ReservedPorts: []Port{{"main", 8000, 0, ""}},
ReservedPorts: []Port{{Label: "main", Value: 8000}},
},
},
Ports: AllocatedPorts{
Expand Down Expand Up @@ -268,7 +268,7 @@ func TestAllocsFit_TerminalAlloc(t *testing.T) {
Device: "eth0",
IP: "10.0.0.1",
MBits: 50,
ReservedPorts: []Port{{"main", 8000, 80, ""}},
ReservedPorts: []Port{{Label: "main", Value: 8000, To: 80}},
},
},
},
Expand Down Expand Up @@ -322,7 +322,7 @@ func TestAllocsFit_ClientTerminalAlloc(t *testing.T) {
Device: "eth0",
IP: "10.0.0.1",
MBits: 50,
ReservedPorts: []Port{{"main", 8000, 80, ""}},
ReservedPorts: []Port{{Label: "main", Value: 8000, To: 80}},
},
},
},
Expand Down Expand Up @@ -373,7 +373,7 @@ func TestAllocsFit_ServerTerminalAlloc(t *testing.T) {
Device: "eth0",
IP: "10.0.0.1",
MBits: 50,
ReservedPorts: []Port{{"main", 8000, 80, ""}},
ReservedPorts: []Port{{Label: "main", Value: 8000, To: 80}},
},
},
},
Expand Down
Loading