mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-11-01 22:34:14 +00:00
Merge pull request #89032 from tanjunchen/move-GetPodSecretUpdateTimeout
move GetPodSecretUpdateTimeout from framework/utils to test/e2e/framework/pod/
This commit is contained in:
@@ -1020,43 +1020,6 @@ func WaitForAllNodesSchedulable(c clientset.Interface, timeout time.Duration) er
|
||||
)
|
||||
}
|
||||
|
||||
// GetPodSecretUpdateTimeout reuturns the timeout duration for updating pod secret.
|
||||
func GetPodSecretUpdateTimeout(c clientset.Interface) time.Duration {
|
||||
// With SecretManager(ConfigMapManager), we may have to wait up to full sync period +
|
||||
// TTL of secret(configmap) to elapse before the Kubelet projects the update into the
|
||||
// volume and the container picks it up.
|
||||
// So this timeout is based on default Kubelet sync period (1 minute) + maximum TTL for
|
||||
// secret(configmap) that's based on cluster size + additional time as a fudge factor.
|
||||
secretTTL, err := getNodeTTLAnnotationValue(c)
|
||||
if err != nil {
|
||||
Logf("Couldn't get node TTL annotation (using default value of 0): %v", err)
|
||||
}
|
||||
podLogTimeout := 240*time.Second + secretTTL
|
||||
return podLogTimeout
|
||||
}
|
||||
|
||||
func getNodeTTLAnnotationValue(c clientset.Interface) (time.Duration, error) {
|
||||
nodes, err := c.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{})
|
||||
if err != nil || len(nodes.Items) == 0 {
|
||||
return time.Duration(0), fmt.Errorf("Couldn't list any nodes to get TTL annotation: %v", err)
|
||||
}
|
||||
// Since TTL the kubelet is using is stored in node object, for the timeout
|
||||
// purpose we take it from the first node (all of them should be the same).
|
||||
node := &nodes.Items[0]
|
||||
if node.Annotations == nil {
|
||||
return time.Duration(0), fmt.Errorf("No annotations found on the node")
|
||||
}
|
||||
value, ok := node.Annotations[v1.ObjectTTLAnnotationKey]
|
||||
if !ok {
|
||||
return time.Duration(0), fmt.Errorf("No TTL annotation found on the node")
|
||||
}
|
||||
intValue, err := strconv.Atoi(value)
|
||||
if err != nil {
|
||||
return time.Duration(0), fmt.Errorf("Cannot convert TTL annotation from %#v to int", *node)
|
||||
}
|
||||
return time.Duration(intValue) * time.Second, nil
|
||||
}
|
||||
|
||||
// AddOrUpdateLabelOnNode adds the given label key and value to the given node or updates value.
|
||||
func AddOrUpdateLabelOnNode(c clientset.Interface, nodeName string, labelKey, labelValue string) {
|
||||
ExpectNoError(testutils.AddLabelsToNode(c, nodeName, map[string]string{labelKey: labelValue}))
|
||||
|
||||
Reference in New Issue
Block a user