{"action":"created","issue":{"url":"https://api.github.com/repos/dogtagpki/pki/issues/40","repository_url":"https://api.github.com/repos/dogtagpki/pki","labels_url":"https://api.github.com/repos/dogtagpki/pki/issues/40/labels{/name}","comments_url":"https://api.github.com/repos/dogtagpki/pki/issues/40/comments","events_url":"https://api.github.com/repos/dogtagpki/pki/issues/40/events","html_url":"https://github.com/dogtagpki/pki/pull/40","id":356386800,"node_id":"MDExOlB1bGxSZXF1ZXN0MjEyNjYxNDU2","number":40,"title":"Fix cloning failures caused by range depletion","user":{"login":"frasertweedale","id":2331938,"node_id":"MDQ6VXNlcjIzMzE5Mzg=","avatar_url":"https://avatars2.githubusercontent.com/u/2331938?v=4","gravatar_id":"","url":"https://api.github.com/users/frasertweedale","html_url":"https://github.com/frasertweedale","followers_url":"https://api.github.com/users/frasertweedale/followers","following_url":"https://api.github.com/users/frasertweedale/following{/other_user}","gists_url":"https://api.github.com/users/frasertweedale/gists{/gist_id}","starred_url":"https://api.github.com/users/frasertweedale/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frasertweedale/subscriptions","organizations_url":"https://api.github.com/users/frasertweedale/orgs","repos_url":"https://api.github.com/users/frasertweedale/repos","events_url":"https://api.github.com/users/frasertweedale/events{/privacy}","received_events_url":"https://api.github.com/users/frasertweedale/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-09-03T07:25:18Z","updated_at":"2018-09-25T05:58:39Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/dogtagpki/pki/pulls/40","html_url":"https://github.com/dogtagpki/pki/pull/40","diff_url":"https://github.com/dogtagpki/pki/pull/40.diff","patch_url":"https://github.com/dogtagpki/pki/pull/40.patch"},"body":"Tickets\r\n- https://pagure.io/dogtagpki/issue/3055\r\n- https://pagure.io/freeipa/issue/7654\r\n\r\nThis issue addresses several problems related to range management that can cause **cloning failure** and **startup failure**.\r\n\r\nHow to reproduce\r\n----------------\r\n\r\n1. Install a master (called **A**).\r\n\r\n2. Install a clone from **A** (called **B**).\r\n\r\n3. Install a clone from **B** (called **C**).\r\n\r\n4. Install another clone from **B** (called **D**).  Cloning fails due to `NullPointerException` on **B** while servicing `UpdateNumberRange` request.\r\n\r\n5. Further observe that **B** fails to restart due to an error initialising the range cache:\r\n\r\n```\r\n2018-09-03 15:12:16 [localhost-startStop-1] SEVERE: Unable to start CMS engine: Error in obtaining the last serial number in the repository!\r\nError in obtaining the last serial number in the repository!\r\n        at com.netscape.cmscore.dbs.Repository.initCache(Repository.java:308)\r\n        at com.netscape.cmscore.dbs.Repository.checkRanges(Repository.java:498)\r\n        at com.netscape.cmscore.apps.CMSEngine.startup(CMSEngine.java:1309)\r\n```\r\n\r\nFix description\r\n---------------\r\n\r\nThe fix consists of a number of parts (addressed in separate commits).\r\n\r\n1. A method to peek at the next serial number (without comsuming it) returned `null` when the current number range was depleted (even when a next range was available).  This was the cause of the NPE resulting in cloning failure.  This method was updated to return a number from the next range (if available).\r\n\r\n2. Range cache initialisation was updated to switch to the next range (if available) when the current range is exhausted. This avoids the startup issue after the range has been exhausted.\r\n\r\n3. A number of potential concurrency issues were addressed through use of `synchronized`.\r\n\r\n4. A substantial amount of commentary was added, and some minor refactoring to improve readability.\r\n\r\n\r\nFuture plans\r\n------------\r\n\r\nThe idea of a clone delegating part of its assigned range (current or next) to a new clone is fraught, as we see from these errors.  It would be better for the UpdateNumberRange servlet to create a full range assignment for the clone during creation.  This probably requires some changes to the UpdateNumberRange API, but is otherwise a straightforward change.  It should be implemented in a backwards compatible manner for a future release.  Ticket: https://pagure.io/dogtagpki/issue/3060."},"comment":{"url":"https://api.github.com/repos/dogtagpki/pki/issues/comments/424216791","html_url":"https://github.com/dogtagpki/pki/pull/40#issuecomment-424216791","issue_url":"https://api.github.com/repos/dogtagpki/pki/issues/40","id":424216791,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNDIxNjc5MQ==","user":{"login":"frasertweedale","id":2331938,"node_id":"MDQ6VXNlcjIzMzE5Mzg=","avatar_url":"https://avatars2.githubusercontent.com/u/2331938?v=4","gravatar_id":"","url":"https://api.github.com/users/frasertweedale","html_url":"https://github.com/frasertweedale","followers_url":"https://api.github.com/users/frasertweedale/followers","following_url":"https://api.github.com/users/frasertweedale/following{/other_user}","gists_url":"https://api.github.com/users/frasertweedale/gists{/gist_id}","starred_url":"https://api.github.com/users/frasertweedale/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frasertweedale/subscriptions","organizations_url":"https://api.github.com/users/frasertweedale/orgs","repos_url":"https://api.github.com/users/frasertweedale/repos","events_url":"https://api.github.com/users/frasertweedale/events{/privacy}","received_events_url":"https://api.github.com/users/frasertweedale/received_events","type":"User","site_admin":false},"created_at":"2018-09-25T05:58:39Z","updated_at":"2018-09-25T05:58:39Z","author_association":"CONTRIBUTOR","body":"Ade hasn't gotten around to it (fair enough, he's not a PKI dev any more).  Hopefully the steps to reproduce are pretty clear and someone else can step up to the plate.  @cipherboy you up for the challenge? :)"}}
{"actor":{"display_login":"frasertweedale"}}