-
Notifications
You must be signed in to change notification settings - Fork 339
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
kuma-dp: improve envoy binary lookup #268
Conversation
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.
Do you think it's beneficial to also look in pwd
? I feel unsure so ok with whatever you decide. We can also always add that later.
f530a84
to
223377f
Compare
- Search in configured path - Fallback to same directory as kuma-dp
223377f
to
91604a9
Compare
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.
Can we have a unit test for this feature ? Both positive and negative cases
@@ -38,6 +41,49 @@ type Envoy struct { | |||
opts Opts | |||
} | |||
|
|||
func getSelfPath() (string, error) { |
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.
getSelfDir()
seems to be a more accurate name
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 string returned by this function is the actual full path of the binary, so it's more accurate to call it "path".
} | ||
} | ||
|
||
return "", errors.New("could not find binary") |
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.
can we change the message to .Errorf("could not find Envoy binary at any of the following locations: %v", candidatePaths)
?
resolvedPath, err := lookupEnvoyPath(binaryPathConfig) | ||
if err != nil { | ||
runLog.Error(err, "Envoy binary not found; make sure it is in PATH or in the same directory as "+os.Args[0]) | ||
return nil |
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.
At the moment, if envoy
binary is not found, konvoy-dp
exists with status code 0
and prints nothing on the console.
You should return the error instead of logging it.
@@ -51,6 +97,13 @@ func (e *Envoy) Run(stop <-chan struct{}) error { | |||
ctx, cancel := context.WithCancel(context.Background()) | |||
defer cancel() | |||
|
|||
binaryPathConfig := e.opts.Config.DataplaneRuntime.BinaryPath | |||
resolvedPath, err := lookupEnvoyPath(binaryPathConfig) | |||
if err != nil { |
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.
Can we have a unit test for this ?
Summary
Fixes #249