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

Code refactoring to check annotations. #193

Open
backguynn opened this issue Oct 17, 2024 · 1 comment
Open

Code refactoring to check annotations. #193

backguynn opened this issue Oct 17, 2024 · 1 comment
Assignees
Labels
good first issue Good for newcomers

Comments

@backguynn
Copy link
Collaborator

backguynn commented Oct 17, 2024

K8s 서비스 생성시, kube-loxilb에서 서비스의 annotation을 체크하고 변수에 값을 할당하는 부분이 있습니다. 다음과 같은 부분입니다.

var secIPs []string
numSecondarySvc := 0
livenessCheck := false
lbMode := -1
addrType := "ipv4"
timeout := 30 * 60
probeType := ""
probePort := 0
probeReq := ""
probeResp := ""
probeTimeout := uint32(0)
probeRetries := 0
prefLocal := false
epSelect := api.LbSelRr
matchNodeLabel := ""
usePodNet := false
if strings.Compare(*lbClassName, m.networkConfig.LoxilbLoadBalancerClass) != 0 && !needMultusEP {
return nil
}
// Check for loxilb specific annotations - Addressing
if lba := svc.Annotations[lbAddressAnnotation]; lba != "" {
if lba == "ipv4" || lba == "ipv6" || lba == "ipv6to4" {
addrType = lba
} else if lba == "ip" || lba == "ip4" {
addrType = "ipv4"
} else if lba == "ip6" || lba == "nat66" {
addrType = "ipv6"
} else if lba == "nat64" {
addrType = "ipv6to4"
}
}

annotation 체크하는 부분을 따로 함수로 빼고, 변수들은 따로 struct로 묶어서 해당 함수에서 struct 값을 업데이트한 다음,
다른 곳에서도 변수 대신 struct를 사용하도록 하면 코드가 좀 더 깔끔해질 것 같습니다.

===============

When creating a K8s service, there is a part in kube-loxilb that checks the annotation of the service and assigns values ​​to variables.

Extract the annotation checking part into a separate function, group the variables into a separate struct, and update the struct value in the function.
I think the code would be cleaner if we used structs instead of variables in other places as well.

@backguynn backguynn added the good first issue Good for newcomers label Oct 17, 2024
@YelynnOh
Copy link

I'm interested in this issue! Would be glad to work on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants