@@ -653,17 +653,27 @@ func ApplyIdxcSecret(ctx context.Context, mgr *indexerClusterPodManager, replica
653653 // Get Indexer's name
654654 indexerPodName := GetSplunkStatefulsetPodName (SplunkIndexer , mgr .cr .GetName (), i )
655655
656+ // Check if pod exists before updating secrets
657+ pod := & corev1.Pod {}
658+ namespacedName := types.NamespacedName {Namespace : mgr .cr .GetNamespace (), Name : indexerPodName }
659+ scopedLog .Info ("Check if pod is created before updating its secrets" )
660+ err := mgr .c .Get (ctx , namespacedName , pod )
661+ if err != nil {
662+ mgr .log .Info ("Peer doesn't exists" , "peerName" , indexerPodName )
663+ continue
664+ }
665+
656666 // Retrieve secret from pod
657667 podSecret , err := splutil .GetSecretFromPod (ctx , mgr .c , indexerPodName , mgr .cr .GetNamespace ())
658668 if err != nil {
659- return fmt .Errorf (fmt . Sprintf ( splcommon .PodSecretNotFoundError , indexerPodName ) )
669+ return fmt .Errorf (splcommon .PodSecretNotFoundError , indexerPodName )
660670 }
661671
662672 // Retrieve idxc_secret token
663673 if indIdxcSecretByte , ok := podSecret .Data [splcommon .IdxcSecret ]; ok {
664674 indIdxcSecret = string (indIdxcSecretByte )
665675 } else {
666- return fmt .Errorf (fmt . Sprintf ( splcommon .SecretTokenNotRetrievable , splcommon .IdxcSecret ) )
676+ return fmt .Errorf (splcommon .SecretTokenNotRetrievable , splcommon .IdxcSecret )
667677 }
668678
669679 // If idxc secret is different from namespace scoped secret change it
0 commit comments