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

reorganize the edgemesh project catalog #19

Merged
merged 3 commits into from
Jul 23, 2021
Merged

Conversation

Poorunga
Copy link
Member

@Poorunga Poorunga commented Jul 12, 2021

edgemesh will later have two parts: edgemesh-server and edgemesh-agent.
edgemesh-server is usually deployed in the cloud and acts as a relay server in the LibP2P mode or assist the agent to establish p2p hole punching. It is specifically responsible for forwarding data across subnets.
edgemesh-agent is usually deployed in the edge to act as an agent for communication between pods at different locations. It is internally divided into the following modules:

  • DNS: Built-in DNS resolver, which resolves the DNS request in the node into a service cluster IP.
  • proxy: Responsible for configuring the kernel's iptables rules, and intercepting requests to the EdgeMesh process.
  • gateway: gateway provides a ability to access services in external edge nodes.

@fisherxu fisherxu closed this Jul 13, 2021
@fisherxu fisherxu reopened this Jul 13, 2021
@kubeedge-bot kubeedge-bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jul 13, 2021
@Poorunga
Copy link
Member Author

/assign @Poorunga

@@ -111,10 +115,10 @@ clean:
endif


ARCH ?= amd64
Copy link
Contributor

Choose a reason for hiding this comment

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

where is this parameter used

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe it will be used in the future :)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this belong to useless code and will cause confusion to others.

)

func main() {
command := app.NewEdgeMeshCommand()
rand.Seed(time.Now().UnixNano())
Copy link
Contributor

Choose a reason for hiding this comment

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

where is this rand used

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe it will be used in the future :)

AddFunc: c.drAdd, UpdateFunc: c.drUpdate, DeleteFunc: c.drDelete})
}

//func (c *controller) epAdd(obj interface{}) {}
Copy link
Contributor

Choose a reason for hiding this comment

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

please delete useless code

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

)

// Manager is gateway manager
type Manager struct {
ipArray []net.IP
lock sync.RWMutex
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems that sync.Mutex is enough

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

// UpdateGateway update a gateway server
func (mgr *Manager) UpdateGateway(gw *istioapi.Gateway) {
mgr.lock.Lock()
defer mgr.lock.Unlock()
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need to lock the total function ? can we just lock the mgr.serversByGateway[key] = newGatewayServers

Copy link
Member Author

@Poorunga Poorunga Jul 16, 2021

Choose a reason for hiding this comment

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

AddGateway can be modified as you said, but UpdaeGateway have multiple critical sections.

@khalid-huang
Copy link
Contributor

/lgtm

@kubeedge-bot kubeedge-bot added the lgtm Indicates that a PR is ready to be merged. label Jul 19, 2021
Init()
GetSvcPorts(ip string) string
GetSvcIP(svcName string) string
}
Copy link
Member

Choose a reason for hiding this comment

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

Why here need a set of interface, this interface only have one implement. in other module like dns, I found the similar code

Copy link
Member Author

Choose a reason for hiding this comment

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

Adopt your suggestion

svcPorts += svcName
return svcPorts
}
const SoOriginalDst = 80
Copy link
Member

Choose a reason for hiding this comment

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

constants puts on the front of file looks better

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it's more standardized like that

const (
EdgeDNSModuleName = "edgedns"
EdgeProxyModuleName = "edgeproxy"
EdgeGatewayModuleName = "edgegateway"
Copy link
Member

Choose a reason for hiding this comment

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

ModuleName and ModuleGroupName are better defined as two constants even if the two values are the same.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we can modify it later when necessary

proxy = &EdgeProxy{Config: c}
if !proxy.Config.Enable {
return proxy, nil
}
Copy link
Member

Choose a reason for hiding this comment

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

if !c.Enable {
    return
}
proxy = &EdgeProxy{Config: c}

judge {enable} in the front of function avoid creating EdgeProxy

Copy link
Member Author

@Poorunga Poorunga Jul 22, 2021

Choose a reason for hiding this comment

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

It should be coded like this:

proxy = &EdgeProxy{Config: c}
if !c.Enable {
    return proxy, nil
}

Otherwise, registryModules will terminate as an error.

Enable: true,
ListenInterface: "docker0",
ListenPort: 53,
},
Copy link
Member

Choose a reason for hiding this comment

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

EdgeDNSConfig: dnsconfig.NewEdgeDNSConfig(), EdgePorxyConfig: proxyconfig.NewEdgeProxyConfig(),
every module have self default config function may be better

Copy link
Member Author

Choose a reason for hiding this comment

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

Adopt your suggestion

}

type controller struct {
svcLister listers.ServiceLister
Copy link
Member

Choose a reason for hiding this comment

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

what's the usage of svcLister, I just find the initialization code

Copy link
Member Author

Choose a reason for hiding this comment

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

Alright, svcLister has been deleted.

IPBySvc map[string]string // key: svcName.svcNamespace, value: clusterIP
}

func New(ifm *informers.Manager) *controller {
Copy link
Member

Choose a reason for hiding this comment

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

I think function New should return a singleton, if other package want to use the interface of controller, now have to import it in the package proxy, and new a proxy to call it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Adopt your suggestion

func (c *controller) GetSvcIP(svcName string) string {
c.RLock()
defer c.RUnlock()
ip := c.IPBySvc[svcName]
Copy link
Member

Choose a reason for hiding this comment

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

If controller is a singleton and you want user use function GetScvIP to get ClusterIP, then IPBySvc should be ipBySvc, SvcPortsByIP as the same

Copy link
Member Author

Choose a reason for hiding this comment

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

Adopt your suggestion

@kubeedge-bot kubeedge-bot removed the lgtm Indicates that a PR is ready to be merged. label Jul 22, 2021
@kubeedge-bot
Copy link
Collaborator

@ZBoIsHere: 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.

@ZBoIsHere
Copy link
Member

/assign @ZBoIsHere

@kubeedge-bot
Copy link
Collaborator

@ZBoIsHere: 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.

@llhuii
Copy link

llhuii commented Jul 23, 2021

/lgtm

@kubeedge-bot kubeedge-bot added the lgtm Indicates that a PR is ready to be merged. label Jul 23, 2021
@llhuii
Copy link

llhuii commented Jul 23, 2021

/lgtm cancel

@kubeedge-bot kubeedge-bot removed the lgtm Indicates that a PR is ready to be merged. label Jul 23, 2021
@llhuii llhuii removed their assignment Jul 23, 2021
Signed-off-by: Poorunga <2744323@qq.com>
Signed-off-by: Poorunga <2744323@qq.com>
@khalid-huang
Copy link
Contributor

/lgtm

@kubeedge-bot kubeedge-bot added the lgtm Indicates that a PR is ready to be merged. label Jul 23, 2021
@fisherxu
Copy link
Member

/approve

@fisherxu fisherxu added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 23, 2021
@kubeedge-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by: fisherxu

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

@kubeedge-bot kubeedge-bot merged commit 2522dbe into kubeedge:main Jul 23, 2021
@Poorunga Poorunga deleted the tidyup branch January 17, 2023 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants