@@ -554,36 +554,16 @@ private static void validateContainerSpec(V1Container container, String podName,
554554 logger .info ("PASS: Container " + containerName + " in pod " + podName + " has readOnlyRootFilesystem=true" );
555555 }
556556
557- if (!isInitContainer ) {
558- // 2. For regular containers, exec to check /tmp mount
559- try {
560-
561- ExecResult result = execCommand (namespace , podName , containerName , true , "df" , "-h" , "/tmp" );
562- String stdout = result .stdout ();
563- if (stdout == null || !stdout .contains ("tmpfs" )) {
564- String msg = "FAIL: /tmp is not mounted as tmpfs in container " + containerName + " in pod " + podName ;
565- logger .severe (msg );
566- failures .add (msg );
567- } else {
568- logger .info ("PASS: /tmp is mounted as tmpfs in container " + containerName + " in pod " + podName );
569- }
570- } catch (Exception e ) {
571- String msg = "FAIL: Exec failed for container " + containerName + " in pod " + podName + ": " + e .getMessage ();
572- logger .severe (msg );
573- failures .add (msg );
574- }
557+ // 2. Check volumeMounts
558+ List <V1VolumeMount > volumeMounts = container .getVolumeMounts ();
559+ boolean hasTmpMount = volumeMounts != null && volumeMounts .stream ()
560+ .anyMatch (mount -> mount .getMountPath () != null && mount .getMountPath ().startsWith ("/tmp" ));
561+ if (!hasTmpMount ) {
562+ String msg = "FAIL: container " + containerName + " in pod " + podName + " does not have /tmp mounted" ;
563+ logger .severe (msg );
564+ failures .add (msg );
575565 } else {
576- // 3. For init container, check volumeMounts
577- List <V1VolumeMount > volumeMounts = container .getVolumeMounts ();
578- boolean hasTmpMount = volumeMounts != null && volumeMounts .stream ()
579- .anyMatch (mount -> mount .getMountPath () != null && mount .getMountPath ().startsWith ("/tmp" ));
580- if (!hasTmpMount ) {
581- String msg = "FAIL: Init container " + containerName + " in pod " + podName + " does not have /tmp mounted" ;
582- logger .severe (msg );
583- failures .add (msg );
584- } else {
585- logger .info ("PASS: Init container " + containerName + " in pod " + podName + " has /tmp mounted" );
586- }
566+ logger .info ("PASS: container " + containerName + " in pod " + podName + " has /tmp mounted" );
587567 }
588568 }
589569
0 commit comments