-
Notifications
You must be signed in to change notification settings - Fork 890
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
Resource Interpreter implements the interfaces #2794
Resource Interpreter implements the interfaces #2794
Conversation
32d3d35
to
a35b06b
Compare
Codecov Report
@@ Coverage Diff @@
## master #2794 +/- ##
==========================================
+ Coverage 33.47% 37.49% +4.02%
==========================================
Files 200 189 -11
Lines 19642 17573 -2069
==========================================
+ Hits 6575 6589 +14
+ Misses 12673 10593 -2080
+ Partials 394 391 -3
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
/retest |
@jameszhangyukun: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Thanks~ Let me take a look |
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.
Generally looks good to me.
@jameszhangyukun I guess you have tested it on your side, please post the test here, so that other people can try it locally.
@jameszhangyukun Please rebase your code with the latest code in master, I see the E2E test is falling and I'm not sure if it is due to the latest E2E changes. |
This approach is more straightforward than #2733, I also need to check on the progress of #2733. And I tend to have a quick version for this feature just like I commented on #2733 (comment). |
pkg/resourceinterpreter/configurableinterpreter/configurable.go
Outdated
Show resolved
Hide resolved
a35b06b
to
1da991e
Compare
1da991e
to
891cac1
Compare
pkg/resourceinterpreter/configurableinterpreter/configurable.go
Outdated
Show resolved
Hide resolved
pkg/resourceinterpreter/configurableinterpreter/configurable.go
Outdated
Show resolved
Hide resolved
pkg/resourceinterpreter/configurableinterpreter/configurable.go
Outdated
Show resolved
Hide resolved
pkg/resourceinterpreter/configurableinterpreter/configurable.go
Outdated
Show resolved
Hide resolved
pkg/resourceinterpreter/configurableinterpreter/configurable.go
Outdated
Show resolved
Hide resolved
pkg/resourceinterpreter/configurableinterpreter/configurable.go
Outdated
Show resolved
Hide resolved
891cac1
to
ef55f96
Compare
LGTM |
95b5e94
to
1fb583b
Compare
pkg/resourceinterpreter/configurableinterpreter/configmanager/manager.go
Show resolved
Hide resolved
@@ -45,8 +45,7 @@ func (configManager *interpreterConfigManager) HasSynced() bool { | |||
if configManager.initialSynced.Load().(bool) { | |||
return true | |||
} | |||
|
|||
if configManager.HasSynced() { | |||
if configuration, err := configManager.lister.List(labels.Everything()); err == nil && len(configuration) == 0 { |
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.
len(configuration) == 0
means synced?
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.
Maybe shall use informer.IsInformerSynced()
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.
The relevant comments can be described here.
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.
len(configuration) == 0
means synced?
karmada/pkg/resourceinterpreter/customizedinterpreter/configmanager/manager.go
Lines 50 to 58 in d3b19ed
if configuration, err := m.lister.List(labels.Everything()); err == nil && len(configuration) == 0 { // the empty list we initially stored is valid to use. // Setting initialSynced to true, so subsequent checks // would be able to take the fast path on the atomic boolean in a // cluster without any webhooks configured. m.initialSynced.Store(true) // the informer has synced, and we don't have any items return true }
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.
But if informer is not synced, the lister.Lister
also returns []
items and nil
error. I test it as below:
func TestName2(t *testing.T) {
// no server servers on this address
config, _ := clientcmd.BuildConfigFromFlags("http://127.0.0.1", "")
clientSet := kubernetes.NewForConfigOrDie(config)
factory := informers.NewSharedInformerFactory(clientSet, 0)
lister := factory.Core().V1().Nodes().Lister()
stopCh := make(chan struct{})
defer close(stopCh)
factory.Start(stopCh)
go factory.WaitForCacheSync(stopCh)
ticker := time.NewTicker(time.Second)
for range ticker.C {
nodes, err := lister.List(labels.Everything())
t.Log(nodes, err)
}
}
And output:
W1116 11:07:20.838592 95036 reflector.go:324] pkg/mod/k8s.io/client-go@v0.23.5/tools/cache/reflector.go:167: failed to list *v1.Node: Get "http://127.0.0.1/api/v1/nodes?limit=500&resourceVersion=0": dial tcp 127.0.0.1:80: connect: connection refused
E1116 11:07:20.838731 95036 reflector.go:138] pkg/mod/k8s.io/client-go@v0.23.5/tools/cache/reflector.go:167: Failed to watch *v1.Node: failed to list *v1.Node: Get "http://127.0.0.1/api/v1/nodes?limit=500&resourceVersion=0": dial tcp 127.0.0.1:80: connect: connection refused
cli_test.go:62: [] <nil>
W1116 11:07:22.127046 95036 reflector.go:324] pkg/mod/k8s.io/client-go@v0.23.5/tools/cache/reflector.go:167: failed to list *v1.Node: Get "http://127.0.0.1/api/v1/nodes?limit=500&resourceVersion=0": dial tcp 127.0.0.1:80: connect: connection refused
E1116 11:07:22.127648 95036 reflector.go:138] pkg/mod/k8s.io/client-go@v0.23.5/tools/cache/reflector.go:167: Failed to watch *v1.Node: failed to list *v1.Node: Get "http://127.0.0.1/api/v1/nodes?limit=500&resourceVersion=0": dial tcp 127.0.0.1:80: connect: connection refused
cli_test.go:62: [] <nil>
cli_test.go:62: [] <nil>
cli_test.go:62: [] <nil>
W1116 11:07:25.236868 95036 reflector.go:324] pkg/mod/k8s.io/client-go@v0.23.5/tools/cache/reflector.go:167: failed to list *v1.Node: Get "http://127.0.0.1/api/v1/nodes?limit=500&resourceVersion=0": dial tcp 127.0.0.1:80: connect: connection refused
E1116 11:07:25.236924 95036 reflector.go:138] pkg/mod/k8s.io/client-go@v0.23.5/tools/cache/reflector.go:167: Failed to watch *v1.Node: failed to list *v1.Node: Get "http://127.0.0.1/api/v1/nodes?limit=500&resourceVersion=0": dial tcp 127.0.0.1:80: connect: connection refused
cli_test.go:62: [] <nil>
cli_test.go:62: [] <nil>
cli_test.go:62: [] <nil>
cli_test.go:62: [] <nil>
cli_test.go:62: [] <nil>
W1116 11:07:30.568426 95036 reflector.go:324] pkg/mod/k8s.io/client-go@v0.23.5/tools/cache/reflector.go:167: failed to list *v1.Node: Get "http://127.0.0.1/api/v1/nodes?limit=500&resourceVersion=0": dial tcp 127.0.0.1:80: connect: connection refused
E1116 11:07:30.568490 95036 reflector.go:138] pkg/mod/k8s.io/client-go@v0.23.5/tools/cache/reflector.go:167: Failed to watch *v1.Node: failed to list *v1.Node: Get "http://127.0.0.1/api/v1/nodes?limit=500&resourceVersion=0": dial tcp 127.0.0.1:80: connect: connection refused
cli_test.go:62: [] <nil>
We can see, informer is always not synced, but lister returns []
and nil
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.
Just as the comment said, the empty list we initially stored is valid to use.
There maybe not a problem?
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.
Another word, when this function will return false?
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.
When an error occurs in the list, the probability is low.
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 agree with @ikaven1024, maybe we can hold the informer into interpreterConfigManager
, not just the lister.
So, that we can check the sync state by IsInformerSynced
or WaitForCacheSync
.
// the empty list we initially stored is valid to use. // Setting initialSynced to true, so subsequent checks // would be able to take the fast path on the atomic boolean in a // cluster without any customization configured.
By the way, I think the comments didn't answer @ikaven1024's question.
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.
Let's do it by the next PR.
When I apply a ResourceInterpreterCustomization: apiVersion: config.karmada.io/v1alpha1
kind: ResourceInterpreterCustomization
metadata:
name: examples-for-deploy
spec:
target:
apiVersion: apps/v1
kind: Deployment
customizations:
replicaResource:
luaScript: |
function GetReplicas(desiredObj)
nodeClaim = {}
resourceRequest = {}
result = {}
replica = desiredObj.spec.replicas
result.resourceRequest = desiredObj.spec.template.spec.containers[1].resources.limits
nodeClaim.nodeSelector = desiredObj.spec.template.spec.nodeSelector
nodeClaim.tolerations = desiredObj.spec.template.spec.tolerations
result.nodeClaim = {}
result.nodeClaim = nil
return replica, {}
end A panic occurs in the
|
89024b8
to
8c42e34
Compare
pkg/resourceinterpreter/configurableinterpreter/luavm/lua_test.go
Outdated
Show resolved
Hide resolved
2c38dcc
to
c8dbd67
Compare
fixed |
c8dbd67
to
855fd5e
Compare
Signed-off-by: zhangyukun <38148677+jameszhangyukun@users.noreply.github.com>
855fd5e
to
04191b7
Compare
LGTM |
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.
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: RainbowMango The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Signed-off-by: zhangyukun 38148677+jameszhangyukun@users.noreply.github.com
What type of PR is this?
/kind feature
What this PR does / why we need it:
Resource Interpreter interfaces implements
Which issue(s) this PR fixes:
part of #2371
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?: