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

Service status declared Ready before pods are running #76

Closed
ruivieira opened this issue Jul 7, 2023 · 1 comment · Fixed by #139
Closed

Service status declared Ready before pods are running #76

ruivieira opened this issue Jul 7, 2023 · 1 comment · Fixed by #139
Assignees
Labels
kind/bug Something isn't working rhods-2.5

Comments

@ruivieira
Copy link
Member

ruivieira commented Jul 7, 2023

  • Add a status.conditions with type: ServiceReady and status: 'True' when service fully deployed
  • Prevent status.ready == 'True' before pods are ready

Validation

Assuming:

  • A namespace called test
  • A TrustyAIService CR named trustyai-service deployed in test
  • The following script ran before the deployment of the CR
#!/bin/bash

NAMESPACE="test"

while true; do
  # Get the 'Available' status of TrustyAIService
  trusty_ai_service_status=$(kubectl get TrustyAIService trustyai-service -n ${NAMESPACE} -o jsonpath='{.status.conditions[?(@.type=="Available")].status}' 2>/dev/null)
  trusty_ai_service_exit_code=$?

  # Get the 'Available' status of the deployment
  deployment_status=$(kubectl get deployment trustyai-service -n ${NAMESPACE} -o jsonpath='{.status.conditions[?(@.type=="Available")].status}' 2>/dev/null)
  deployment_exit_code=$?

  # Check if both statuses are "True" or if any command failed
  if [ "$trusty_ai_service_exit_code" -eq 0 ] && [ "$trusty_ai_service_status" == "True" ] && [ "$deployment_exit_code" -eq 0 ] && [ "$deployment_status" == "True" ]; then
    echo "TrustyAIService: Available, Deployment: Available"
    break # Exit the loop if both are available
  else
    # Default to "Not available" if the kubectl command failed or status is not "True"
    echo "TrustyAIService: ${trusty_ai_service_status:-Not available}, Deployment: ${deployment_status:-Not available}"
  fi

  sleep 1 # Wait for 1 second before checking again
done

It should show that the TrustyAIService is never Available before the Deployment is available.
The output should be similar to:

TrustyAIService: Not available, Deployment: Not available
...
TrustyAIService: Not available, Deployment: False
...
TrustyAIService: Not available, Deployment: True
...
TrustyAIService: Available, Deployment: Available
@ruivieira ruivieira added the kind/bug Something isn't working label Jul 7, 2023
@ruivieira ruivieira self-assigned this Jul 7, 2023
@alexcreasy
Copy link

I've reproduced this in a couple of ways, be aware the pod does spin up within about 15 seconds on an empty cluster, so you have a short window to catch it.

The easiest way is to have a dedicated console window open on the pods page for that namespace and have two console windows open, one ready to create the CR, the other with the command typed out ready to retrieve the CR. If you create and then fetch the CR straight after, you'll see it shows as ready before the pod is fully spun up in your browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working rhods-2.5
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants