Skip to content

Commit

Permalink
fix: Adding periodic check to fix the sporadic failures of the operat…
Browse files Browse the repository at this point in the history
…or e2e tests. (#4952)

Adding a delay to check if the pods are available. this fix is expected to solve sporadic failures of test cases.

Signed-off-by: lrangine <[email protected]>
  • Loading branch information
lokeshrangineni authored Jan 22, 2025
1 parent cb81939 commit 1d086be
Showing 1 changed file with 41 additions and 28 deletions.
69 changes: 41 additions & 28 deletions infra/feast-operator/test/e2e/test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,40 +157,53 @@ func checkIfKubernetesServiceExists(namespace, serviceName string) error {
}

func isFeatureStoreHavingRemoteRegistry(namespace, featureStoreName string) (bool, error) {
cmd := exec.Command("kubectl", "get", "featurestore", featureStoreName, "-n", namespace,
"-o=jsonpath='{.status.applied.services.registry}'")
timeout := time.Second * 30
interval := time.Second * 2 // Poll every 2 seconds
startTime := time.Now()

for time.Since(startTime) < timeout {
cmd := exec.Command("kubectl", "get", "featurestore", featureStoreName, "-n", namespace,
"-o=jsonpath='{.status.applied.services.registry}'")

output, err := cmd.Output()
if err != nil {
// Retry only on transient errors
if _, ok := err.(*exec.ExitError); ok {
time.Sleep(interval)
continue
}
return false, err // Return immediately on non-transient errors
}

// Capture the output
output, err := cmd.Output()
if err != nil {
return false, err // Return false on command execution failure
}
// Convert output to string and trim any extra spaces
result := strings.TrimSpace(string(output))

// Convert output to string and trim any extra spaces
result := strings.TrimSpace(string(output))
// Remove single quotes if present
if strings.HasPrefix(result, "'") && strings.HasSuffix(result, "'") {
result = strings.Trim(result, "'")
}

// Remove single quotes if present
if strings.HasPrefix(result, "'") && strings.HasSuffix(result, "'") {
result = strings.Trim(result, "'")
}
if result == "" {
time.Sleep(interval) // Retry if result is empty
continue
}

if result == "" {
return false, errors.New("kubectl get featurestore command returned empty output")
}
// Parse the JSON into a map
var registryConfig v1alpha1.Registry
if err := json.Unmarshal([]byte(result), &registryConfig); err != nil {
return false, err // Return false on JSON parsing failure
}

// Parse the JSON into a map
var registryConfig v1alpha1.Registry
if err := json.Unmarshal([]byte(result), &registryConfig); err != nil {
return false, err // Return false on JSON parsing failure
}
if registryConfig.Remote == nil {
return false, nil
}

if registryConfig.Remote == nil {
return false, nil
}
hasHostname := registryConfig.Remote.Hostname != nil
hasValidFeastRef := registryConfig.Remote.FeastRef != nil &&
registryConfig.Remote.FeastRef.Name != ""

hasHostname := registryConfig.Remote.Hostname != nil
hasValidFeastRef := registryConfig.Remote.FeastRef != nil &&
registryConfig.Remote.FeastRef.Name != ""
return hasHostname || hasValidFeastRef, nil
}

return hasHostname || hasValidFeastRef, nil
return false, errors.New("timeout waiting for featurestore registry status to be ready")
}

0 comments on commit 1d086be

Please sign in to comment.