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

Ensure protokube can connect to kube-apiserver before starting the sync loop #11093

Merged
merged 1 commit into from
Mar 21, 2021

Conversation

olemarkus
Copy link
Member

@olemarkus olemarkus commented Mar 21, 2021

This commit will have protokube eagerly retry to connect to kube-apiserver instead of the 1 minute sync loop.
Another benefit is that we know that tasks are run in order and that labels are always applied before channels etc

With very few samples, it looks like a cluster gets the DNS entry about 1-2 minutes earlier, which I think makes sense.

Ref #11050

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 21, 2021
@olemarkus
Copy link
Member Author

/cc @justinsb @rifelpet

for {
client, err := k.Kubernetes.KubernetesClient()
if err != nil {
klog.Warningf("could not create kubernetes client: %v", err)
Copy link
Member

Choose a reason for hiding this comment

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

This one probably needs a sleep and continue? Or klog.Fatalf? I think we'll panic on the client.CoreV1() call anyway..

Copy link
Member Author

Choose a reason for hiding this comment

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

We may as well panic here. There isn't much we can do if this one fails.

klog.Info("connected to the apiserver")
break
}
klog.Infof("Could not connect to apiserver: %v", err)
Copy link
Member

Choose a reason for hiding this comment

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

Nit: something to indicate that this is normal(ish) might be helpful here. e.g. "polling for apiserver readiness; not yet ready: %v" or something like that?

@justinsb
Copy link
Member

This is a nice win. LGTM; one error handling comment and one nit.

/approve
/lgtm

/hold

Feel free to remove the hold if you don't think the nits are worth it :-)

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 21, 2021
@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Mar 21, 2021
…nc loop

This commit will have protokube eagerly retry to connect to kube-apiserver instead of the 1 minute sync loop.
Another benefit is that we know that tasks are run in order and that labels are always applied before channels etc
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 21, 2021
@olemarkus olemarkus requested a review from justinsb March 21, 2021 14:50
@rifelpet
Copy link
Member

FWIW, Looking at the protokube logs from the first commit's kubernetes-aws and k8s-containerd jobs it seems we retried 19 and 22 times respectively. We'll see how the most recent jobs perform as well.

Copy link
Member

@rifelpet rifelpet left a comment

Choose a reason for hiding this comment

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

most recent jobs both retried 15 times (75 seconds)

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 21, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: justinsb, rifelpet

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

@justinsb
Copy link
Member

Looks good, going to remove the hold (I had meant it to mean "feel free to remove hold when you want it to merge")

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 21, 2021
@k8s-ci-robot k8s-ci-robot merged commit 9c4de8d into kubernetes:master Mar 21, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.21 milestone Mar 21, 2021
k8s-ci-robot added a commit that referenced this pull request Mar 22, 2021
…093-origin-release-1.20

Automated cherry pick of #11093: Ensure protokube can connect to kube-apiserver before
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants