-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[WIP] Improve workload creation in Felix FVs #11453
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -21,6 +21,7 @@ import ( | |||
| api "github.com/projectcalico/api/pkg/apis/projectcalico/v3" | ||||
|
|
||||
| "github.com/projectcalico/calico/felix/fv/utils" | ||||
| "github.com/projectcalico/calico/felix/fv/workload" | ||||
| libapi "github.com/projectcalico/calico/libcalico-go/lib/apis/v3" | ||||
| client "github.com/projectcalico/calico/libcalico-go/lib/clientv3" | ||||
| ) | ||||
|
|
@@ -68,6 +69,8 @@ type DatastoreInfra interface { | |||
| // which the tunnel is created). needBGP is used (only in etcd) to | ||||
| // add a NodeBGPSpec if true or otherwise not. | ||||
| AddNode(felix *Felix, v4CIDR *net.IPNet, v6CIDR *net.IPNet, idx int, needBGP bool) | ||||
|
|
||||
| CreateWorkload(felix *Felix, name, addr string, opts ...workload.Opt) *workload.Workload | ||||
|
||||
| CreateWorkload(felix *Felix, name, addr string, opts ...workload.Opt) *workload.Workload |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -101,24 +101,29 @@ var _ = infrastructure.DatastoreDescribe("connectivity tests and flow logs with | |||||||||||||
| infra.AddDefaultAllow() | ||||||||||||||
|
|
||||||||||||||
| // Create workload on host 1. | ||||||||||||||
| infrastructure.AssignIP("ep1-1", "10.65.0.0", tc.Felixes[0].Hostname, client) | ||||||||||||||
| ep1_1 = workload.Run(tc.Felixes[0], "ep1-1", "default", "10.65.0.0", wepPortStr, "tcp") | ||||||||||||||
| //infrastructure.AssignIP("ep1-1", "10.65.0.0", tc.Felixes[0].Hostname, client) | ||||||||||||||
| //ep1_1 = workload.Run(tc.Felixes[0], "ep1-1", "default", "10.65.0.0", wepPortStr, "tcp") | ||||||||||||||
| ep1_1 = infra.CreateWorkload(tc.Felixes[0], "ep1-1", "10.65.0.0") | ||||||||||||||
| ep1_1.ConfigureInInfra(infra) | ||||||||||||||
|
|
||||||||||||||
| infrastructure.AssignIP("ep2-1", "10.65.1.0", tc.Felixes[1].Hostname, client) | ||||||||||||||
| ep2_1 = workload.Run(tc.Felixes[1], "ep2-1", "default", "10.65.1.0", wepPortStr, "tcp") | ||||||||||||||
| //infrastructure.AssignIP("ep2-1", "10.65.1.0", tc.Felixes[1].Hostname, client) | ||||||||||||||
| //ep2_1 = workload.Run(tc.Felixes[1], "ep2-1", "default", "10.65.1.0", wepPortStr, "tcp") | ||||||||||||||
| ep2_1 = infra.CreateWorkload(tc.Felixes[1], "ep2-1", "10.65.1.0") | ||||||||||||||
| ep2_1.ConfigureInInfra(infra) | ||||||||||||||
|
|
||||||||||||||
| infrastructure.AssignIP("ep2-2", "10.65.1.1", tc.Felixes[1].Hostname, client) | ||||||||||||||
| ep2_2 = workload.Run(tc.Felixes[1], "ep2-2", "default", "10.65.1.1", wepPortStr, "tcp") | ||||||||||||||
| //infrastructure.AssignIP("ep2-2", "10.65.1.1", tc.Felixes[1].Hostname, client) | ||||||||||||||
| //ep2_2 = workload.Run(tc.Felixes[1], "ep2-2", "default", "10.65.1.1", wepPortStr, "tcp") | ||||||||||||||
| ep2_2 = infra.CreateWorkload(tc.Felixes[1], "ep2-2", "10.65.1.1") | ||||||||||||||
| ep2_2.ConfigureInInfra(infra) | ||||||||||||||
|
|
||||||||||||||
| infrastructure.AssignIP("ep2-3", "10.65.1.2", tc.Felixes[1].Hostname, client) | ||||||||||||||
| ep2_3 = workload.Run(tc.Felixes[1], "ep2-3", "default", "10.65.1.2", wepPortStr, "tcp") | ||||||||||||||
| //infrastructure.AssignIP("ep2-3", "10.65.1.2", tc.Felixes[1].Hostname, client) | ||||||||||||||
| //ep2_3 = workload.Run(tc.Felixes[1], "ep2-3", "default", "10.65.1.2", wepPortStr, "tcp") | ||||||||||||||
| ep2_3 = infra.CreateWorkload(tc.Felixes[1], "ep2-3", "10.65.1.2") | ||||||||||||||
| ep2_3.ConfigureInInfra(infra) | ||||||||||||||
|
|
||||||||||||||
| infrastructure.AssignIP("ep2-3", "10.65.1.3", tc.Felixes[1].Hostname, client) | ||||||||||||||
| ep2_4 = workload.Run(tc.Felixes[1], "ep2-4", "default", "10.65.1.3", wepPortStr, "tcp") | ||||||||||||||
| //infrastructure.AssignIP("ep2-3", "10.65.1.3", tc.Felixes[1].Hostname, client) | ||||||||||||||
| //ep2_4 = workload.Run(tc.Felixes[1], "ep2-4", "default", "10.65.1.3", wepPortStr, "tcp") | ||||||||||||||
|
Comment on lines
+104
to
+125
|
||||||||||||||
| ep2_4 = infra.CreateWorkload(tc.Felixes[1], "ep2-4", "10.65.1.4") | ||||||||||||||
|
Comment on lines
+124
to
+126
|
||||||||||||||
| //infrastructure.AssignIP("ep2-3", "10.65.1.3", tc.Felixes[1].Hostname, client) | |
| //ep2_4 = workload.Run(tc.Felixes[1], "ep2-4", "default", "10.65.1.3", wepPortStr, "tcp") | |
| ep2_4 = infra.CreateWorkload(tc.Felixes[1], "ep2-4", "10.65.1.4") | |
| //infrastructure.AssignIP("ep2-4", "10.65.1.3", tc.Felixes[1].Hostname, client) | |
| //ep2_4 = workload.Run(tc.Felixes[1], "ep2-4", "default", "10.65.1.3", wepPortStr, "tcp") | |
| ep2_4 = infra.CreateWorkload(tc.Felixes[1], "ep2-4", "10.65.1.3") |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -184,7 +184,19 @@ func WithHostNetworked() Opt { | |
| } | ||
| } | ||
|
|
||
| func New(c *infrastructure.Felix, name, profile, ip, ports, protocol string, opts ...Opt) *Workload { | ||
| func WithPort(ports string) Opt { | ||
| return func(w *Workload) { | ||
| w.Ports = ports | ||
| } | ||
| } | ||
|
Comment on lines
+187
to
+191
|
||
|
|
||
| func WithProtocol(proto string) Opt { | ||
| return func(w *Workload) { | ||
| w.Protocol = proto | ||
| } | ||
| } | ||
|
|
||
| func New(c *infrastructure.Felix, name, profile, ip string, opts ...Opt) *Workload { | ||
|
||
| workloadIdx++ | ||
| n := fmt.Sprintf("%s-idx%v", name, workloadIdx) | ||
| interfaceName := conversion.NewConverter().VethNameForWorkload(profile, n) | ||
|
|
@@ -218,8 +230,8 @@ func New(c *infrastructure.Felix, name, profile, ip, ports, protocol string, opt | |
| SpoofName: spoofN, | ||
| InterfaceName: interfaceName, | ||
| SpoofInterfaceName: spoofIfaceName, | ||
| Ports: ports, | ||
| Protocol: protocol, | ||
| Ports: "8055", | ||
| Protocol: "tcp", | ||
| WorkloadEndpoint: wep, | ||
| MTU: defaultMTU, | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
CreateWorkloadsPerHostsfunction is added but never used in this PR and is not part of theDatastoreInfrainterface. Consider removing it if it's not needed, or document its intended use case. If it's intended for future use, consider adding a comment explaining its purpose.