Skip to content

Commit

Permalink
RHOAIENG-3845: Remove requeueing from finalizer (#224)
Browse files Browse the repository at this point in the history
* Remove requeueing from finalizer

* Add namespace deletion test to smoke tests.
  • Loading branch information
ruivieira committed Apr 25, 2024
1 parent b0eeed7 commit 1d15f74
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
5 changes: 2 additions & 3 deletions controllers/trustyaiservice_controller.go
Expand Up @@ -93,9 +93,8 @@ func (r *TrustyAIServiceReconciler) Reconcile(ctx context.Context, req ctrl.Requ
if containsString(instance.Finalizers, finalizerName) {
// The finalizer is present, so we handle external dependency deletion
if err := r.deleteExternalDependency(req.Name, instance, req.Namespace, ctx); err != nil {
// If fail to delete the external dependency here, return with error
// so that it can be retried
return RequeueWithErrorMessage(ctx, err, "Failed to delete external dependencies.")
// Log the error instead of returning it, so we proceed to remove the finalizer without blocking
log.FromContext(ctx).Error(err, "Failed to delete external dependencies, but proceeding with finalizer removal.")
}

// Remove the finalizer from the list and update it.
Expand Down
26 changes: 23 additions & 3 deletions tests/smoke/test_smoke.sh
Expand Up @@ -15,17 +15,27 @@ SERVICE_NAME_2="trustyai-service-tls"
kubectl create namespace "$NAMESPACE"
kubectl apply -f "$CRD_PATH" -n "$NAMESPACE"

log_success() {
local message=$1
echo "$message"
}

log_failure() {
local message=$1
echo "$message"
exit 1
}

# Function to check resource existence
check_resource() {
local resource_type=$1
local resource_name=$2
local namespace=$3

if ! kubectl get "$resource_type" -n "$namespace" | grep -q "$resource_name"; then
echo "❌ Failed to find $resource_type: $resource_name in namespace $namespace"
exit 1
log_failure "Failed to find $resource_type: $resource_name in namespace $namespace"
else
echo "$resource_type: $resource_name found in namespace $namespace"
log_success "$resource_type: $resource_name found in namespace $namespace"
fi
}

Expand All @@ -38,4 +48,14 @@ check_resource service "$SERVICE_NAME_2" "$NAMESPACE"
# Check for the PVC creation
check_resource pvc "$PVC_NAME" "$NAMESPACE"

kubectl delete namespace "$NAMESPACE"

sleep 10

if kubectl get namespace "$NAMESPACE" &> /dev/null; then
log_failure "Namespace $NAMESPACE was not deleted successfully"
else
log_success "Namespace $NAMESPACE has been deleted successfully"
fi

echo "All tests passed successfully."

0 comments on commit 1d15f74

Please sign in to comment.