@@ -125,6 +125,7 @@ public static synchronized void setupDBandRCUschema(String dbImage, String fmwIm
125125 public static synchronized void startOracleDB (String dbBaseImageName , int dbPort , String dbNamespace ,
126126 int dbListenerPort ) throws ApiException {
127127 LoggingFacade logger = getLogger ();
128+ String dbPodNamePrefix = "oracledb" ;
128129
129130 if (OKD ) {
130131 addSccToDBSvcAccount ("default" , dbNamespace );
@@ -200,7 +201,7 @@ public static synchronized void startOracleDB(String dbBaseImageName, int dbPort
200201 .addEnvItem (new V1EnvVar ().name ("DB_BUNDLE" ).value ("basic" ))
201202 .image (dbBaseImageName )
202203 .imagePullPolicy ("IfNotPresent" )
203- .name ("oracledb" )
204+ .name (dbPodNamePrefix )
204205 .ports (Arrays .asList (
205206 new V1ContainerPort ()
206207 .containerPort (dbListenerPort )
@@ -237,7 +238,7 @@ public static synchronized void startOracleDB(String dbBaseImageName, int dbPort
237238 }
238239
239240 // wait for the Oracle DB pod to be ready
240- String dbPodName = assertDoesNotThrow (() -> getPodNameOfDb (dbNamespace ),
241+ String dbPodName = assertDoesNotThrow (() -> getPodNameOfDb (dbNamespace , dbPodNamePrefix ),
241242 String .format ("Get Oracle DB pod name failed with ApiException for oracleDBService in namespace %s" ,
242243 dbNamespace ));
243244 logger .info ("Wait for the oracle Db pod: {0} ready in namespace {1}" , dbPodName , dbNamespace );
@@ -434,22 +435,24 @@ private static boolean createRcuRepository(String dbNamespace, String dbUrl,
434435
435436 /**
436437 * Get database pod name.
438+ *
437439 * @param dbNamespace namespace where database exists
440+ * @param podPrefix prefix of database pod
438441 * @return pod name of database
439442 * @throws ApiException if Kubernetes client API call fails
440443 */
441- public static String getPodNameOfDb (String dbNamespace ) throws ApiException {
442-
443- V1PodList pod = null ;
444- pod = Kubernetes .listPods (dbNamespace , null );
445-
444+ public static String getPodNameOfDb (String dbNamespace , String podPrefix ) throws ApiException {
446445 String podName = null ;
447-
448- //There is only one pod in the given DB namespace
449- if (pod != null ) {
450- podName = pod .getItems ().get (0 ).getMetadata ().getName ();
446+ V1PodList pods = null ;
447+ pods = Kubernetes .listPods (dbNamespace , null );
448+ if (!pods .getItems ().isEmpty ()) {
449+ for (V1Pod pod : pods .getItems ()) {
450+ if (pod != null && pod .getMetadata ().getName ().startsWith (podPrefix )) {
451+ podName = pod .getMetadata ().getName ();
452+ break ;
453+ }
454+ }
451455 }
452-
453456 return podName ;
454457 }
455458
0 commit comments