Add metrics of gophercloud (POST,UPDATE and DELETE) actions#863
Add metrics of gophercloud (POST,UPDATE and DELETE) actions#863k8s-ci-robot merged 1 commit intokubernetes-sigs:masterfrom
Conversation
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jichenjc The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
974ab16 to
f306230
Compare
|
@seanschneeweiss @chrischdi Maybe one of you has some bandwitdh to review? :) |
|
I can't create a local env (because difference between 0.3.4 and master) @sbueringer @hidekazuna please help review , thanks |
chrischdi
left a comment
There was a problem hiding this comment.
ObserveRequest always returns the same error which we give to it. So when using it there should be a separate if err != nil part, instead we should use what we had before to not loose context :-)
I think there are lots of more places where we call gophercloud / the OpenStack API to observe metrics.
For example:
- https://github.com/kubernetes-sigs/cluster-api-provider-openstack/blob/master/pkg/cloud/services/compute/availabilityzone.go#L26
- https://github.com/kubernetes-sigs/cluster-api-provider-openstack/blob/master/pkg/cloud/services/compute/instance.go#L395
I think almost all occurencies can be found using, but ignore the highlighted Extract functions:
for l in $(grep . -r -e "github.com/gophercloud" | sed -E -e 's/:\t+/;/g' -e 's/"$//g' -e 's/;"/;/g' -e 's/ //g' | grep -v go.sum | grep -v go.mod | grep -v 'test/e2e'); do
FILE="$(cut -d ";" -f 1 <<< $l)"
PKG="$(cut -d ";" -f 2 <<< $l | cut -d '"' -f 1 | tr '/' ' ' | awk '{print $NF}')"
echo " # $FILE"
cat $FILE | grep -e "$PKG\.[A-Z][a-zA-Z]+\(" -E -A2 -B2
done
| func (r *OpenStackClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Result, reterr error) { | ||
| log := ctrl.LoggerFrom(ctx) | ||
|
|
||
| mc := metrics.NewMetricPrometheusContext("snapshot", "create") |
There was a problem hiding this comment.
I don't think we are doing a snapshot create here :-) also the r.Client.Get is no openstack request?!
There was a problem hiding this comment.
it's my debug code ... sorry to forget remove them
| if mc.ObserveRequest(err) != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| if err != nil { |
There was a problem hiding this comment.
| if mc.ObserveRequest(err) != nil { | |
| return nil, err | |
| } | |
| if err != nil { | |
| if mc.ObserveRequest(err) != nil { |
ObserveRequest just exposes a metric and does return the very same error.
| if mc.ObserveRequest(err) != nil { | ||
| return ports.Port{}, err | ||
| } | ||
| if err != nil { |
There was a problem hiding this comment.
| if mc.ObserveRequest(err) != nil { | |
| return ports.Port{}, err | |
| } | |
| if err != nil { | |
| if mc.ObserveRequest(err) != nil { |
| mc := metrics.NewMetricPrometheusContext("server", "create") | ||
|
|
There was a problem hiding this comment.
| mc := metrics.NewMetricPrometheusContext("server", "create") | |
| mc := metrics.NewMetricPrometheusContext("server", "create") |
| if mc.ObserveRequest(err) != nil { | ||
| return err | ||
| } | ||
| if err != nil { |
There was a problem hiding this comment.
| if mc.ObserveRequest(err) != nil { | |
| return err | |
| } | |
| if err != nil { | |
| if mc.ObserveRequest(err) != nil { |
| if mc.ObserveRequest(err) != nil { | ||
| return nil, err | ||
| } | ||
| if err != nil { |
There was a problem hiding this comment.
| if mc.ObserveRequest(err) != nil { | |
| return nil, err | |
| } | |
| if err != nil { | |
| if mc.ObserveRequest(err) != nil { |
| if mc.ObserveRequest(err) != nil { | ||
| return err | ||
| } | ||
| if err != nil { |
There was a problem hiding this comment.
| if mc.ObserveRequest(err) != nil { | |
| return err | |
| } | |
| if err != nil { | |
| if mc.ObserveRequest(err) != nil { |
| if mc.ObserveRequest(err) != nil { | ||
| return nil, err | ||
| } | ||
| if err != nil { |
There was a problem hiding this comment.
| if mc.ObserveRequest(err) != nil { | |
| return nil, err | |
| } | |
| if err != nil { | |
| if mc.ObserveRequest(err) != nil { |
| if mc.ObserveRequest(err) != nil { | ||
| return nil, err | ||
| } | ||
| if err != nil { |
There was a problem hiding this comment.
| if mc.ObserveRequest(err) != nil { | |
| return nil, err | |
| } | |
| if err != nil { | |
| if mc.ObserveRequest(err) != nil { |
|
|
||
| if mc.ObserveRequest(err) != nil { | ||
| return err | ||
| } | ||
| if err != nil { |
There was a problem hiding this comment.
| if mc.ObserveRequest(err) != nil { | |
| return err | |
| } | |
| if err != nil { | |
| if mc.ObserveRequest(err) != nil { |
There was a problem hiding this comment.
thanks for the comments, will check other possible metrics
d806f20 to
89836fe
Compare
|
/test pull-cluster-api-provider-openstack-e2e-test |
740f78d to
516b4e1
Compare
|
@chrischdi I checked again the question you posted above for additional metrics .. |
I think it would be helpful to also have a metric for the get / list requests. It is also done like this in https://github.com/kubernetes/cloud-provider-openstack . These requests could also fail and another use-case for me would be checking how many requests are done to OpenStack to not overload it. |
seanschneeweiss
left a comment
There was a problem hiding this comment.
Thank you for adding all the metrics :) I would also suggest to add metrics for the get/list and delete requests.
|
@chrischdi @seanschneeweiss thanks for the review most comments addressed |
661a547 to
74fec38
Compare
|
@jichenjc I'll take another look. Let's please merge this ASAP afterwards. With every refactoring PR we merge in the meantime we could introduce new bugs here. So it's a lot of effort to review it all over again to make sure we're safe :/ |
| SecGroupID: r.SecurityGroupID, | ||
| } | ||
| s.logger.V(6).Info("Creating rule", "Description", r.Description, "Direction", dir, "PortRangeMin", r.PortRangeMin, "PortRangeMax", r.PortRangeMax, "Proto", proto, "etherType", etherType, "RemoteGroupID", r.RemoteGroupID, "RemoteIPPrefix", r.RemoteIPPrefix, "SecurityGroupID", r.SecurityGroupID) | ||
| mc := metrics.NewMetricPrometheusContext("security_group_rules", "create") |
There was a problem hiding this comment.
| mc := metrics.NewMetricPrometheusContext("security_group_rules", "create") | |
| mc := metrics.NewMetricPrometheusContext("security_group_rule", "create") |
There was a problem hiding this comment.
searched and no other plural anymore ..
|
/lgtm |
|
/hold cancel |
|
/hold @jichenjc you have to squash locally + push -force before. Otherwise we will get 8 commits on master. |
my bad, another mistake ... not a lucky day for me |
|
Squashed :-) /lgtm |
|
@jichenjc No problem :). /lgtm |
|
/lgtm Thank you. |
|
/hold cancel |
What this PR does / why we need it:
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)format, will close the issue(s) when PR gets merged):Part of #856
Special notes for your reviewer:
TODOs:
/hold