{"record":{"id":"fc08fce5969d40da","repo":"apache/cassandra","slug":"cloudstacksnitch-cannot-access-lease-file","errorCode":null,"errorMessage":"CloudstackSnitch cannot access lease file.","messagePattern":"CloudstackSnitch cannot access lease file\\.","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/locator/CloudstackLocationProvider.java","lineNumber":125,"sourceCode":"        Pattern identifierPattern = Pattern.compile(\"^[ \\t]*option dhcp-server-identifier (.*);$\");\n\n        try (BufferedReader reader = new BufferedReader(new FileReader(lease)))\n        {\n\n            while ((line = reader.readLine()) != null)\n            {\n                Matcher matcher = identifierPattern.matcher(line);\n\n                if (matcher.find())\n                {\n                    endpoint = matcher.group(1);\n                    break;\n                }\n            }\n        }\n        catch (Exception e)\n        {\n            throw new ConfigurationException(\"CloudstackSnitch cannot access lease file.\");\n        }\n\n        if (endpoint == null)\n        {\n            throw new ConfigurationException(\"No metadata server could be found in lease file.\");\n        }\n\n        return \"http://\" + endpoint;\n    }\n}\n","sourceCodeStart":107,"sourceCodeEnd":136,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/locator/CloudstackLocationProvider.java#L107-L136","documentation":"Thrown by CloudstackLocationProvider.csEndpointFromLease() when reading/parsing the DHCP lease file throws (file unreadable, permissions, unexpected content). It reports that the CloudStack metadata endpoint could not be extracted from the lease file.","triggerScenarios":"csEndpointFromLease(), invoked from csMetadataEndpoint(), when the lease file exists but cannot be read or parsed — bad permissions, missing file between listing and reading, malformed lease content causing BufferedReader exceptions.","commonSituations":"Lease file owned by root/dhcp user without read permission for the cassandra process; truncated or corrupted dhclient lease; running as non-root in a hardened container.","solutions":["Grant read permission on the lease file to the cassandra process user","Run the node with sufficient privileges or mount the lease file readable","Verify lease file contents are well-formed dhclient lease entries","Regenerate the lease by restarting dhclient/networking"],"exampleFix":"// before\n-rw------- root /var/lib/dhcp/dhclient.eth0.leases\n\n// after\nsudo chmod 644 /var/lib/dhcp/dhclient.eth0.leases","handlingStrategy":"try-catch","validationCode":"File lease = new File(path);\nif (!lease.canRead()) throw new IllegalStateException(\"Lease file not readable by user \" + System.getProperty(\"user.name\"));","typeGuard":null,"tryCatchPattern":"try { endpoint = csEndpointFromLease(lease); } catch (ConfigurationException e) { logger.error(\"Cannot read CloudStack lease file\", e); throw e; }","preventionTips":["Ensure cassandra user has read access to /var/lib/dhcp/*","Do not remove/rename lease files while Cassandra runs","Validate lease file format after network stack changes"],"tags":["cloudstack","snitch","file-read","permissions"],"backgroundTag":"file-read-failed","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}