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

fix: Adding periodic check to fix the sporadic failures of the operator e2e tests. #4952

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
}
Loading