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

[WIP][don't merge] Dev:1st impl for integration test #275

Conversation

SamYuan1990
Copy link
Collaborator

Details for this PR
e2e folder with end to end testing, will run with two models, base on environment kepler_address.

  1. build kepler during test process and run it targets on local.
  2. run test case targets on cluster after cluster port forwarding.

Signed-off-by: Sam Yuan yy19902439@126.com

@SamYuan1990 SamYuan1990 changed the title Dev:1st impl for integration test [WIP] Dev:1st impl for integration test Oct 3, 2022
@SamYuan1990
Copy link
Collaborator Author

@marceloamaral , if I am correct, in integration test, we will deploy kepler with port 9102 right? could you please help with error https://github.com/sustainable-computing-io/kepler/actions/runs/3174554723/jobs/5171489975#step:8:28

cmd/exporter.go Outdated Show resolved Hide resolved
@SamYuan1990
Copy link
Collaborator Author

Sorry, for asking for help on this WIP pr.

cmd/exporter.go Show resolved Hide resolved
@@ -104,8 +104,12 @@ func (c *Collector) resetCurrValue() {

// resetBPFTables reset BPF module's tables
func (c *Collector) resetBPFTables() {
c.modules.Table.DeleteAll()
c.modules.TimeTable.DeleteAll()
if c.modules != nil && c.modules.Table != nil {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@rootfs , do you know where we init modules and tables?

Copy link
Contributor

Choose a reason for hiding this comment

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

the tables are auto filled; the delete functions remove existing table entries, the ebpf program will fill the tables again.

@@ -0,0 +1,94 @@
//go:build linux
// +build linux
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@rootfs ,those path are linux specific, so we have to split at here for different device/operator system?

Copy link
Contributor

Choose a reason for hiding this comment

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

@marceloamaral any idea? maybe a stub here too?

@@ -66,7 +62,7 @@ var (
)

func AttachBPFAssets() (*BpfModuleTables, error) {
return nil, fmt.Errorf("no bcc build tag")
return nil, nil
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@rootfs , here is the pre defined error for without bcc tag.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. This could make a case for a new bcc stub that emit mock data

@SamYuan1990 SamYuan1990 force-pushed the integrationTest1stImpl branch 2 times, most recently from 0e841c2 to 3fe3c52 Compare October 4, 2022 07:27
@SamYuan1990
Copy link
Collaborator Author

SamYuan1990 commented Oct 4, 2022

@rootfs , @marceloamaral , it seems we got error at https://github.com/sustainable-computing-io/kepler/actions/runs/3180212481/jobs/5183521776#step:7:17 could you please advise?

the network port forwards for pod failed

@SamYuan1990
Copy link
Collaborator Author

@rootfs
Copy link
Contributor

rootfs commented Oct 5, 2022

topic may related https://github.com/kubernetes-sigs/kind/search?q=failed+to+execute+portforward+in+network+namespace+%22host%22&type=issues

Could ClusterIP: None be causing trouble?

@SamYuan1990
Copy link
Collaborator Author

topic may related https://github.com/kubernetes-sigs/kind/search?q=failed+to+execute+portforward+in+network+namespace+%22host%22&type=issues

Could ClusterIP: None be causing trouble?

I give a try by a new commit, but seems not the root cause.
from the log, I suppose there some error happened during ip v4 ip v6 transform.

@SamYuan1990
Copy link
Collaborator Author

@rootfs , I am now try to force KIND use IPv4 to avoid:
https://kind.sigs.k8s.io/docs/user/known-issues/#ipv6-port-forwarding

Signed-off-by: Sam Yuan <yy19902439@126.com>
Signed-off-by: Sam Yuan <yy19902439@126.com>
Signed-off-by: Sam Yuan <yy19902439@126.com>
Signed-off-by: Sam Yuan <yy19902439@126.com>
Signed-off-by: Sam Yuan <yy19902439@126.com>
Signed-off-by: Sam Yuan <yy19902439@126.com>
Signed-off-by: Sam Yuan <yy19902439@126.com>
Signed-off-by: Sam Yuan <yy19902439@126.com>
Signed-off-by: Sam Yuan <yy19902439@126.com>
Signed-off-by: Sam Yuan <yy19902439@126.com>
@rootfs
Copy link
Contributor

rootfs commented Oct 6, 2022

@BenTheElder Thank you Ben for the help! The application should be running and listening to the port (in this Service).

@BenTheElder
Copy link

port-forward forwards to pods (not services), it will attempt to open a connection from within the pod's namespace, the tunnel looks roughly like:

kubectl <=> API server <=> kubelet <=> CRI <=> socket opened within target pod. IIRC kubernetes will always do this on localhost. The specific implementation in this case will be containerd's.

My KIND co-maintainer aojea previously patched this, because it used to literally use socat and supported IPv4 only. The current implementation has "happy eyeballs" IPv4+IPv6 (because Go) IIRC.

I'm noticing that the pod seems to be configured in hostNetwork and looks like the process should be bound to 0.0.0.0 ...

I'm not sure if we / Kubernetes have tests for hostNetwork port forward, it's possible that's broken in KIND (or containerd), otherwise unless the app isn't listening yet or the wrong pod is selected, I'm at a loss ...

@rootfs
Copy link
Contributor

rootfs commented Oct 6, 2022

Good info @BenTheElder! So based on your feedback, a more appropriate CI deployment is to use pod network. @SamYuan1990 can you give that a try? Thanks!

@SamYuan1990
Copy link
Collaborator Author

SamYuan1990 commented Oct 7, 2022

well, I also found some thing on github runner.
if I am right, github agent doesn't support ipv6 for now.
actions/runner-images#668

also kubernetes/kubectl#1169 from Jan reported at kubectl

as a short summary, we even make the case more complex as we use docker and ref to kubernetes-sigs/kind#2953 (comment)

Kubernetes within kind is using containerd.

ref:
截屏2022-10-07 09 54 27

and I suppose we need to make our life easier, by reduce components on this long tunnel.
By put test application into a pod, and use k8s network. As everything happens in side kind/k8s, we don't need to worry about the long tunnel across different application and owners.
截屏2022-10-07 10 00 13

@BenTheElder
Copy link

BenTheElder commented Oct 7, 2022

Instead of kubectl port forward, you could try configuring a port forward in kind and use a matching nodePort, similar to https://kind.sigs.k8s.io/docs/user/ingress/

kubectl port forward is more of a debugging tool and is not the most robust, though i'd still expect it to work here 🤔 , but as a general rule I wouldn't use it for anything load bearing with any cluster, even if you use the API directly.

Something like:

kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- extraPortMappings:
  - containerPort: 30001
    hostPort: 30001
    protocol: TCP

Or actually since the pod appears(?) to be in hostNetwork and you have a single node:

kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- extraPortMappings:
  - containerPort: 9102
    hostPort: 9102

I.E. adds -p 127.0.0.1:9102:9102/TCP to running the kind node.

if I am right, github agent doesn't support ipv6 for now.
actions/runner-images#668

We run some of our CI in GitHub actions and lack of IPv6 is not an issue, the ipv6 port forward connect is a red-herring, it's portforward is trying both ipv4 and ipv6 and both are failing. You can use kind / kubernetes without ipv6, if anything optional ipv6 in KIND involved a lot of fixing tests and Kubernetes, and then again in conjunction with the folks working on dualstack.

Signed-off-by: Sam Yuan <yy19902439@126.com>
@SamYuan1990
Copy link
Collaborator Author

Instead of kubectl port forward, you could try configuring a port forward in kind and use a matching nodePort, similar to https://kind.sigs.k8s.io/docs/user/ingress/

kubectl port forward is more of a debugging tool and is not the most robust, though i'd still expect it to work here 🤔 , but as a general rule I wouldn't use it for anything load bearing with any cluster, even if you use the API directly.

Something like:

kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- extraPortMappings:
  - containerPort: 30001
    hostPort: 30001
    protocol: TCP

Or actually since the pod appears(?) to be in hostNetwork and you have a single node:

kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- extraPortMappings:
  - containerPort: 9102
    hostPort: 9102

I.E. adds -p 127.0.0.1:9102:9102/TCP to running the kind node.

if I am right, github agent doesn't support ipv6 for now.
actions/runner-images#668

We run some of our CI in GitHub actions and lack of IPv6 is not an issue, the ipv6 port forward connect is a red-herring, it's portforward is trying both ipv4 and ipv6 and both are failing. You can use kind / kubernetes without ipv6, if anything optional ipv6 in KIND involved a lot of fixing tests and Kubernetes, and then again in conjunction with the folks working on dualstack.

let me try

Signed-off-by: Sam Yuan <yy19902439@126.com>
Signed-off-by: Sam Yuan <yy19902439@126.com>
Signed-off-by: Sam Yuan <yy19902439@126.com>
@SamYuan1990
Copy link
Collaborator Author

Signed-off-by: Sam Yuan <yy19902439@126.com>
Signed-off-by: Sam Yuan <yy19902439@126.com>
Signed-off-by: Sam Yuan <yy19902439@126.com>
Signed-off-by: Sam Yuan <yy19902439@126.com>
Signed-off-by: Sam Yuan <yy19902439@126.com>
Signed-off-by: Sam Yuan <yy19902439@126.com>
Signed-off-by: Sam Yuan <yy19902439@126.com>
Signed-off-by: Sam Yuan <yy19902439@126.com>
@SamYuan1990
Copy link
Collaborator Author

some updates:

  • tried with https://kind.sigs.k8s.io/docs/user/configuration/#extra-port-mappings but, The Service "kepler-exporter" is invalid: spec.ports[0].nodePort: Forbidden: may not be used when type is 'ClusterIP' should we use ClusterIP together with extra-port-mappings?
  • fixed one panic error, but why pod in panic passed kubectl rollout status daemonset kepler-exporter -n kepler --timeout 180s ? question here as the panic will make the service down, which breaks livenessProbe.
  • once panic been fixed, the port forward works. @_@

@BenTheElder
Copy link

The Service "kepler-exporter" is invalid: spec.ports[0].nodePort: Forbidden: may not be used when type is 'ClusterIP' should we use ClusterIP together with extra-port-mappings?

nodePort can only be set on a service of type NodePort. shouldn't be related to the node level port mappings.

I think you can skip the service though and just map 9102 from the host to the kind node since the pod appears to be in hostNetwork.

@marceloamaral
Copy link
Collaborator

I've been using port-forward with no problem on a kind cluster.
So probably the problem here was just related to the panic error.

The command kubectl rollout status daemonset kepler-exporter -n kepler --timeout 180s verifies if the container has been started, but will not check if the container failed shortly after starting....

Maybe we should sleep and then check for failed containers....

@rootfs
Copy link
Contributor

rootfs commented Oct 7, 2022

@SamYuan1990 now just a couple of lint error, ready to merge

@SamYuan1990
Copy link
Collaborator Author

@SamYuan1990 now just a couple of lint error, ready to merge

no no no.... I am going to bed... and don't merge it for now. please take a look at #283 1st.

@SamYuan1990 SamYuan1990 changed the title [WIP] Dev:1st impl for integration test [WIP][don't merge] Dev:1st impl for integration test Oct 7, 2022
@SamYuan1990
Copy link
Collaborator Author

close and move to #292 without issue. thanks guys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants