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

Bug fixes for timeout #1654

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

asn1809
Copy link
Contributor

@asn1809 asn1809 commented Nov 15, 2024

  1. TImeout checks to include the check hook execution as well.
  2. Incorporating review comments pending from Check hook implementation #1649

Signed-off-by: Annaraya Narasagond <[email protected]>
Signed-off-by: Annaraya Narasagond <[email protected]> Annaraya Narasagond <[email protected]>
Signed-off-by: Annaraya Narasagond <[email protected]>
Signed-off-by: Annaraya Narasagond <[email protected]> Annaraya Narasagond <[email protected]>
@asn1809 asn1809 marked this pull request as draft November 15, 2024 19:15
// err := WaitUntilResourceExists(client, resource, nsScopedName, time.Duration(timeout)*time.Second)
// if err != nil {
// return false, err
// }
Copy link
Member

Choose a reason for hiding this comment

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

Why do you keep this as commented code?


return EvaluateCheckHookExp(hook.Chk.Condition, resource)
//return EvaluateCheckHookExp(hook.Chk.Condition, resource)
Copy link
Member

Choose a reason for hiding this comment

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

Why do you keep this commented code?

ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()

ticker := time.NewTicker(pollInterval * time.Millisecond) // Poll every 100 milliseconds
Copy link
Member

Choose a reason for hiding this comment

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

This comment will quickly become stale when we change pollInternal. It is better to remove it.

However polling every 100 millisecond is too much. If we need to check a resource until the resource reach some state, the right way is to watch the resource. Each time the resources changes, you check the desired state.

Until we get a proper watch we can make this more efficient by using a backoff. We can start with short wait internal to be able to detect very short waits quickly (e.g. 10 ms), and double the interval on each retry, until we reach maximum internal (e.g. 10 seconds).

@@ -232,27 +266,27 @@ func compareValues(val1, val2 interface{}, operator string) (bool, error) {
case float64:
v2, ok := val2.(float64)
if !ok {
return false, fmt.Errorf("mismatched types")
return false, fmt.Errorf("mismatched types %T and %T", val1, val2)
Copy link
Member

Choose a reason for hiding this comment

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

This error is not clear - which is the expected value? we can make it clear using:

fmt.Errorf("type mismatch: expected: %T, actual: %T", expected, actual)

Same for other errors bellow.

Signed-off-by: Annaraya Narasagond <[email protected]>
Signed-off-by: Annaraya Narasagond <[email protected]> Annaraya Narasagond <[email protected]>
Signed-off-by: Annaraya Narasagond <[email protected]>
Signed-off-by: Annaraya Narasagond <[email protected]> Annaraya Narasagond <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants