@@ -385,7 +385,7 @@ func (r *OpenStackDataPlaneNodeSetReconciler) Reconcile(ctx context.Context, req
385385 }
386386 }
387387
388- isDeploymentReady , isDeploymentRunning , isDeploymentFailed , err := checkDeployment (helper , instance )
388+ isDeploymentReady , isDeploymentRunning , isDeploymentFailed , failedDeployment , err := checkDeployment (helper , instance )
389389 if ! isDeploymentFailed && err != nil {
390390 instance .Status .Conditions .MarkFalse (
391391 condition .DeploymentReadyCondition ,
@@ -436,6 +436,19 @@ func (r *OpenStackDataPlaneNodeSetReconciler) Reconcile(ctx context.Context, req
436436 condition .RequestedReason , condition .SeverityInfo ,
437437 condition .DeploymentReadyRunningMessage )
438438 } else if isDeploymentFailed {
439+ podsInterface := r .Kclient .CoreV1 ().Pods (instance .Namespace )
440+ podsList , _err := podsInterface .List (ctx , v1.ListOptions {
441+ LabelSelector : fmt .Sprintf ("openstackdataplanedeployment=%s" , failedDeployment ),
442+ FieldSelector : "status.phase=Failed" ,
443+ })
444+
445+ if _err != nil {
446+ Log .Error (err , "unable to retrieve list of pods for dataplane diagnostic" )
447+ } else {
448+ for _ , pod := range podsList .Items {
449+ Log .Info (fmt .Sprintf ("openstackansibleee job %s failed due to %s with message: %s" , pod .Name , pod .Status .Reason , pod .Status .Message ))
450+ }
451+ }
439452 Log .Info ("Set NodeSet DeploymentReadyCondition false" )
440453 deployErrorMsg := ""
441454 if err != nil {
@@ -451,16 +464,17 @@ func (r *OpenStackDataPlaneNodeSetReconciler) Reconcile(ctx context.Context, req
451464
452465func checkDeployment (helper * helper.Helper ,
453466 instance * dataplanev1.OpenStackDataPlaneNodeSet ,
454- ) (bool , bool , bool , error ) {
467+ ) (bool , bool , bool , string , error ) {
455468 // Get all completed deployments
469+ var failedDeployment string
456470 deployments := & dataplanev1.OpenStackDataPlaneDeploymentList {}
457471 opts := []client.ListOption {
458472 client .InNamespace (instance .Namespace ),
459473 }
460474 err := helper .GetClient ().List (context .Background (), deployments , opts ... )
461475 if err != nil {
462476 helper .GetLogger ().Error (err , "Unable to retrieve OpenStackDataPlaneDeployment CRs %v" )
463- return false , false , false , err
477+ return false , false , false , failedDeployment , err
464478 }
465479
466480 var isDeploymentReady bool
@@ -499,6 +513,7 @@ func checkDeployment(helper *helper.Helper,
499513 if condition .IsError (deploymentCondition ) {
500514 err = fmt .Errorf (deploymentCondition .Message )
501515 isDeploymentFailed = true
516+ failedDeployment = deployment .Name
502517 break
503518 } else if deploymentConditions .IsFalse (dataplanev1 .NodeSetDeploymentReadyCondition ) {
504519 isDeploymentRunning = true
@@ -523,7 +538,7 @@ func checkDeployment(helper *helper.Helper,
523538 }
524539 }
525540
526- return isDeploymentReady , isDeploymentRunning , isDeploymentFailed , err
541+ return isDeploymentReady , isDeploymentRunning , isDeploymentFailed , failedDeployment , err
527542}
528543
529544// SetupWithManager sets up the controller with the Manager.
@@ -662,8 +677,8 @@ func (r *OpenStackDataPlaneNodeSetReconciler) genericWatcherFn(
662677}
663678
664679func (r * OpenStackDataPlaneNodeSetReconciler ) deploymentWatcherFn (
665- ctx context.Context , obj client. Object ) []reconcile. Request {
666- Log := r . GetLogger ( ctx )
680+ ctx context.Context , //revive:disable-line
681+ obj client. Object ) []reconcile. Request {
667682 namespace := obj .GetNamespace ()
668683 deployment := obj .(* dataplanev1.OpenStackDataPlaneDeployment )
669684
@@ -676,20 +691,6 @@ func (r *OpenStackDataPlaneNodeSetReconciler) deploymentWatcherFn(
676691 },
677692 })
678693 }
679-
680- podsInterface := r .Kclient .CoreV1 ().Pods (namespace )
681- podsList , err := podsInterface .List (ctx , v1.ListOptions {
682- LabelSelector : fmt .Sprintf ("openstackdataplanedeployment=%s" , deployment .Name ),
683- FieldSelector : "status.phase=Failed" ,
684- })
685-
686- if err != nil {
687- Log .Error (err , "unable to retrieve list of pods for dataplane diagnostic" )
688- } else {
689- for _ , pod := range podsList .Items {
690- Log .Info (fmt .Sprintf ("openstackansibleee job %s failed due to %s with message: %s" , pod .Name , pod .Status .Reason , pod .Status .Message ))
691- }
692- }
693694 return requests
694695}
695696
0 commit comments