Skip to content
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

chore(*) improve resource manager initialization readability #2316

Merged
merged 2 commits into from
Jul 12, 2021
Merged

chore(*) improve resource manager initialization readability #2316

merged 2 commits into from
Jul 12, 2021

Conversation

jpeach
Copy link
Contributor

@jpeach jpeach commented Jul 6, 2021

Summary

This refactoring is a bit gratuitous, so I'm not that concerned if we don't want to merge it :-)

I was reading the resource manager setup and it was confusing how the type map was still being initialized after already being "consumed" by customizable resource manager.

Full changelog

N/A

Issues resolved

N/A

Documentation

N/A

Testing

  • Unit tests
  • E2E tests
  • Manual testing on Universal
  • Manual testing on Kubernetes

Signed-off-by: James Peach <james.peach@konghq.com>
@jpeach jpeach requested a review from a team as a code owner July 6, 2021 08:58
Copy link
Contributor

@lobkovilya lobkovilya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense and for sure improves readability, so I'm not against merging this one

@@ -28,6 +32,9 @@ type customizableResourceManager struct {
}

func (m *customizableResourceManager) Customize(resourceType model.ResourceType, manager ResourceManager) {
if _, ok := m.customManagers[resourceType]; ok {
panic(fmt.Sprintf("resource type %q is already customized", resourceType))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd better panicked with error rather than string

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There needs to be a possibility to override existing resource managers. So

  1. Remove the check
  2. Add CustomizeOpts and Override()
  3. Add different method called Override(resourceType model.ResourceType, manager ResourceManager)

I'm fine with whatever is picked.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did (1)

@codecov-commenter
Copy link

codecov-commenter commented Jul 6, 2021

Codecov Report

Merging #2316 (2d0aeaa) into master (d6d37cc) will increase coverage by 0.36%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2316      +/-   ##
==========================================
+ Coverage   50.78%   51.14%   +0.36%     
==========================================
  Files         870      874       +4     
  Lines       40541    40589      +48     
==========================================
+ Hits        20587    20759     +172     
+ Misses      17959    17806     -153     
- Partials     1995     2024      +29     
Impacted Files Coverage Δ
pkg/core/bootstrap/bootstrap.go 59.54% <100.00%> (+2.54%) ⬆️
pkg/core/resources/manager/customizable_manager.go 93.33% <100.00%> (+8.71%) ⬆️
pkg/xds/cache/once/cache.go 86.11% <0.00%> (-8.34%) ⬇️
api/internal/util/proto/proto.go 62.50% <0.00%> (ø)
...k8s/native/controllers/proxytemplate_controller.go 0.00% <0.00%> (ø)
api/internal/util/proto/types.go 100.00% <0.00%> (ø)
...kg/plugins/resources/k8s/native/pkg/test/within.go 100.00% <0.00%> (ø)
api/observability/v1/mads.pb.go 35.94% <0.00%> (+1.30%) ⬆️
api/mesh/v1alpha1/dataplane_helpers.go 77.84% <0.00%> (+1.70%) ⬆️
pkg/plugins/runtime/universal/outbound/outbound.go 64.28% <0.00%> (+1.78%) ⬆️
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d6d37cc...2d0aeaa. Read the comment docs.

Copy link
Contributor

@jakubdyszkiewicz jakubdyszkiewicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, I introduced Customize method, I should have refactored the rest.

👍

@@ -28,6 +32,9 @@ type customizableResourceManager struct {
}

func (m *customizableResourceManager) Customize(resourceType model.ResourceType, manager ResourceManager) {
if _, ok := m.customManagers[resourceType]; ok {
panic(fmt.Sprintf("resource type %q is already customized", resourceType))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There needs to be a possibility to override existing resource managers. So

  1. Remove the check
  2. Add CustomizeOpts and Override()
  3. Add different method called Override(resourceType model.ResourceType, manager ResourceManager)

I'm fine with whatever is picked.

Signed-off-by: James Peach <james.peach@konghq.com>
@jpeach jpeach merged commit 544cd03 into kumahq:master Jul 12, 2021
@jpeach jpeach deleted the chore/resmgr-readability branch July 12, 2021 01:19
mergify bot pushed a commit that referenced this pull request Jul 12, 2021
Signed-off-by: James Peach <james.peach@konghq.com>
(cherry picked from commit 544cd03)
lobkovilya pushed a commit that referenced this pull request Jul 12, 2021
…2348)

Signed-off-by: James Peach <james.peach@konghq.com>
(cherry picked from commit 544cd03)

Co-authored-by: James Peach <james.peach@konghq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants