{"record":{"id":"13b986459aa6b608","repo":"apache/hadoop","slug":"cannot-rename-kdc-s-krb5conf-to-s","errorCode":null,"errorMessage":"Cannot rename KDC's krb5conf to %s","messagePattern":"Cannot rename KDC's krb5conf to (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-minikdc/src/main/java/org/apache/hadoop/minikdc/MiniKdc.java","lineNumber":138,"sourceCode":"      System.out.println(\"  Realm           : \" + miniKdc.getRealm());\n      System.out.println(\"  Running at      : \" + miniKdc.getHost() + \":\" +\n              miniKdc.getHost());\n      System.out.println(\"  krb5conf        : \" + krb5conf);\n      System.out.println();\n      System.out.println(\"  created keytab  : \" + keytabFile);\n      System.out.println(\"  with principals : \" + Arrays.asList(principals));\n      System.out.println();\n      System.out.println(\" Do <CTRL-C> or kill <PID> to stop it\");\n      System.out.println(\"---------------------------------------------------\");\n      System.out.println();\n      Runtime.getRuntime().addShutdownHook(new Thread() {\n        @Override\n        public void run() {\n          miniKdc.stop();\n        }\n      });\n    } else {\n      throw new RuntimeException(\"Cannot rename KDC's krb5conf to \"\n              + krb5conf.getAbsolutePath());\n    }\n  }\n\n  private static final Logger LOG = LoggerFactory.getLogger(MiniKdc.class);\n\n  public static final String ORG_NAME = \"org.name\";\n  public static final String ORG_DOMAIN = \"org.domain\";\n  public static final String KDC_BIND_ADDRESS = \"kdc.bind.address\";\n  public static final String KDC_PORT = \"kdc.port\";\n  public static final String INSTANCE = \"instance\";\n  public static final String MAX_TICKET_LIFETIME = \"max.ticket.lifetime\";\n  public static final String MIN_TICKET_LIFETIME = \"min.ticket.lifetime\";\n  public static final String MAX_RENEWABLE_LIFETIME = \"max.renewable.lifetime\";\n  public static final String TRANSPORT = \"transport\";\n  public static final String DEBUG = \"debug\";\n\n  private static final Set<String> PROPERTIES = new HashSet<String>();","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-minikdc/src/main/java/org/apache/hadoop/minikdc/MiniKdc.java#L120-L156","documentation":"After starting the embedded KDC, standalone MiniKdc.main() renames the generated krb5.conf from inside the KDC's timestamped work directory to <WORKDIR>/krb5.conf (MiniKdc.java:112). If File.renameTo returns false — target could not be created/replaced — it throws RuntimeException 'Cannot rename KDC's krb5conf to <path>' and the standalone KDC aborts.","triggerScenarios":"An existing workDir/krb5.conf that cannot be replaced (locked by another process, read-only permissions, or Windows rename-over-existing semantics), a work directory without write permission, or the source krb5.conf missing because the KDC failed to write it.","commonSituations":"Running the standalone MiniKdc twice in the same workdir where the first run's file is held open; antivirus/file locks on Windows; read-only or root-owned workdir under CI; disk full.","solutions":["Delete any stale <WORKDIR>/krb5.conf (and stop processes holding it) before starting","Ensure the JVM user has write permission on the workdir and sufficient disk space","Use a fresh workdir per run (the JUnit harness does this via target/test-dir/<timestamp>)","On Windows, close handles to krb5.conf — renameTo cannot replace an open file there"],"exampleFix":"# before\njava ... MiniKdc /tmp/kdc ... # second run, stale krb5.conf\n# after\nrm -f /tmp/kdc/krb5.conf && java ... MiniKdc /tmp/kdc ...","handlingStrategy":"validation","validationCode":"File target = new File(workDir, \"krb5.conf\");\nif (target.exists() && !target.delete())\n  throw new IllegalStateException(\"cannot clear stale \" + target + \" — close holders and retry\");\nif (!workDir.canWrite()) throw new IllegalStateException(\"workdir not writable: \" + workDir);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use a fresh workdir per standalone MiniKdc run","Remove workDir/krb5.conf before each start","On Windows, ensure no process holds krb5.conf open (rename cannot replace open files)"],"tags":["minikdc","kerberos","testing","file-system","rename-failed"],"backgroundTag":"file-rename-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}