Unverified Commit 7190c74a authored by Brad Davidson's avatar Brad Davidson Committed by GitHub

[release-1.30] Backports for 2024-08 release cycle (#10664)

* Use pagination when retrieving etcd snapshot list Signed-off-by: 's avatarBrad Davidson <brad.davidson@rancher.com> (cherry picked from commit c2216a62) Signed-off-by: 's avatarBrad Davidson <brad.davidson@rancher.com> * Update secretsencrypt pagination Make secretsencrypt page size and iteration consistent with other paginators Signed-off-by: 's avatarBrad Davidson <brad.davidson@rancher.com> (cherry picked from commit 891e72f9) Signed-off-by: 's avatarBrad Davidson <brad.davidson@rancher.com> * Cap length of generated name used for servicelb daemonset Signed-off-by: 's avatarBrad Davidson <brad.davidson@rancher.com> (cherry picked from commit 21611c56) Signed-off-by: 's avatarBrad Davidson <brad.davidson@rancher.com> * Fix ipv6 sysctl required by non-ipv6 LoadBalancer service This is a partial revert of 095ecdb0, with the workaround moved into klipper-lb. Signed-off-by: 's avatarBrad Davidson <brad.davidson@rancher.com> (cherry picked from commit d4c3422a) Signed-off-by: 's avatarBrad Davidson <brad.davidson@rancher.com> * remove deprecated use of wait functions Signed-off-by: 's avatarWill <will7989@hotmail.com> (cherry picked from commit e4f3cc7b) Signed-off-by: 's avatarBrad Davidson <brad.davidson@rancher.com> * Update pkg/secretsencrypt/config.go Co-authored-by: 's avatarBrad Davidson <brad@oatmail.org> Signed-off-by: 's avatarWill Andrews <will7989@hotmail.com> (cherry picked from commit 3ec086f6) Signed-off-by: 's avatarBrad Davidson <brad.davidson@rancher.com> * Update pkg/cluster/managed.go Co-authored-by: 's avatarDerek Nola <derek.nola@suse.com> Signed-off-by: 's avatarWill Andrews <will7989@hotmail.com> (cherry picked from commit e2179aa9) Signed-off-by: 's avatarBrad Davidson <brad.davidson@rancher.com> * Wire lasso metrics up to common gatherer Signed-off-by: 's avatarBrad Davidson <brad.davidson@rancher.com> (cherry picked from commit e168438d) Signed-off-by: 's avatarBrad Davidson <brad.davidson@rancher.com> * Fix cloudprovider controller name Looking at metrics revealed the cloudprovider controller name was anempty string. Signed-off-by: 's avatarBrad Davidson <brad.davidson@rancher.com> (cherry picked from commit bffdf463) Signed-off-by: 's avatarBrad Davidson <brad.davidson@rancher.com> --------- Signed-off-by: 's avatarBrad Davidson <brad.davidson@rancher.com> Signed-off-by: 's avatarWill <will7989@hotmail.com> Signed-off-by: 's avatarWill Andrews <will7989@hotmail.com> Co-authored-by: 's avatarWill <will7989@hotmail.com> Co-authored-by: 's avatarDerek Nola <derek.nola@suse.com>
parent fa480384
...@@ -122,7 +122,7 @@ require ( ...@@ -122,7 +122,7 @@ require (
github.com/prometheus/client_golang v1.19.1 github.com/prometheus/client_golang v1.19.1
github.com/prometheus/common v0.49.0 github.com/prometheus/common v0.49.0
github.com/rancher/dynamiclistener v0.6.0-rc1 github.com/rancher/dynamiclistener v0.6.0-rc1
github.com/rancher/lasso v0.0.0-20240430201833-6f3def65ffc5 github.com/rancher/lasso v0.0.0-20240724174736-24ab3dbf26f0
github.com/rancher/permissions v0.0.0-20240523180510-4001d3d637f7 github.com/rancher/permissions v0.0.0-20240523180510-4001d3d637f7
github.com/rancher/remotedialer v0.4.1 github.com/rancher/remotedialer v0.4.1
github.com/rancher/wharfie v0.6.4 github.com/rancher/wharfie v0.6.4
...@@ -279,7 +279,7 @@ require ( ...@@ -279,7 +279,7 @@ require (
github.com/hashicorp/go-version v1.6.0 // indirect github.com/hashicorp/go-version v1.6.0 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/golang-lru/arc/v2 v2.0.5 // indirect github.com/hashicorp/golang-lru/arc/v2 v2.0.5 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.5 // indirect github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/huin/goupnp v1.3.0 // indirect github.com/huin/goupnp v1.3.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect github.com/imdario/mergo v0.3.16 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect
......
...@@ -819,8 +819,8 @@ github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+l ...@@ -819,8 +819,8 @@ github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+l
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/hashicorp/golang-lru/arc/v2 v2.0.5 h1:l2zaLDubNhW4XO3LnliVj0GXO3+/CGNJAg1dcN2Fpfw= github.com/hashicorp/golang-lru/arc/v2 v2.0.5 h1:l2zaLDubNhW4XO3LnliVj0GXO3+/CGNJAg1dcN2Fpfw=
github.com/hashicorp/golang-lru/arc/v2 v2.0.5/go.mod h1:ny6zBSQZi2JxIeYcv7kt2sH2PXJtirBN7RDhRpxPkxU= github.com/hashicorp/golang-lru/arc/v2 v2.0.5/go.mod h1:ny6zBSQZi2JxIeYcv7kt2sH2PXJtirBN7RDhRpxPkxU=
github.com/hashicorp/golang-lru/v2 v2.0.5 h1:wW7h1TG88eUIJ2i69gaE3uNVtEPIagzhGvHgwfx2Vm4= github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
github.com/hashicorp/golang-lru/v2 v2.0.5/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
...@@ -1407,8 +1407,8 @@ github.com/quic-go/webtransport-go v0.6.0 h1:CvNsKqc4W2HljHJnoT+rMmbRJybShZ0YPFD ...@@ -1407,8 +1407,8 @@ github.com/quic-go/webtransport-go v0.6.0 h1:CvNsKqc4W2HljHJnoT+rMmbRJybShZ0YPFD
github.com/quic-go/webtransport-go v0.6.0/go.mod h1:9KjU4AEBqEQidGHNDkZrb8CAa1abRaosM2yGOyiikEc= github.com/quic-go/webtransport-go v0.6.0/go.mod h1:9KjU4AEBqEQidGHNDkZrb8CAa1abRaosM2yGOyiikEc=
github.com/rancher/dynamiclistener v0.6.0-rc1 h1:Emwf9o7PMLdQNv4lvFx7xJKxDuDa4Y69GvVEGU9U9Js= github.com/rancher/dynamiclistener v0.6.0-rc1 h1:Emwf9o7PMLdQNv4lvFx7xJKxDuDa4Y69GvVEGU9U9Js=
github.com/rancher/dynamiclistener v0.6.0-rc1/go.mod h1:BIPgJ8xFSUyuTyGvRMVt++S1qjD3+7Ptvq1TXl6hcTM= github.com/rancher/dynamiclistener v0.6.0-rc1/go.mod h1:BIPgJ8xFSUyuTyGvRMVt++S1qjD3+7Ptvq1TXl6hcTM=
github.com/rancher/lasso v0.0.0-20240430201833-6f3def65ffc5 h1:6K4RhfmCy7uxaw9OzCljNLfFcgD/q7SeF+/2gCQ3Tvw= github.com/rancher/lasso v0.0.0-20240724174736-24ab3dbf26f0 h1:rM56SuQHkXyzPqldBDMdBZ8H4tOzyfbKxMlGyKnTQF8=
github.com/rancher/lasso v0.0.0-20240430201833-6f3def65ffc5/go.mod h1:7WkdfPEvWAdnHVioMUkhpZkshJzjDY62ocHVhcbw89M= github.com/rancher/lasso v0.0.0-20240724174736-24ab3dbf26f0/go.mod h1:A/y3BLQkxZXYD60MNDRwAG9WGxXfvd6Z6gWR/a8wPw8=
github.com/rancher/permissions v0.0.0-20240523180510-4001d3d637f7 h1:0Kg2SGoMeU1ll4xPi4DE0+qNHLFO/U5MwtK0WrIdK+o= github.com/rancher/permissions v0.0.0-20240523180510-4001d3d637f7 h1:0Kg2SGoMeU1ll4xPi4DE0+qNHLFO/U5MwtK0WrIdK+o=
github.com/rancher/permissions v0.0.0-20240523180510-4001d3d637f7/go.mod h1:fsbs0YOsGn1ofPD5p+BuI4qDhbMbSJtTegKt6Ucna+c= github.com/rancher/permissions v0.0.0-20240523180510-4001d3d637f7/go.mod h1:fsbs0YOsGn1ofPD5p+BuI4qDhbMbSJtTegKt6Ucna+c=
github.com/rancher/remotedialer v0.4.1 h1:jwOf2kPRjBBpSFofv1OuZHWaYHeC9Eb6/XgDvbkoTgc= github.com/rancher/remotedialer v0.4.1 h1:jwOf2kPRjBBpSFofv1OuZHWaYHeC9Eb6/XgDvbkoTgc=
......
...@@ -59,6 +59,8 @@ func Get(ctx context.Context, agent cmds.Agent, proxy proxy.Proxy) (*config.Node ...@@ -59,6 +59,8 @@ func Get(ctx context.Context, agent cmds.Agent, proxy proxy.Proxy) (*config.Node
// does not support jittering, so we instead use wait.JitterUntilWithContext, and cancel // does not support jittering, so we instead use wait.JitterUntilWithContext, and cancel
// the context on success. // the context on success.
ctx, cancel := context.WithCancel(ctx) ctx, cancel := context.WithCancel(ctx)
defer cancel()
wait.JitterUntilWithContext(ctx, func(ctx context.Context) { wait.JitterUntilWithContext(ctx, func(ctx context.Context) {
agentConfig, err = get(ctx, &agent, proxy) agentConfig, err = get(ctx, &agent, proxy)
if err != nil { if err != nil {
...@@ -78,7 +80,7 @@ func KubeProxyDisabled(ctx context.Context, node *config.Node, proxy proxy.Proxy ...@@ -78,7 +80,7 @@ func KubeProxyDisabled(ctx context.Context, node *config.Node, proxy proxy.Proxy
var disabled bool var disabled bool
var err error var err error
wait.PollImmediateUntilWithContext(ctx, 5*time.Second, func(ctx context.Context) (bool, error) { _ = wait.PollUntilContextCancel(ctx, 5*time.Second, true, func(ctx context.Context) (bool, error) {
disabled, err = getKubeProxyDisabled(ctx, node, proxy) disabled, err = getKubeProxyDisabled(ctx, node, proxy)
if err != nil { if err != nil {
logrus.Infof("Waiting to retrieve kube-proxy configuration; server is not ready: %v", err) logrus.Infof("Waiting to retrieve kube-proxy configuration; server is not ready: %v", err)
...@@ -96,7 +98,7 @@ func APIServers(ctx context.Context, node *config.Node, proxy proxy.Proxy) []str ...@@ -96,7 +98,7 @@ func APIServers(ctx context.Context, node *config.Node, proxy proxy.Proxy) []str
var addresses []string var addresses []string
var err error var err error
wait.PollImmediateUntilWithContext(ctx, 5*time.Second, func(ctx context.Context) (bool, error) { _ = wait.PollUntilContextCancel(ctx, 5*time.Second, true, func(ctx context.Context) (bool, error) {
addresses, err = getAPIServers(ctx, node, proxy) addresses, err = getAPIServers(ctx, node, proxy)
if err != nil { if err != nil {
logrus.Infof("Failed to retrieve list of apiservers from server: %v", err) logrus.Infof("Failed to retrieve list of apiservers from server: %v", err)
......
...@@ -70,7 +70,7 @@ func Run(ctx context.Context, nodeConfig *config.Node) error { ...@@ -70,7 +70,7 @@ func Run(ctx context.Context, nodeConfig *config.Node) error {
// kube-router netpol requires addresses to be available in the node object. // kube-router netpol requires addresses to be available in the node object.
// Wait until the uninitialized taint has been removed, at which point the addresses should be set. // Wait until the uninitialized taint has been removed, at which point the addresses should be set.
// TODO: Replace with non-deprecated PollUntilContextTimeout when our and Kubernetes code migrate to it // TODO: Replace with non-deprecated PollUntilContextTimeout when our and Kubernetes code migrate to it
if err := wait.PollImmediateInfiniteWithContext(ctx, 2*time.Second, func(ctx context.Context) (bool, error) { if err := wait.PollUntilContextCancel(ctx, 2*time.Second, true, func(ctx context.Context) (bool, error) {
// Get the node object // Get the node object
node, err := client.CoreV1().Nodes().Get(ctx, nodeConfig.AgentConfig.NodeName, metav1.GetOptions{}) node, err := client.CoreV1().Nodes().Get(ctx, nodeConfig.AgentConfig.NodeName, metav1.GetOptions{})
if err != nil { if err != nil {
......
...@@ -181,7 +181,7 @@ func Setup(ctx context.Context, config *daemonconfig.Node, proxy proxy.Proxy) er ...@@ -181,7 +181,7 @@ func Setup(ctx context.Context, config *daemonconfig.Node, proxy proxy.Proxy) er
func (a *agentTunnel) setKubeletPort(ctx context.Context, apiServerReady <-chan struct{}) { func (a *agentTunnel) setKubeletPort(ctx context.Context, apiServerReady <-chan struct{}) {
<-apiServerReady <-apiServerReady
wait.PollImmediateWithContext(ctx, time.Second, util.DefaultAPIServerReadyTimeout, func(ctx context.Context) (bool, error) { wait.PollUntilContextTimeout(ctx, time.Second, util.DefaultAPIServerReadyTimeout, true, func(ctx context.Context) (bool, error) {
var readyTime metav1.Time var readyTime metav1.Time
nodeName := os.Getenv("NODE_NAME") nodeName := os.Getenv("NODE_NAME")
node, err := a.client.CoreV1().Nodes().Get(ctx, nodeName, metav1.GetOptions{}) node, err := a.client.CoreV1().Nodes().Get(ctx, nodeName, metav1.GetOptions{})
......
...@@ -27,7 +27,7 @@ import ( ...@@ -27,7 +27,7 @@ import (
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
utilfeature "k8s.io/apiserver/pkg/util/feature" utilfeature "k8s.io/apiserver/pkg/util/feature"
"k8s.io/client-go/util/retry" "k8s.io/client-go/util/retry"
ccmapp "k8s.io/cloud-provider/app" "k8s.io/cloud-provider/names"
servicehelper "k8s.io/cloud-provider/service/helpers" servicehelper "k8s.io/cloud-provider/service/helpers"
"k8s.io/kubernetes/pkg/features" "k8s.io/kubernetes/pkg/features"
utilsnet "k8s.io/utils/net" utilsnet "k8s.io/utils/net"
...@@ -42,7 +42,7 @@ var ( ...@@ -42,7 +42,7 @@ var (
daemonsetNodePoolLabel = "svccontroller." + version.Program + ".cattle.io/lbpool" daemonsetNodePoolLabel = "svccontroller." + version.Program + ".cattle.io/lbpool"
nodeSelectorLabel = "svccontroller." + version.Program + ".cattle.io/nodeselector" nodeSelectorLabel = "svccontroller." + version.Program + ".cattle.io/nodeselector"
priorityAnnotation = "svccontroller." + version.Program + ".cattle.io/priorityclassname" priorityAnnotation = "svccontroller." + version.Program + ".cattle.io/priorityclassname"
controllerName = ccmapp.DefaultInitFuncConstructors["service"].InitContext.ClientName controllerName = names.ServiceLBController
) )
const ( const (
...@@ -52,7 +52,7 @@ const ( ...@@ -52,7 +52,7 @@ const (
) )
var ( var (
DefaultLBImage = "rancher/klipper-lb:v0.4.7" DefaultLBImage = "rancher/klipper-lb:v0.4.9"
) )
func (k *k3s) Register(ctx context.Context, func (k *k3s) Register(ctx context.Context,
...@@ -437,12 +437,19 @@ func (k *k3s) newDaemonSet(svc *core.Service) (*apps.DaemonSet, error) { ...@@ -437,12 +437,19 @@ func (k *k3s) newDaemonSet(svc *core.Service) (*apps.DaemonSet, error) {
return nil, err return nil, err
} }
sourceRanges := strings.Join(sourceRangesSet.StringSlice(), ",") sourceRanges := strings.Join(sourceRangesSet.StringSlice(), ",")
securityContext := &core.PodSecurityContext{}
for _, ipFamily := range svc.Spec.IPFamilies { for _, ipFamily := range svc.Spec.IPFamilies {
if ipFamily == core.IPv6Protocol && sourceRanges == "0.0.0.0/0" { switch ipFamily {
// The upstream default load-balancer source range only includes IPv4, even if the service is IPv6-only or dual-stack. case core.IPv4Protocol:
// If using the default range, and IPv6 is enabled, also allow IPv6. securityContext.Sysctls = append(securityContext.Sysctls, core.Sysctl{Name: "net.ipv4.ip_forward", Value: "1"})
sourceRanges += ",::/0" case core.IPv6Protocol:
securityContext.Sysctls = append(securityContext.Sysctls, core.Sysctl{Name: "net.ipv6.conf.all.forwarding", Value: "1"})
if sourceRanges == "0.0.0.0/0" {
// The upstream default load-balancer source range only includes IPv4, even if the service is IPv6-only or dual-stack.
// If using the default range, and IPv6 is enabled, also allow IPv6.
sourceRanges += ",::/0"
}
} }
} }
...@@ -478,12 +485,7 @@ func (k *k3s) newDaemonSet(svc *core.Service) (*apps.DaemonSet, error) { ...@@ -478,12 +485,7 @@ func (k *k3s) newDaemonSet(svc *core.Service) (*apps.DaemonSet, error) {
PriorityClassName: priorityClassName, PriorityClassName: priorityClassName,
ServiceAccountName: "svclb", ServiceAccountName: "svclb",
AutomountServiceAccountToken: utilsptr.To(false), AutomountServiceAccountToken: utilsptr.To(false),
SecurityContext: &core.PodSecurityContext{ SecurityContext: securityContext,
Sysctls: []core.Sysctl{
{Name: "net.ipv4.ip_forward", Value: "1"},
{Name: "net.ipv6.conf.all.forwarding", Value: "1"},
},
},
Tolerations: []core.Toleration{ Tolerations: []core.Toleration{
{ {
Key: util.MasterRoleLabelKey, Key: util.MasterRoleLabelKey,
...@@ -699,7 +701,17 @@ func (k *k3s) getPriorityClassName(svc *core.Service) string { ...@@ -699,7 +701,17 @@ func (k *k3s) getPriorityClassName(svc *core.Service) string {
// generateName generates a distinct name for the DaemonSet based on the service name and UID // generateName generates a distinct name for the DaemonSet based on the service name and UID
func generateName(svc *core.Service) string { func generateName(svc *core.Service) string {
return fmt.Sprintf("svclb-%s-%s", svc.Name, svc.UID[:8]) name := svc.Name
// ensure that the service name plus prefix and uuid aren't overly long, but
// don't cut the service name at a trailing hyphen.
if len(name) > 48 {
trimlen := 48
for name[trimlen-1] == '-' {
trimlen--
}
name = name[0:trimlen]
}
return fmt.Sprintf("svclb-%s-%s", name, svc.UID[:8])
} }
// ingressToString converts a list of LoadBalancerIngress entries to strings // ingressToString converts a list of LoadBalancerIngress entries to strings
......
...@@ -6,6 +6,8 @@ import ( ...@@ -6,6 +6,8 @@ import (
"testing" "testing"
core "k8s.io/api/core/v1" core "k8s.io/api/core/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
) )
const ( const (
...@@ -111,3 +113,50 @@ func Test_UnitFilterByIPFamily_Ordering(t *testing.T) { ...@@ -111,3 +113,50 @@ func Test_UnitFilterByIPFamily_Ordering(t *testing.T) {
t.Errorf("filterByIPFamily() = %+v\nWant = %+v", got, want) t.Errorf("filterByIPFamily() = %+v\nWant = %+v", got, want)
} }
} }
func Test_UnitGenerateName(t *testing.T) {
uid := types.UID("35a5ccb3-4a82-40b7-8d83-cda9582e4251")
tests := []struct {
name string
svc *core.Service
want string
}{
{
name: "Short name",
svc: &core.Service{
ObjectMeta: meta.ObjectMeta{
Name: "a-service",
UID: uid,
},
},
want: "svclb-a-service-35a5ccb3",
},
{
name: "Long name",
svc: &core.Service{
ObjectMeta: meta.ObjectMeta{
Name: "a-service-with-a-very-veeeeeery-long-yet-valid-name",
UID: uid,
},
},
want: "svclb-a-service-with-a-very-veeeeeery-long-yet-valid-n-35a5ccb3",
},
{
name: "Long hypenated name",
svc: &core.Service{
ObjectMeta: meta.ObjectMeta{
Name: "a-service-with-a-name-with-inconvenient------------hypens",
UID: uid,
},
},
want: "svclb-a-service-with-a-name-with-inconvenient-35a5ccb3",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := generateName(tt.svc); got != tt.want {
t.Errorf("generateName() = %+v\nWant = %+v", got, tt.want)
}
})
}
}
...@@ -123,7 +123,7 @@ func (c *Cluster) Start(ctx context.Context) (<-chan struct{}, error) { ...@@ -123,7 +123,7 @@ func (c *Cluster) Start(ctx context.Context) (<-chan struct{}, error) {
} }
if !c.config.EtcdDisableSnapshots { if !c.config.EtcdDisableSnapshots {
wait.PollImmediateUntilWithContext(ctx, time.Second, func(ctx context.Context) (bool, error) { _ = wait.PollUntilContextCancel(ctx, time.Second, true, func(ctx context.Context) (bool, error) {
err := c.managedDB.ReconcileSnapshotData(ctx) err := c.managedDB.ReconcileSnapshotData(ctx)
if err != nil { if err != nil {
logrus.Errorf("Failed to record snapshots for cluster: %v", err) logrus.Errorf("Failed to record snapshots for cluster: %v", err)
......
...@@ -136,7 +136,7 @@ func (c *Cluster) setupEtcdProxy(ctx context.Context, etcdProxy etcd.Proxy) { ...@@ -136,7 +136,7 @@ func (c *Cluster) setupEtcdProxy(ctx context.Context, etcdProxy etcd.Proxy) {
return return
} }
// We use Poll here instead of Until because we want to wait the interval before running the function. // We use Poll here instead of Until because we want to wait the interval before running the function.
go wait.PollUntilWithContext(ctx, 30*time.Second, func(ctx context.Context) (bool, error) { go wait.PollUntilContextCancel(ctx, 30*time.Second, false, func(ctx context.Context) (bool, error) {
clientURLs, err := c.managedDB.GetMembersClientURLs(ctx) clientURLs, err := c.managedDB.GetMembersClientURLs(ctx)
if err != nil { if err != nil {
logrus.Warnf("Failed to get etcd ClientURLs: %v", err) logrus.Warnf("Failed to get etcd ClientURLs: %v", err)
......
...@@ -39,7 +39,7 @@ func RotateBootstrapToken(ctx context.Context, config *config.Control, oldToken ...@@ -39,7 +39,7 @@ func RotateBootstrapToken(ctx context.Context, config *config.Control, oldToken
tokenKey := storageKey(normalizedToken) tokenKey := storageKey(normalizedToken)
var bootstrapList []client.Value var bootstrapList []client.Value
if err := wait.PollImmediateUntilWithContext(ctx, 5*time.Second, func(ctx context.Context) (bool, error) { if err := wait.PollUntilContextCancel(ctx, 5*time.Second, true, func(ctx context.Context) (bool, error) {
bootstrapList, err = storageClient.List(ctx, "/bootstrap", 0) bootstrapList, err = storageClient.List(ctx, "/bootstrap", 0)
if err != nil { if err != nil {
return false, err return false, err
...@@ -198,7 +198,7 @@ func (c *Cluster) storageBootstrap(ctx context.Context) error { ...@@ -198,7 +198,7 @@ func (c *Cluster) storageBootstrap(ctx context.Context) error {
attempts := 0 attempts := 0
tokenKey := storageKey(normalizedToken) tokenKey := storageKey(normalizedToken)
return wait.PollImmediateUntilWithContext(ctx, time.Second, func(ctx context.Context) (bool, error) { return wait.PollUntilContextCancel(ctx, time.Second, true, func(ctx context.Context) (bool, error) {
attempts++ attempts++
value, saveBootstrap, err := getBootstrapKeyFromStorage(ctx, storageClient, normalizedToken, token) value, saveBootstrap, err := getBootstrapKeyFromStorage(ctx, storageClient, normalizedToken, token)
c.saveBootstrap = saveBootstrap c.saveBootstrap = saveBootstrap
...@@ -258,7 +258,7 @@ func getBootstrapKeyFromStorage(ctx context.Context, storageClient client.Client ...@@ -258,7 +258,7 @@ func getBootstrapKeyFromStorage(ctx context.Context, storageClient client.Client
var bootstrapList []client.Value var bootstrapList []client.Value
var err error var err error
if err := wait.PollImmediateUntilWithContext(ctx, 5*time.Second, func(ctx context.Context) (bool, error) { if err := wait.PollUntilContextCancel(ctx, 5*time.Second, true, func(ctx context.Context) (bool, error) {
bootstrapList, err = storageClient.List(ctx, "/bootstrap", 0) bootstrapList, err = storageClient.List(ctx, "/bootstrap", 0)
if err != nil { if err != nil {
if errors.Is(err, rpctypes.ErrGPRCNotSupportedForLearner) { if errors.Is(err, rpctypes.ErrGPRCNotSupportedForLearner) {
......
...@@ -482,7 +482,7 @@ func (e *ETCD) Start(ctx context.Context, clientAccessInfo *clientaccess.Info) e ...@@ -482,7 +482,7 @@ func (e *ETCD) Start(ctx context.Context, clientAccessInfo *clientaccess.Info) e
case <-time.After(30 * time.Second): case <-time.After(30 * time.Second):
logrus.Infof("Waiting for container runtime to become ready before joining etcd cluster") logrus.Infof("Waiting for container runtime to become ready before joining etcd cluster")
case <-e.config.Runtime.ContainerRuntimeReady: case <-e.config.Runtime.ContainerRuntimeReady:
if err := wait.PollImmediateUntilWithContext(ctx, time.Second, func(ctx context.Context) (bool, error) { if err := wait.PollUntilContextCancel(ctx, time.Second, true, func(ctx context.Context) (bool, error) {
if err := e.join(ctx, clientAccessInfo); err != nil { if err := e.join(ctx, clientAccessInfo); err != nil {
// Retry the join if waiting for another member to be promoted, or waiting for peers to connect after promotion // Retry the join if waiting for another member to be promoted, or waiting for peers to connect after promotion
if errors.Is(err, rpctypes.ErrTooManyLearners) || errors.Is(err, rpctypes.ErrUnhealthy) { if errors.Is(err, rpctypes.ErrTooManyLearners) || errors.Is(err, rpctypes.ErrUnhealthy) {
......
...@@ -32,13 +32,16 @@ import ( ...@@ -32,13 +32,16 @@ import (
apierrors "k8s.io/apimachinery/pkg/api/errors" apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
k8sruntime "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/tools/pager"
"k8s.io/client-go/util/retry" "k8s.io/client-go/util/retry"
) )
const ( const (
errorTTL = 24 * time.Hour errorTTL = 24 * time.Hour
snapshotListPageSize = 20
) )
var ( var (
...@@ -720,18 +723,20 @@ func (e *ETCD) ReconcileSnapshotData(ctx context.Context) error { ...@@ -720,18 +723,20 @@ func (e *ETCD) ReconcileSnapshotData(ctx context.Context) error {
return err return err
} }
// List all snapshots matching the selector
snapshots := e.config.Runtime.K3s.K3s().V1().ETCDSnapshotFile() snapshots := e.config.Runtime.K3s.K3s().V1().ETCDSnapshotFile()
esfList, err := snapshots.List(metav1.ListOptions{LabelSelector: selector.String()}) snapshotPager := pager.New(pager.SimplePageFunc(func(opts metav1.ListOptions) (k8sruntime.Object, error) { return snapshots.List(opts) }))
if err != nil { snapshotPager.PageSize = snapshotListPageSize
return err
}
// List all snapshots matching the selector
// If a snapshot from Kubernetes was found on disk/s3, it is in sync and we can remove it from the map to sync. // If a snapshot from Kubernetes was found on disk/s3, it is in sync and we can remove it from the map to sync.
// If a snapshot from Kubernetes was not found on disk/s3, is is gone and can be removed from Kubernetes. // If a snapshot from Kubernetes was not found on disk/s3, is is gone and can be removed from Kubernetes.
// The one exception to the last rule is failed snapshots - these must be retained for a period of time. // The one exception to the last rule is failed snapshots - these must be retained for a period of time.
for _, esf := range esfList.Items { if err := snapshotPager.EachListItem(ctx, metav1.ListOptions{LabelSelector: selector.String()}, func(obj k8sruntime.Object) error {
sfKey := generateETCDSnapshotFileConfigMapKey(esf) esf, ok := obj.(*k3s.ETCDSnapshotFile)
if !ok {
return errors.New("failed to convert object to ETCDSnapshotFile")
}
sfKey := generateETCDSnapshotFileConfigMapKey(*esf)
logrus.Debugf("Found ETCDSnapshotFile for %s with key %s", esf.Spec.SnapshotName, sfKey) logrus.Debugf("Found ETCDSnapshotFile for %s with key %s", esf.Spec.SnapshotName, sfKey)
if sf, ok := snapshotFiles[sfKey]; ok && sf.GenerateName() == esf.Name { if sf, ok := snapshotFiles[sfKey]; ok && sf.GenerateName() == esf.Name {
// exists in both and names match, don't need to sync // exists in both and names match, don't need to sync
...@@ -741,7 +746,7 @@ func (e *ETCD) ReconcileSnapshotData(ctx context.Context) error { ...@@ -741,7 +746,7 @@ func (e *ETCD) ReconcileSnapshotData(ctx context.Context) error {
if esf.Status.Error != nil && esf.Status.Error.Time != nil { if esf.Status.Error != nil && esf.Status.Error.Time != nil {
expires := esf.Status.Error.Time.Add(errorTTL) expires := esf.Status.Error.Time.Add(errorTTL)
if time.Now().Before(expires) { if time.Now().Before(expires) {
continue return nil
} }
} }
if ok { if ok {
...@@ -754,6 +759,9 @@ func (e *ETCD) ReconcileSnapshotData(ctx context.Context) error { ...@@ -754,6 +759,9 @@ func (e *ETCD) ReconcileSnapshotData(ctx context.Context) error {
logrus.Errorf("Failed to delete ETCDSnapshotFile: %v", err) logrus.Errorf("Failed to delete ETCDSnapshotFile: %v", err)
} }
} }
return nil
}); err != nil {
return err
} }
// Any snapshots remaining in the map from disk/s3 were not found in Kubernetes and need to be created // Any snapshots remaining in the map from disk/s3 were not found in Kubernetes and need to be created
...@@ -794,15 +802,18 @@ func (e *ETCD) ReconcileSnapshotData(ctx context.Context) error { ...@@ -794,15 +802,18 @@ func (e *ETCD) ReconcileSnapshotData(ctx context.Context) error {
} }
// List and remove all snapshots stored on nodes that do not match the selector // List and remove all snapshots stored on nodes that do not match the selector
esfList, err = snapshots.List(metav1.ListOptions{LabelSelector: selector.String()}) if err := snapshotPager.EachListItem(ctx, metav1.ListOptions{LabelSelector: selector.String()}, func(obj k8sruntime.Object) error {
if err != nil { esf, ok := obj.(*k3s.ETCDSnapshotFile)
return err if !ok {
} return errors.New("failed to convert object to ETCDSnapshotFile")
}
for _, esf := range esfList.Items {
if err := snapshots.Delete(esf.Name, &metav1.DeleteOptions{}); err != nil { if err := snapshots.Delete(esf.Name, &metav1.DeleteOptions{}); err != nil {
logrus.Errorf("Failed to delete ETCDSnapshotFile for non-etcd node %s: %v", esf.Spec.NodeName, err) logrus.Errorf("Failed to delete ETCDSnapshotFile for non-etcd node %s: %v", esf.Spec.NodeName, err)
} }
return nil
}); err != nil {
return err
} }
// Update our Node object to note the timestamp of the snapshot storages that have been reconciled // Update our Node object to note the timestamp of the snapshot storages that have been reconciled
......
...@@ -9,6 +9,7 @@ import ( ...@@ -9,6 +9,7 @@ import (
"time" "time"
apisv1 "github.com/k3s-io/k3s/pkg/apis/k3s.cattle.io/v1" apisv1 "github.com/k3s-io/k3s/pkg/apis/k3s.cattle.io/v1"
k3s "github.com/k3s-io/k3s/pkg/apis/k3s.cattle.io/v1"
"github.com/k3s-io/k3s/pkg/etcd/snapshot" "github.com/k3s-io/k3s/pkg/etcd/snapshot"
controllersv1 "github.com/k3s-io/k3s/pkg/generated/controllers/k3s.cattle.io/v1" controllersv1 "github.com/k3s-io/k3s/pkg/generated/controllers/k3s.cattle.io/v1"
"github.com/k3s-io/k3s/pkg/util" "github.com/k3s-io/k3s/pkg/util"
...@@ -20,7 +21,9 @@ import ( ...@@ -20,7 +21,9 @@ import (
apierrors "k8s.io/apimachinery/pkg/api/errors" apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
k8sruntime "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/tools/pager"
"k8s.io/client-go/util/retry" "k8s.io/client-go/util/retry"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
...@@ -216,20 +219,25 @@ func (e *etcdSnapshotHandler) reconcile() error { ...@@ -216,20 +219,25 @@ func (e *etcdSnapshotHandler) reconcile() error {
logrus.Infof("Reconciling snapshot ConfigMap data") logrus.Infof("Reconciling snapshot ConfigMap data")
// Get a list of existing snapshots // Get a list of existing snapshots
snapshotList, err := e.snapshots.List(metav1.ListOptions{})
if err != nil {
return err
}
snapshots := map[string]*apisv1.ETCDSnapshotFile{} snapshots := map[string]*apisv1.ETCDSnapshotFile{}
for i := range snapshotList.Items { snapshotPager := pager.New(pager.SimplePageFunc(func(opts metav1.ListOptions) (k8sruntime.Object, error) { return e.snapshots.List(opts) }))
esf := &snapshotList.Items[i] snapshotPager.PageSize = snapshotListPageSize
if err := snapshotPager.EachListItem(e.ctx, metav1.ListOptions{}, func(obj k8sruntime.Object) error {
esf, ok := obj.(*k3s.ETCDSnapshotFile)
if !ok {
return errors.New("failed to convert object to ETCDSnapshotFile")
}
// Do not create entries for snapshots that have been deleted or do not have extra metadata // Do not create entries for snapshots that have been deleted or do not have extra metadata
if !esf.DeletionTimestamp.IsZero() || len(esf.Spec.Metadata) == 0 { if !esf.DeletionTimestamp.IsZero() || len(esf.Spec.Metadata) == 0 {
continue return nil
} }
sfKey := generateETCDSnapshotFileConfigMapKey(*esf) sfKey := generateETCDSnapshotFileConfigMapKey(*esf)
snapshots[sfKey] = esf snapshots[sfKey] = esf
return nil
}); err != nil {
return err
} }
snapshotConfigMap, err := e.configmaps.Get(metav1.NamespaceSystem, snapshotConfigMapName, metav1.GetOptions{}) snapshotConfigMap, err := e.configmaps.Get(metav1.NamespaceSystem, snapshotConfigMapName, metav1.GetOptions{})
......
...@@ -8,6 +8,7 @@ import ( ...@@ -8,6 +8,7 @@ import (
"github.com/k3s-io/k3s/pkg/agent/https" "github.com/k3s-io/k3s/pkg/agent/https"
"github.com/k3s-io/k3s/pkg/daemons/config" "github.com/k3s-io/k3s/pkg/daemons/config"
"github.com/prometheus/client_golang/prometheus/promhttp" "github.com/prometheus/client_golang/prometheus/promhttp"
lassometrics "github.com/rancher/lasso/pkg/metrics"
"k8s.io/component-base/metrics/legacyregistry" "k8s.io/component-base/metrics/legacyregistry"
) )
...@@ -28,6 +29,11 @@ var DefaultMetrics = &Config{ ...@@ -28,6 +29,11 @@ var DefaultMetrics = &Config{
}, },
} }
func init() {
// ensure that lasso exposes metrics through the same registry used by Kubernetes components
lassometrics.MustRegister(DefaultRegisterer)
}
// Config holds fields for the metrics listener // Config holds fields for the metrics listener
type Config struct { type Config struct {
// Router will be called to add the metrics API handler to an existing router. // Router will be called to add the metrics API handler to an existing router.
......
...@@ -198,8 +198,9 @@ func WriteEncryptionHashAnnotation(runtime *config.ControlRuntime, node *corev1. ...@@ -198,8 +198,9 @@ func WriteEncryptionHashAnnotation(runtime *config.ControlRuntime, node *corev1.
// WaitForEncryptionConfigReload watches the metrics API, polling the latest time the encryption config was reloaded. // WaitForEncryptionConfigReload watches the metrics API, polling the latest time the encryption config was reloaded.
func WaitForEncryptionConfigReload(runtime *config.ControlRuntime, reloadSuccesses, reloadTime int64) error { func WaitForEncryptionConfigReload(runtime *config.ControlRuntime, reloadSuccesses, reloadTime int64) error {
var lastFailure string var lastFailure string
err := wait.PollImmediate(5*time.Second, 60*time.Second, func() (bool, error) {
ctx := context.Background()
err := wait.PollUntilContextTimeout(ctx, 5*time.Second, 60*time.Second, true, func(ctx context.Context) (bool, error) {
newReloadTime, newReloadSuccess, err := GetEncryptionConfigMetrics(runtime, false) newReloadTime, newReloadSuccess, err := GetEncryptionConfigMetrics(runtime, false)
if err != nil { if err != nil {
return true, err return true, err
...@@ -238,8 +239,9 @@ func GetEncryptionConfigMetrics(runtime *config.ControlRuntime, initialMetrics b ...@@ -238,8 +239,9 @@ func GetEncryptionConfigMetrics(runtime *config.ControlRuntime, initialMetrics b
// This is wrapped in a poller because on startup no metrics exist. Its only after the encryption config // This is wrapped in a poller because on startup no metrics exist. Its only after the encryption config
// is modified and the first reload occurs that the metrics are available. // is modified and the first reload occurs that the metrics are available.
err = wait.PollImmediate(5*time.Second, 60*time.Second, func() (bool, error) { ctx := context.Background()
data, err := restClient.Get().AbsPath("/metrics").DoRaw(context.TODO()) err = wait.PollUntilContextTimeout(ctx, 5*time.Second, 60*time.Second, true, func(ctx context.Context) (bool, error) {
data, err := restClient.Get().AbsPath("/metrics").DoRaw(ctx)
if err != nil { if err != nil {
return true, err return true, err
} }
......
...@@ -2,6 +2,7 @@ package secretsencrypt ...@@ -2,6 +2,7 @@ package secretsencrypt
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
"strings" "strings"
...@@ -12,7 +13,6 @@ import ( ...@@ -12,7 +13,6 @@ import (
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
corev1 "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors" apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
...@@ -30,6 +30,8 @@ const ( ...@@ -30,6 +30,8 @@ const (
secretsProgressEvent string = "SecretsProgress" secretsProgressEvent string = "SecretsProgress"
secretsUpdateCompleteEvent string = "SecretsUpdateComplete" secretsUpdateCompleteEvent string = "SecretsUpdateComplete"
secretsUpdateErrorEvent string = "SecretsUpdateError" secretsUpdateErrorEvent string = "SecretsUpdateError"
secretListPageSize = 20
) )
type handler struct { type handler struct {
...@@ -116,7 +118,7 @@ func (h *handler) onChangeNode(nodeName string, node *corev1.Node) (*corev1.Node ...@@ -116,7 +118,7 @@ func (h *handler) onChangeNode(nodeName string, node *corev1.Node) (*corev1.Node
return node, err return node, err
} }
if err := h.updateSecrets(node); err != nil { if err := h.updateSecrets(nodeRef); err != nil {
h.recorder.Event(nodeRef, corev1.EventTypeWarning, secretsUpdateErrorEvent, err.Error()) h.recorder.Event(nodeRef, corev1.EventTypeWarning, secretsUpdateErrorEvent, err.Error())
return node, err return node, err
} }
...@@ -213,36 +215,30 @@ func (h *handler) validateReencryptStage(node *corev1.Node, annotation string) ( ...@@ -213,36 +215,30 @@ func (h *handler) validateReencryptStage(node *corev1.Node, annotation string) (
return true, nil return true, nil
} }
func (h *handler) updateSecrets(node *corev1.Node) error { func (h *handler) updateSecrets(nodeRef *corev1.ObjectReference) error {
nodeRef := &corev1.ObjectReference{
Kind: "Node",
Name: node.Name,
UID: types.UID(node.Name),
Namespace: "",
}
secretPager := pager.New(pager.SimplePageFunc(func(opts metav1.ListOptions) (runtime.Object, error) { secretPager := pager.New(pager.SimplePageFunc(func(opts metav1.ListOptions) (runtime.Object, error) {
return h.secrets.List("", opts) return h.secrets.List(metav1.NamespaceAll, opts)
})) }))
secretsList, _, err := secretPager.List(h.ctx, metav1.ListOptions{}) secretPager.PageSize = secretListPageSize
if err != nil {
return err
}
i := 0 i := 0
err = meta.EachListItem(secretsList, func(obj runtime.Object) error { if err := secretPager.EachListItem(h.ctx, metav1.ListOptions{}, func(obj runtime.Object) error {
if secret, ok := obj.(*corev1.Secret); ok { secret, ok := obj.(*corev1.Secret)
if _, err := h.secrets.Update(secret); err != nil && !apierrors.IsConflict(err) { if !ok {
return fmt.Errorf("failed to update secret: %v", err) return errors.New("failed to convert object to Secret")
} }
if i != 0 && i%10 == 0 { if _, err := h.secrets.Update(secret); err != nil && !apierrors.IsConflict(err) {
h.recorder.Eventf(nodeRef, corev1.EventTypeNormal, secretsProgressEvent, "reencrypted %d secrets", i) return fmt.Errorf("failed to update secret: %v", err)
}
i++
} }
if i != 0 && i%10 == 0 {
h.recorder.Eventf(nodeRef, corev1.EventTypeNormal, secretsProgressEvent, "reencrypted %d secrets", i)
}
i++
return nil return nil
}) }); err != nil {
if err != nil {
return err return err
} }
h.recorder.Eventf(nodeRef, corev1.EventTypeNormal, secretsUpdateCompleteEvent, "completed reencrypt of %d secrets", i) h.recorder.Eventf(nodeRef, corev1.EventTypeNormal, secretsUpdateCompleteEvent, "completed reencrypt of %d secrets", i)
return nil return nil
} }
...@@ -502,7 +502,7 @@ func verifyNode(ctx context.Context, nodeClient coreclient.NodeController, node ...@@ -502,7 +502,7 @@ func verifyNode(ctx context.Context, nodeClient coreclient.NodeController, node
func ensureSecret(ctx context.Context, config *Config, node *nodeInfo) { func ensureSecret(ctx context.Context, config *Config, node *nodeInfo) {
runtime := config.ControlConfig.Runtime runtime := config.ControlConfig.Runtime
wait.PollImmediateUntilWithContext(ctx, time.Second*5, func(ctx context.Context) (bool, error) { _ = wait.PollUntilContextCancel(ctx, time.Second*5, true, func(ctx context.Context) (bool, error) {
if runtime.Core != nil { if runtime.Core != nil {
secretClient := runtime.Core.Core().V1().Secret() secretClient := runtime.Core.Core().V1().Secret()
// This is consistent with events attached to the node generated by the kubelet // This is consistent with events attached to the node generated by the kubelet
......
...@@ -103,7 +103,7 @@ func NewServerBootstrapper(controlConfig *config.Control) routing.Bootstrapper { ...@@ -103,7 +103,7 @@ func NewServerBootstrapper(controlConfig *config.Control) routing.Bootstrapper {
func (s *serverBootstrapper) Run(_ context.Context, id string) error { func (s *serverBootstrapper) Run(_ context.Context, id string) error {
s.controlConfig.Runtime.ClusterControllerStarts["spegel-p2p"] = func(ctx context.Context) { s.controlConfig.Runtime.ClusterControllerStarts["spegel-p2p"] = func(ctx context.Context) {
nodes := s.controlConfig.Runtime.Core.Core().V1().Node() nodes := s.controlConfig.Runtime.Core.Core().V1().Node()
wait.PollImmediateUntilWithContext(ctx, 1*time.Second, func(ctx context.Context) (bool, error) { _ = wait.PollUntilContextCancel(ctx, 1*time.Second, true, func(ctx context.Context) (bool, error) {
nodeName := os.Getenv("NODE_NAME") nodeName := os.Getenv("NODE_NAME")
if nodeName == "" { if nodeName == "" {
return false, nil return false, nil
......
...@@ -236,7 +236,7 @@ func (c *Config) Start(ctx context.Context, nodeConfig *config.Node) error { ...@@ -236,7 +236,7 @@ func (c *Config) Start(ctx context.Context, nodeConfig *config.Node) error {
// Wait up to 5 seconds for the p2p network to find peers. This will return // Wait up to 5 seconds for the p2p network to find peers. This will return
// immediately if the node is bootstrapping from itself. // immediately if the node is bootstrapping from itself.
wait.PollImmediateWithContext(ctx, time.Second, resolveTimeout, func(_ context.Context) (bool, error) { _ = wait.PollUntilContextTimeout(ctx, time.Second, resolveTimeout, true, func(_ context.Context) (bool, error) {
return router.Ready() return router.Ready()
}) })
......
...@@ -80,7 +80,7 @@ func WaitForAPIServerReady(ctx context.Context, kubeconfigPath string, timeout t ...@@ -80,7 +80,7 @@ func WaitForAPIServerReady(ctx context.Context, kubeconfigPath string, timeout t
return err return err
} }
err = wait.PollImmediateWithContext(ctx, time.Second, timeout, func(ctx context.Context) (bool, error) { err = wait.PollUntilContextTimeout(ctx, time.Second, timeout, true, func(ctx context.Context) (bool, error) {
healthStatus := 0 healthStatus := 0
result := restClient.Get().AbsPath("/readyz").Do(ctx).StatusCode(&healthStatus) result := restClient.Get().AbsPath("/readyz").Do(ctx).StatusCode(&healthStatus)
if rerr := result.Error(); rerr != nil { if rerr := result.Error(); rerr != nil {
...@@ -128,7 +128,7 @@ func WaitForRBACReady(ctx context.Context, kubeconfigPath string, timeout time.D ...@@ -128,7 +128,7 @@ func WaitForRBACReady(ctx context.Context, kubeconfigPath string, timeout time.D
reviewFunc = subjectAccessReview(authClient, ra, user, groups) reviewFunc = subjectAccessReview(authClient, ra, user, groups)
} }
err = wait.PollImmediateWithContext(ctx, time.Second, timeout, func(ctx context.Context) (bool, error) { err = wait.PollUntilContextTimeout(ctx, time.Second, timeout, true, func(ctx context.Context) (bool, error) {
status, rerr := reviewFunc(ctx) status, rerr := reviewFunc(ctx)
if rerr != nil { if rerr != nil {
lastErr = rerr lastErr = rerr
......
docker.io/rancher/klipper-helm:v0.8.4-build20240523 docker.io/rancher/klipper-helm:v0.8.4-build20240523
docker.io/rancher/klipper-lb:v0.4.7 docker.io/rancher/klipper-lb:v0.4.9
docker.io/rancher/local-path-provisioner:v0.0.28 docker.io/rancher/local-path-provisioner:v0.0.28
docker.io/rancher/mirrored-coredns-coredns:1.10.1 docker.io/rancher/mirrored-coredns-coredns:1.10.1
docker.io/rancher/mirrored-library-busybox:1.36.1 docker.io/rancher/mirrored-library-busybox:1.36.1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment