karmada icon indicating copy to clipboard operation
karmada copied to clipboard

[refactor] Resource Interpreter Framework cache and reorganize configurations

Open ikaven1024 opened this issue 2 years ago • 5 comments

Signed-off-by: yingjinhui [email protected]

What type of PR is this? /kind feature

What this PR does / why we need it: add framework cache and reorganize configurations Resource Interpreter

Which issue(s) this PR fixes: Part of #2371

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

ikaven1024 avatar Nov 03 '22 05:11 ikaven1024

cc @XiShanYongYe-Chang @jameszhangyukun @chaunceyjiang

ikaven1024 avatar Nov 03 '22 05:11 ikaven1024

/assign @jameszhangyukun

XiShanYongYe-Chang avatar Nov 03 '22 06:11 XiShanYongYe-Chang

@XiShanYongYe-Chang: GitHub didn't allow me to assign the following users: jameszhangyukun.

Note that only karmada-io members, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time. For more information please see the contributor guide

In response to this:

/assign @jameszhangyukun

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.

karmada-bot avatar Nov 03 '22 06:11 karmada-bot

Just for the record: this pr is refactored based on the #2719.

XiShanYongYe-Chang avatar Nov 03 '22 08:11 XiShanYongYe-Chang

Hi @ikaven1024 Could you please rebase and resolve the conflicts? (#2719 has been merged)

Which one should be the next do you think? this one, or #2731?

RainbowMango avatar Nov 07 '22 07:11 RainbowMango

Which one should be the next do you think? this one, or #2731?

Let #2731 go on first. I will rebase and refactor after it completed.

ikaven1024 avatar Nov 07 '22 07:11 ikaven1024

Let's move on.

XiShanYongYe-Chang avatar Nov 08 '22 03:11 XiShanYongYe-Chang

Let's move on.

OK, I am going to fix the conflict firstly. I will assign you after it's ready.

ikaven1024 avatar Nov 08 '22 04:11 ikaven1024

@XiShanYongYe-Chang PTAL

ikaven1024 avatar Nov 08 '22 09:11 ikaven1024

Codecov Report

Merging #2733 (d97c5c1) into master (32291df) will decrease coverage by 0.52%. The diff coverage is 36.41%.

@@            Coverage Diff             @@
##           master    #2733      +/-   ##
==========================================
- Coverage   37.72%   37.20%   -0.53%     
==========================================
  Files         200      200              
  Lines       18435    18351      -84     
==========================================
- Hits         6955     6827     -128     
- Misses      11075    11136      +61     
+ Partials      405      388      -17     
Flag Coverage Δ
unittests 37.20% <36.41%> (-0.53%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ceinterpreter/configurableinterpreter/luavm/lua.go 25.17% <ø> (-31.92%) :arrow_down:
...nterpreter/configurableinterpreter/configurable.go 17.14% <18.30%> (ø)
...nterpreter/configurableinterpreter/executor/lua.go 50.54% <50.54%> (ø)
...reter/configurableinterpreter/luavm/lua_convert.go 65.21% <0.00%> (-8.70%) :arrow_down:
...kg/scheduler/framework/runtime/metrics_recorder.go 82.85% <0.00%> (-5.72%) :arrow_down:
pkg/search/proxy/store/util.go 93.36% <0.00%> (-0.95%) :arrow_down:
...r/configurableinterpreter/configmanager/manager.go

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov-commenter avatar Nov 08 '22 09:11 codecov-commenter

I have face this error twice, but do not known why. https://github.com/karmada-io/karmada/actions/runs/3417843605/jobs/5689574998#step:4:23

Run export CLUSTER_VERSION=kindest/node:v1.22.7
Preparing: 'kind' existence check - passed
Preparing: 'kubectl' existence check - passed
Preparing kindClusterConfig in path: /tmp/tmp.BXOP8AvTSD
Creating cluster karmada-host and the log file is in /tmp/karmada/karmada-host.log
Creating cluster member1 and the log file is in /tmp/karmada/member1.log
Creating cluster member2 and the log file is in /tmp/karmada/member2.log
Creating cluster member3 and the log file is in /tmp/karmada/member3.log
make: Entering directory '/home/runner/work/karmada/karmada'
set -e;\
target=$(echo karmada-aggregated-apiserver);\
make $target GOOS=linux;\
VERSION=latest REGISTRY=swr.ap-southeast-1.myhuaweicloud.com/karmada BUILD_PLATFORMS=linux/amd64 hack/docker.sh $target
make[1]: Entering directory '/home/runner/work/karmada/karmada'
yacc  vendor/github.com/yuin/gopher-lua/parse/parser.go.y 
vendor/github.com/yuin/gopher-lua/parse/parser.go.y: warning: 3 shift/reduce conflicts [-Wconflicts-sr]
mv -f y.tab.c vendor/github.com/yuin/gopher-lua/parse/parser.go.c
cc    -c -o vendor/github.com/yuin/gopher-lua/parse/parser.go.o vendor/github.com/yuin/gopher-lua/parse/parser.go.c
vendor/github.com/yuin/gopher-lua/parse/parser.go.y:2:1: error: unknown type name ‘package’
    2 | package parse
      | ^~~~~~~
vendor/github.com/yuin/gopher-lua/parse/parser.go.y:4:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘import’
    4 | import (
      | ^~~~~~
vendor/github.com/yuin/gopher-lua/parse/parser.go.y:3[5](https://github.com/karmada-io/karmada/actions/runs/3417843605/jobs/5689574998#step:4:6):3: error: unknown type name ‘token’
   35 |   token  ast.Token
      |   ^~~~~
vendor/github.com/yuin/gopher-lua/parse/parser.go.y:35:13: error: expected ‘:’, ‘,’, ‘;’, ‘}’ or ‘__attribute__’ before ‘.’ token
   35 |   token  ast.Token
      |             ^
y.tab.c: In function ‘yyparse’:
y.tab.c:1515:1[6](https://github.com/karmada-io/karmada/actions/runs/3417843605/jobs/5689574998#step:4:7): warning: implicit declaration of function ‘yylex’ [-Wimplicit-function-declaration]
vendor/github.com/yuin/gopher-lua/parse/parser.go.y:[7](https://github.com/karmada-io/karmada/actions/runs/3417843605/jobs/5689574998#step:4:8)4:19: error: ‘YYSTYPE’ {aka ‘union YYSTYPE’} has no member named ‘stmts’
   74 |             $$ = $1
      |                   ^
vendor/github.com/yuin/gopher-lua/parse/parser.go.y:74:3[8](https://github.com/karmada-io/karmada/actions/runs/3417843605/jobs/5689574998#step:4:9): error: ‘YYSTYPE’ {aka ‘union YYSTYPE’} has no member named ‘stmts’
   74 |             $$ = $1
      |                                      ^
vendor/github.com/yuin/gopher-lua/parse/parser.go.y:74:45: error: expected ‘;’ before ‘if’
   74 |             $$ = $1
      |                                             ^
      |                                             ;
   75 |             if l, ok := yylex.(*Lexer); ok {
      |             ~~                               
vendor/github.com/yuin/gopher-lua/parse/parser.go.y:75:41: error: ‘ok’ undeclared (first use in this function)
   75 |             if l, ok := yylex.(*Lexer); ok {
y.tab.c:2504:7: warning: implicit declaration of function ‘yyerror’; did you mean ‘yyerrok’? [-Wimplicit-function-declaration]
vendor/github.com/yuin/gopher-lua/parse/parser.go.y: At top level:
vendor/github.com/yuin/gopher-lua/parse/parser.go.y:51[9](https://github.com/karmada-io/karmada/actions/runs/3417843605/jobs/5689574998#step:4:10):1: error: unknown type name ‘func’
  519 | func TokenName(c int) string {
      | ^~~~
vendor/github.com/yuin/gopher-lua/parse/parser.go.y:519:[16](https://github.com/karmada-io/karmada/actions/runs/3417843605/jobs/5689574998#step:4:17): error: unknown type name ‘c’
  5[19](https://github.com/karmada-io/karmada/actions/runs/3417843605/jobs/5689574998#step:4:20) | func TokenName(c int) string {
      |                ^
make[1]: *** [<builtin>: vendor/github.com/yuin/gopher-lua/parse/parser.go.o] Error 1
rm vendor/github.com/yuin/gopher-lua/parse/parser.go.c
make[1]: Leaving directory '/home/runner/work/karmada/karmada'
make: *** [Makefile:69: image-karmada-aggregated-apiserver] Error 2
make: Leaving directory '/home/runner/work/karmada/karmada'

ikaven1024 avatar Nov 08 '22 09:11 ikaven1024

@XiShanYongYe-Chang PTAL

Thanks~ Let me take a study.

XiShanYongYe-Chang avatar Nov 08 '22 09:11 XiShanYongYe-Chang

/assign

RainbowMango avatar Nov 10 '22 03:11 RainbowMango

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: To complete the pull request process, please ask for approval from rainbowmango after the PR has been reviewed.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

karmada-bot avatar Nov 10 '22 05:11 karmada-bot

After going through this approach, I think the complexity is much more than I expected.

@XiShanYongYe-Chang How much gap do we have according to the previous approach? Can we have a workable implementation quickly?

RainbowMango avatar Nov 10 '22 09:11 RainbowMango

Can we have a workable implementation quickly?

You can experience with this branch: https://github.com/ikaven1024/karmada/tree/interpret-ctl-demo

I test it on my side:

  1. Apply the customization:
apiVersion: config.karmada.io/v1alpha1
kind: ResourceInterpreterCustomization
metadata:
spec:
  customizations:
    replicaResource:
      luaScript: |
        function GetReplicas(obj)
          replica = obj.spec.replicas + 1
          requirement = {}
          return replica, requirement
        end
  target:
    apiVersion: apps/v1
    kind: Deployment
  1. Apply deployment with 3 replicas

  2. get deployment and see 4 replicas (affected by customization)

kubectl get deploy
NAME    READY   UP-TO-DATE   AVAILABLE   AGE
nginx   4/3     4            4           3s

ikaven1024 avatar Nov 10 '22 10:11 ikaven1024

@XiShanYongYe-Chang @RainbowMango Plz take a loot at the new framework. (tests are not ready)

ikaven1024 avatar Nov 11 '22 07:11 ikaven1024

OK. working on it.

RainbowMango avatar Nov 11 '22 07:11 RainbowMango