Potential cyclic imports
What happened: Encounter some cyclic imports errors after rebasing a WIP PR to master. It means the code structure is lowly cohesive/ highly coupling, or the WIP PR needs refactoring imports.
Compared dependencies and found these newly added dependencies:
v2/pkg/app
├──v2/pkg/util
├──v2/internal/discovery
v2/pkg/customresourcestate
├──v2/pkg/util
├──v2/internal/discovery
v2/internal/store
├──v2/pkg/util
v2/pkg/util
└──v2/pkg/customresource
v2/internal/discovery
├──v2/pkg/metricshandler
├──v2/pkg/util
├──v2/internal/store
├──v2/pkg/customresource
└──v2/pkg/options
# before
godepgraph ./
v2/pkg/app
├──v2/pkg/metricshandler
├──v2/pkg/allowdenylist
├──v2/pkg/customresource
├──v2/pkg/customresourcestate
├──v2/pkg/options
├──v2/internal/store
├──v2/pkg/optin
├──v2/pkg/util/proc
└──v2/pkg/metric_generator
v2/pkg/customresourcestate
├──v2/pkg/metric_generator
├──v2/pkg/customresource
└──v2/pkg/metric
v2/pkg/optin
└──v2/pkg/metric_generator
v2/pkg/sharding
v2/pkg/util/proc
v2/pkg/allowdenylist
└──v2/pkg/metric_generator
v2/pkg/builder/types
├──v2/pkg/metrics_store
├──v2/pkg/customresource
├──v2/pkg/metric_generator
└──v2/pkg/options
v2/pkg/customresource
└──v2/pkg/metric_generator
v2/pkg/watch
v2/tests/e2e/framework
v2/tools
v2/internal
├──v2/pkg/app
└──v2/pkg/options
v2/internal/store
├──v2/pkg/watch
├──v2/pkg/customresource
├──v2/pkg/metric_generator
├──v2/pkg/options
├──v2/pkg/metrics_store
├──v2/pkg/metric
├──v2/pkg/sharding
├──v2/pkg/constant
└──v2/pkg/builder/types
v2/pkg/allow
v2/pkg/options
v2
├──v2/internal
└──v2/pkg/options
v2/pkg/builder
├──v2/internal/store
├──v2/pkg/builder/types
├──v2/pkg/customresource
├──v2/pkg/metric_generator
├──v2/pkg/metrics_store
└──v2/pkg/options
v2/pkg/metric
v2/pkg/metric_generator
└──v2/pkg/metric
v2/pkg/metrics_store/metricsstore
└──v2/pkg/metric
v2/pkg/metricshandler
├──v2/pkg/builder/types
├──v2/pkg/metrics_store
└──v2/pkg/options
# now
godepgraph ./
v2/pkg/app
├──v2/pkg/util
├──v2/internal/discovery
├──v2/pkg/optin
├──v2/pkg/customresourcestate
├──v2/pkg/metricshandler
├──v2/pkg/options
├──v2/pkg/allowdenylist
├──v2/internal/store
├──v2/pkg/metric_generator
├──v2/pkg/util/proc
└──v2/pkg/customresource
v2/pkg/customresourcestate
├──v2/pkg/util
├──v2/internal/discovery
└──v2/internal/store
├──v2/pkg/customresource
├──v2/pkg/metric
├──v2/pkg/metric_generator
v2/pkg/optin
└──v2/pkg/metric_generator
v2/pkg/sharding
v2/pkg/util/proc
v2/pkg/allowdenylist
└──v2/pkg/metric_generator
v2/pkg/builder/types
├──v2/pkg/options
├──v2/pkg/metrics_store
├──v2/pkg/customresource
└──v2/pkg/metric_generator
v2/pkg/customresource
└──v2/pkg/metric_generator
v2/pkg/watch
v2/tests/e2e/framework
v2/tools
v2/internal
├──v2/pkg/app
└──v2/pkg/options
v2/internal/store
├──v2/pkg/util
├──v2/pkg/sharding
├──v2/pkg/builder/types
├──v2/pkg/options
├──v2/pkg/metric
├──v2/pkg/metric_generator
├──v2/pkg/constant
├──v2/pkg/metrics_store
├──v2/pkg/watch
└──v2/pkg/customresource
v2/pkg/allow
v2/pkg/options
v2
├──v2/internal
└──v2/pkg/options
v2/pkg/builder
├──v2/internal/store
├──v2/pkg/builder/types
├──v2/pkg/metric_generator
├──v2/pkg/options
├──v2/pkg/customresource
└──v2/pkg/metrics_store
v2/pkg/metric
v2/pkg/metric_generator
└──v2/pkg/metric
v2/pkg/metrics_store/metricsstore
└──v2/pkg/metric
v2/pkg/metricshandler
├──v2/pkg/builder/types
├──v2/pkg/options
└──v2/pkg/metrics_store
v2/pkg/util
└──v2/pkg/customresource
v2/internal/discovery
├──v2/pkg/metricshandler
├──v2/pkg/util
├──v2/internal/store
├──v2/pkg/customresource
└──v2/pkg/options
What you expected to happen: Refactor some codes to make sure it's highly cohesive and lowly coupling.
How to reproduce it (as minimally and precisely as possible):
Anything else we need to know?:
Environment:
- kube-state-metrics version:
- Kubernetes version (use
kubectl version): - Cloud provider or hardware configuration:
- Other info:
/assign
-
discovery imports many packages, which is similar to app package. Will move this under app.
-
util are highly coupled with custom resource state feature. Will move this under customresource.
It's better to have less many imports in an independent package
/triage accepted
This issue has not been updated in over 1 year, and should be re-triaged.
You can:
- Confirm that this issue is still relevant with
/triage accepted(org members only) - Close this issue with
/close
For more details on the triage process, see https://www.kubernetes.dev/docs/guide/issue-triage/
/remove-triage accepted