openyurt icon indicating copy to clipboard operation
openyurt copied to clipboard

[WIP] proposal of yurthub cache refactoring

Open Congrool opened this issue 2 years ago • 7 comments

What type of PR is this?

/kind documentation /kind design /sig storage

What this PR does / why we need it:

When implementing the feature of pool-coordinator, I encountered serval problems to be solved first. So, it is this pr. Details are in the proposal.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?


other Note

Congrool avatar Jun 27 '22 03:06 Congrool

@Congrool: GitHub didn't allow me to assign the following users: your_reviewer.

Note that only openyurtio 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:

What type of PR is this?

/kind documentation /kind design /sig storage

What this PR does / why we need it:

When implementing the feature of pool-coordinator, I encountered serval problems to be solved first. So, it is this pr. Details are in the proposal.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?


other Note

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.

openyurt-bot avatar Jun 27 '22 03:06 openyurt-bot

@Congrool Maybe we should also consider the interface for reading objects from yurthub cache?

rambohe-ch avatar Jun 30 '22 09:06 rambohe-ch

@rambohe-ch Currently we have Get/List/ListKeys only for reading objects in diskStorage. In the case of Pool-Coordiantor, the read request will be send to the APIServer in pool-coordinator, so it does not need to use the read interface to read object from cache directly.

The problem i can find is that the function of List is so weak for using.

  // List will retrieve all contents whose keys have the prefix of rootKey.
  // If rootKey is empty, ErrKeyIsEmpty will be returned.
    // If the rootKey does not exist in the store, ErrStorageNotFound will be returned.
  // If the rootKey exists in the store but no keys has the prefix of rootKey,
    // an empty content slice will be returned.
  List(rootKey Key) ([][]byte, error)

We can see that List only has rootKey as its parameter, which means it cannot list objects with selector. Thus, we can only support one kind of selector for each resource per component as described in #265 . It will be a problem if one component need to list the same resource with different selectors. But currently, we haven't encountered such a component. We can do this enhancement when we have to be faced with it.

Congrool avatar Jun 30 '22 09:06 Congrool

@rambohe-ch Currently we have Get/List/ListKeys only for reading objects in diskStorage. In the case of Pool-Coordiantor, the read request will be send to the APIServer in pool-coordinator, so it does not need to use the read interface to read object from cache directly.

@Congrool ok, the conclusion is that pool-coordinator will not implement Get/List/ListKeys funcs for Storage interface because yurthub read from kube-apiserver of pool-coordinator directly.

rambohe-ch avatar Jul 01 '22 02:07 rambohe-ch

need revision /hold

Congrool avatar Jul 17 '22 16:07 Congrool

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Congrool, rambohe-ch

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 /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

openyurt-bot avatar Jul 26 '22 02:07 openyurt-bot

@qclc: changing LGTM is restricted to collaborators

In response to this:

/lgtm

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.

openyurt-bot avatar Sep 14 '22 13:09 openyurt-bot

revised according to the newest implementation

Congrool avatar Nov 03 '22 03:11 Congrool

Codecov Report

:exclamation: No coverage uploaded for pull request base (master@475c156). Click here to learn what that means. The diff coverage is n/a.

@@            Coverage Diff            @@
##             master     #897   +/-   ##
=========================================
  Coverage          ?   49.45%           
=========================================
  Files             ?       96           
  Lines             ?    13054           
  Branches          ?        0           
=========================================
  Hits              ?     6456           
  Misses            ?     6061           
  Partials          ?      537           
Flag Coverage Δ
unittests 49.45% <0.00%> (?)

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.

codecov[bot] avatar Nov 03 '22 03:11 codecov[bot]

@Congrool how about the definition of KeyBuildInfo and Key struct?

rambohe-ch avatar Nov 04 '22 02:11 rambohe-ch

The definition of Key is like:

type Key interface {
	Key() string
}

type KeyBuildInfo struct {
	Component string
	Namespace string
	Name      string
	Resources string
	Group     string
	Version   string
}

I'll update it in this proposal.

Congrool avatar Nov 04 '22 03:11 Congrool

proposal is updated with definition of Key and new interface names

Congrool avatar Nov 04 '22 04:11 Congrool

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Congrool, rambohe-ch

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 /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

openyurt-bot avatar Nov 04 '22 06:11 openyurt-bot

/lgtm

rambohe-ch avatar Nov 04 '22 06:11 rambohe-ch