-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Add namespace in function name for metrics #1488
Conversation
e.services = services | ||
} else { | ||
for _, namespace := range namespaces { | ||
services, err := e.getFunctions(endpointURL, namespace) |
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.
I think this works well for now, but I also suspect a larger discussion is needed about how/if we move this into the provider sending a request per namespace every second seems like something the provider should encapsulate so that it can optimize that behavior as it best makes sense for itself.
This current implementation would create a "thundering herd"-like problem with no way to really streamline or optimize it. For example, the k8s provider should be able to request the existing functions from several/all namespaces in a single request.
Perhaps we need a new endpoint in the provider that allows the gateway to send 0, 1, or more namespaces as part of the request. When it is 0, it would request for all namespaces, otherwise the response would send back a list of functions for the provided namespaces. Alternatively, we could allow a special _all
value. Then 0 namespaces == default, 1 or more applied as obvious, _all
return functions from all possible namespaces.
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.
I completely agree and we should move function aggregation logic to the provider.
I think we can modify the exiting function list endpoint using some special query parameters like _all
, for which will combine functions from all namespaces and return it. Otherwise it works as it is working now. I think it will be a very minimal change compared to having a new endpoint. For new endpoint we will have to write different logic depending on the provider at several places.
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.
Introducing a thundering herd issue concerns me. What are the alternatives to doing that?
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.
Thundering herd issue is because every 5 second (configurable) it tries to get all namespaces and then for each namespace it lists its functions to count service/replica count of functions.
Solution is to use a new endpoint or existing which list all functions across all namespaces so that we don't have to make these multiple calls. This implementation can be done in faas-netes which will be efficient.
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.
@viveksyngh can you write a bash loop to deploy 100-200 functions and then measure the effect of the patch?
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.
for j in {1..10} do ;
kubectl create namespace $i #annotate it
for i in {1..10} do ;
faas-cli deploy --image figlet --name fn$I --namespace $j
done
done
Perhaps create 10-20 in 10 different namespaces
@@ -72,9 +82,45 @@ func (e *Exporter) StartServiceWatcher(endpointURL url.URL, metricsOptions Metri | |||
ticker := time.NewTicker(interval) | |||
quit := make(chan struct{}) | |||
|
|||
timeout := 3 * time.Second | |||
go func() { | |||
for { |
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.
What is this new segment of code for? I was mainly expecting this PR to set a default suffix in the invocation URL when there was not one given.
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.
New segment of code is for getting replica count of the services, which was not having support for multiple namespace. It was only getting replica count for the functions present in default namespace.
This was reviewed several weeks ago in a members call with @viveksyngh and @LucasRoesler - we had a concern about performance and paused the patch. We need to review the solution and see if there are alternatives with other trade-offs (this still may be the best option) |
Testing :
Before ChangesAfter ChangesEdit the Gateway deployment to use docker image
|
return services, nil | ||
} | ||
|
||
func (e *Exporter) getNamespaces(endpointURL url.URL) ([]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.
Can we use the CLI's code for this?
for { | ||
select { | ||
case <-ticker.C: | ||
func (e *Exporter) getFunctions(endpointURL url.URL, namespace string) ([]types.FunctionStatus, 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.
Can you use the CLI here instead?
@viveksyngh we will need a rebase on this. After some discussion with @LucasRoesler, we thought this PR should be merged and then load-tested later. |
This commit adds namespace in function names while logging metrics to prometheus, irrespective of the function is invoked with namespace suffix or not. This is also required to add multiple namespace support to faas-idler https://github.com/openfaas-incubator/faas-idler/issues/37 which is part of openfaas/faas-netes#511 Signed-off-by: Vivek Singh <[email protected]>
Signed-off-by: Vivek Singh <[email protected]>
Signed-off-by: Vivek Singh <[email protected]>
f0e633a
to
3118134
Compare
@LucasRoesler could you give this a final pass? |
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.
@alexellis I think we are ready. Let's follow up in a future PR to consolidate those places we can/should use the cli
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.
Approved
This commit adds namespace in function names while logging metrics to
prometheus, irrespective of the function is invoked with namespace suffix
or not.
This is also required to add multiple namespace support to faas-idler
https://github.com/openfaas-incubator/faas-idler/issues/37 which is part
of openfaas/faas-netes#511
Signed-off-by: Vivek Singh [email protected]
Description
Motivation and Context
design/approved
labelHow Has This Been Tested?
Types of changes
Checklist:
git commit -s