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

Fix crash on startup #312

Merged
merged 2 commits into from
Sep 22, 2022
Merged

Fix crash on startup #312

merged 2 commits into from
Sep 22, 2022

Conversation

jotak
Copy link
Member

@jotak jotak commented Sep 22, 2022

"failed to initialize pipeline opening "": open : no such file or directory"
Previous PR removed the default file names for service mapping

func (tn *TransformNetwork) GetServiceFiles() (string, string) {
p := tn.ProtocolsFile
if p == "" {
p = "/etc/protocols"
Copy link
Member Author

@jotak jotak Sep 22, 2022

Choose a reason for hiding this comment

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

by the way, I used the previous default, as you can see here: https://github.com/netobserv/flowlogs-pipeline/pull/304/files#diff-803cd3d555b315c0ffdf0ac4905fd947085c6edf178137e7734e7af8a1218214L55 it was previously using these paths.

But maybe this isn't super safe to write in /etc/protocols? maybe rather use /tmp/flp-protocols and /tmp/flp-services instead? @KalmanMeth @ronensc @mariomac ?

Copy link
Member Author

Choose a reason for hiding this comment

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

never mind, I thought it was a file that we would write into, I didn't know it was a standardized thingy

"failed to initialize pipeline opening "": open : no such file or directory"
Previous PR removed the default file names for service mapping
Copy link
Collaborator

@ronensc ronensc left a comment

Choose a reason for hiding this comment

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

Thanks for the fix!
It's weird that the e2e tests didn't catch it...

Comment on lines +196 to +201
return nil, fmt.Errorf("opening protocols file %q: %w", pFilename, err)
}
defer protos.Close()
services, err := os.Open(jsonNetworkTransform.ServicesFile)
services, err := os.Open(sFilename)
if err != nil {
return nil, fmt.Errorf("opening %q: %w", jsonNetworkTransform.ServicesFile, err)
return nil, fmt.Errorf("opening services file %q: %w", sFilename, err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

+1 for improving the error message

Copy link
Collaborator

Choose a reason for hiding this comment

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

I was able to find the error message in the e2e test of the PR that introduced the bug. But, despite that, the test passes.
https://github.com/netobserv/flowlogs-pipeline/actions/runs/3082582328/jobs/4982452400
image

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah seems like there's some improvement to bring to the e2e test too

require.NoError(t, err)
require.NotNil(t, cfg)
mainPipeline, err := pipeline.NewPipeline(&cfg)
require.NoError(t, err)

Choose a reason for hiding this comment

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

This test is failing here with:

can't access kubenetes. Tried using config from: config parameter, KUBECONFIG env, homedir and InClusterConfig. Got: unable to load in-cluster configuration, KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT must be defined

I wonder if using os.Setenv is enough...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Another option would be to remove the add_kubernetes rules from the test config.

Copy link

@mariomac mariomac Sep 22, 2022

Choose a reason for hiding this comment

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

yeah, Ronen's suggestion is much cleaner for a unit test

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm rather mocking the kube client loading

Copy link
Member Author

Choose a reason for hiding this comment

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

(else, kube client initialization would fail without a real kube cluster available)

@@ -47,7 +47,13 @@ const (
typeService = "Service"
)

type KubeDataInterface interface {

Choose a reason for hiding this comment

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

nitpick: this interface can be private.

Copy link
Member Author

Choose a reason for hiding this comment

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

done (I just had to move the mock into kubernetes package :) )

@jotak jotak merged commit 69c1d55 into netobserv:main Sep 22, 2022
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.

3 participants