-
Notifications
You must be signed in to change notification settings - Fork 5
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
Exposes the endpointSliceWatchTimeout value #53
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3ca65d8
exposes the endpointSliceWatchTimeout
sonnysideup 3a7db87
fixes poolEndpointWatchTimeout comment
sonnysideup ca36bd0
fixes buildkit worker pool unit test
sonnysideup 832813c
upgrade to go 1.19
sonnysideup 83a40d9
upgrade to vector 0.23
sonnysideup bcbd156
adds diagnostic logs to buildkit worker pool
sonnysideup b18f3b2
updates golangci-lint to v1.48.0
sonnysideup 476f7fc
exposes fetchAndExtractTimeout config value
sonnysideup File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,9 +39,8 @@ type Pool interface { | |
var ( | ||
ErrNoUnleasedPods = errors.New("no unleased pods found") | ||
|
||
newUUID = uuid.NewUUID | ||
statefulPodRegex = regexp.MustCompile(`^.*-(\d+)$`) | ||
endpointSliceWatchTimeout = pointer.Int64(90) | ||
newUUID = uuid.NewUUID | ||
statefulPodRegex = regexp.MustCompile(`^.*-(\d+)$`) | ||
) | ||
|
||
const ( | ||
|
@@ -74,8 +73,9 @@ type workerPool struct { | |
podClient corev1typed.PodInterface | ||
endpointSliceClient discoveryv1beta1typed.EndpointSliceInterface | ||
|
||
podListOptions metav1.ListOptions | ||
endpointSliceListOptions metav1.ListOptions | ||
podListOptions metav1.ListOptions | ||
endpointSliceListOptions metav1.ListOptions | ||
endpointSliceWatchTimeout int64 | ||
|
||
// endpoints discovery | ||
serviceName string | ||
|
@@ -101,23 +101,24 @@ func NewPool(ctx context.Context, clientset kubernetes.Interface, conf config.Bu | |
|
||
ctx, cancel := context.WithCancel(ctx) | ||
wp := &workerPool{ | ||
ctx: ctx, | ||
cancel: cancel, | ||
log: o.Log, | ||
poolSyncTime: o.SyncWaitTime, | ||
podMaxIdleTime: o.MaxIdleTime, | ||
uuid: string(newUUID()), | ||
requests: NewRequestQueue(), | ||
notifyReconcile: make(chan struct{}, 1), | ||
podClient: clientset.CoreV1().Pods(conf.Namespace), | ||
endpointSliceClient: clientset.DiscoveryV1beta1().EndpointSlices(conf.Namespace), | ||
podListOptions: podListOptions, | ||
endpointSliceListOptions: endpointSliceListOptions, | ||
serviceName: conf.ServiceName, | ||
servicePort: conf.DaemonPort, | ||
statefulSetName: conf.StatefulSetName, | ||
statefulSetClient: clientset.AppsV1().StatefulSets(conf.Namespace), | ||
namespace: conf.Namespace, | ||
ctx: ctx, | ||
cancel: cancel, | ||
log: o.Log, | ||
poolSyncTime: o.SyncWaitTime, | ||
podMaxIdleTime: o.MaxIdleTime, | ||
endpointSliceWatchTimeout: o.EndpointWatchTimeoutSeconds, | ||
uuid: string(newUUID()), | ||
requests: NewRequestQueue(), | ||
notifyReconcile: make(chan struct{}, 1), | ||
podClient: clientset.CoreV1().Pods(conf.Namespace), | ||
endpointSliceClient: clientset.DiscoveryV1beta1().EndpointSlices(conf.Namespace), | ||
podListOptions: podListOptions, | ||
endpointSliceListOptions: endpointSliceListOptions, | ||
serviceName: conf.ServiceName, | ||
servicePort: conf.DaemonPort, | ||
statefulSetName: conf.StatefulSetName, | ||
statefulSetClient: clientset.AppsV1().StatefulSets(conf.Namespace), | ||
namespace: conf.Namespace, | ||
} | ||
|
||
wp.log.Info("Starting worker pod monitor", "syncTime", wp.poolSyncTime.String()) | ||
|
@@ -268,7 +269,7 @@ func (p *workerPool) buildEndpointURL(ctx context.Context, podName string) (stri | |
|
||
watchOpts := metav1.ListOptions{ | ||
LabelSelector: p.endpointSliceListOptions.LabelSelector, | ||
TimeoutSeconds: endpointSliceWatchTimeout, | ||
TimeoutSeconds: &p.endpointSliceWatchTimeout, | ||
} | ||
watcher, err := p.endpointSliceClient.Watch(ctx, watchOpts) | ||
if err != nil { | ||
|
@@ -289,7 +290,7 @@ func (p *workerPool) buildEndpointURL(ctx context.Context, podName string) (stri | |
p.log.Info("Finished watching endpoints", "podName", podName, "duration", time.Since(start)) | ||
|
||
if hostname == "" { | ||
return "", fmt.Errorf("failed to extract hostname after %d seconds", *endpointSliceWatchTimeout) | ||
return "", fmt.Errorf("failed to extract hostname after %d seconds", p.endpointSliceWatchTimeout) | ||
} | ||
|
||
u, err := url.ParseRequestURI(fmt.Sprintf("tcp://%s:%d", hostname, p.servicePort)) | ||
|
@@ -375,8 +376,7 @@ func (p *workerPool) updateWorkers(ctx context.Context) error { | |
if req := p.requests.Dequeue(); req != nil { | ||
log.Info("Found pending pod request, processing") | ||
|
||
pod := pod | ||
if p.processPodRequest(ctx, req, &pod) { | ||
if p.processPodRequest(ctx, req, pod) { | ||
leased = append(leased, pod.Name) | ||
} | ||
continue | ||
|
@@ -449,11 +449,11 @@ func (p *workerPool) updateWorkers(ctx context.Context) error { | |
} | ||
|
||
// attempts to lease a pod, build and endpoint url, and provide a request result | ||
func (p *workerPool) processPodRequest(ctx context.Context, req *PodRequest, pod *corev1.Pod) (success bool) { | ||
func (p *workerPool) processPodRequest(ctx context.Context, req *PodRequest, pod corev1.Pod) (success bool) { | ||
log := p.log.WithValues("podName", pod.Name) | ||
|
||
log.Info("Attempting to lease pod") | ||
if err := p.leasePod(ctx, pod, req.owner); err != nil { | ||
if err := p.leasePod(ctx, &pod, req.owner); err != nil { | ||
log.Error(err, "Failed to lease pod") | ||
|
||
req.result <- PodRequestResult{err: err} | ||
|
@@ -466,8 +466,8 @@ func (p *workerPool) processPodRequest(ctx context.Context, req *PodRequest, pod | |
if err != nil { | ||
log.Error(err, "Failed to build routable URL") | ||
|
||
if rErr := p.releasePod(ctx, pod); rErr != nil { | ||
log.Error(err, "Failed to release pod") | ||
if rErr := p.releasePod(ctx, &pod); rErr != nil { | ||
log.Error(rErr, "Failed to release pod") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was logging the wrong error. |
||
} | ||
|
||
req.result <- PodRequestResult{err: err} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 passing the pod value instead of a pointer to avoid implicit memory aliasing and variable re-declaration.