kubernetes-sigs / apiserver-network-proxy

Apache License 2.0
371 stars 177 forks source link

[BUG] The backend ServerMetric is not correct #294

Open YRXING opened 2 years ago

YRXING commented 2 years ago

As the konnectivity server may has multiple BackendManagers, the backend metric should record the total backends stored in various of BackendManager even if we can record them with a label.

However, the backend metric is recorded by DefaultBackendStorage, which is the underlying storage implementation. It will result in only some BackendManager record its number of backends.

The solution is that backend metric should be recorded by konnectivity server instead of DefaultBackendStorage.

mainred commented 2 years ago

I don't think it's a bug. It's not only DefaultBackendManager that can record the backend but all backend managers inherit AddBackend from DefaultBackendStorage. Please reconsider this.

YRXING commented 2 years ago

Yes, every backend manager will inherit AddBackend method.

What I wonder is that the DefaultBackendStorage record backend metric through setting their own backends count while the backend metric is belong to proxy server. And the backend managers will overwrite each other's values.

For example, the proxy server has two backend managers. One has three backends and the other has five backends. Now the backend metric will only be one of these tow values while the actual value may be greater than three and smaller than five.

The related codes as following shows:

// SetBackendCount sets the number of backend connection.
func (a *ServerMetrics) SetBackendCount(count int) {
    a.backend.WithLabelValues().Set(float64(count))
}

func (s *DefaultBackendStorage) AddBackend(identifier string, idType pkgagent.IdentifierType, conn agent.AgentService_ConnectServer) Backend {
    // ...
    addedBackend := newBackend(conn)
    // ...
    metrics.Metrics.SetBackendCount(len(s.backends))
    // ...
    return addedBackend
}
mainred commented 2 years ago

Thanks for your explanation, let's go on with your fix. proxy server is designed to support multiple backend managers, though currently only one is used.

jkh52 commented 2 years ago

/cc @yan-lgtm /cc @cheftako

k8s-triage-robot commented 2 years ago

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot commented 2 years ago

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

k8s-triage-robot commented 2 years ago

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

k8s-ci-robot commented 2 years ago

@k8s-triage-robot: Closing this issue.

In response to [this](https://github.com/kubernetes-sigs/apiserver-network-proxy/issues/294#issuecomment-1118959098): >The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. > >This bot triages issues and PRs according to the following rules: >- After 90d of inactivity, `lifecycle/stale` is applied >- After 30d of inactivity since `lifecycle/stale` was applied, `lifecycle/rotten` is applied >- After 30d of inactivity since `lifecycle/rotten` was applied, the issue is closed > >You can: >- Reopen this issue or PR with `/reopen` >- Mark this issue or PR as fresh with `/remove-lifecycle rotten` >- Offer to help out with [Issue Triage][1] > >Please send feedback to sig-contributor-experience at [kubernetes/community](https://github.com/kubernetes/community). > >/close > >[1]: https://www.kubernetes.dev/docs/guide/issue-triage/ Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
jkh52 commented 5 months ago

/assign