{"action":"created","issue":{"url":"https://api.github.com/repos/spotify/docker-client/issues/416","repository_url":"https://api.github.com/repos/spotify/docker-client","labels_url":"https://api.github.com/repos/spotify/docker-client/issues/416/labels{/name}","comments_url":"https://api.github.com/repos/spotify/docker-client/issues/416/comments","events_url":"https://api.github.com/repos/spotify/docker-client/issues/416/events","html_url":"https://github.com/spotify/docker-client/issues/416","id":149165342,"number":416,"title":"Docker date time parsing (e.g. in inspect command) is not working sometimes","user":{"login":"quickwind","id":6889221,"avatar_url":"https://avatars.githubusercontent.com/u/6889221?v=3","gravatar_id":"","url":"https://api.github.com/users/quickwind","html_url":"https://github.com/quickwind","followers_url":"https://api.github.com/users/quickwind/followers","following_url":"https://api.github.com/users/quickwind/following{/other_user}","gists_url":"https://api.github.com/users/quickwind/gists{/gist_id}","starred_url":"https://api.github.com/users/quickwind/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quickwind/subscriptions","organizations_url":"https://api.github.com/users/quickwind/orgs","repos_url":"https://api.github.com/users/quickwind/repos","events_url":"https://api.github.com/users/quickwind/events{/privacy}","received_events_url":"https://api.github.com/users/quickwind/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-04-18T14:22:10Z","updated_at":"2016-04-18T14:54:10Z","closed_at":null,"body":"## Description\r\n\r\nDocker date time parsing (e.g. in inspect command) is not working sometimes.\r\n\r\n## How to reproduce\r\n\r\nThis happens from time to time, but not found a pattern yet. \r\n\r\n## What do you expect\r\n\r\ndocker inspect command response ContainerInfo should include correct datetime for startAt, finishAt, createAt timestamps parsed. \r\n\r\n## What happened instead\r\n\r\nParsed/deserialized datetime timestamp for ContainerInfo pojo is not correct somtimes. \r\n\r\n## Software:\r\n\r\n- docker version: 1.9.1\r\n- docker-client version: 3.6.8\r\n\r\n## Full backtrace\r\n\r\nSample output from our environment of one container, from it you can see the docker date time format is not always the pattern expected by com.spotify.docker.client.DockerDateFormat in following code:\r\n```\r\n@Override\r\n  public Date parse(String source) throws ParseException {\r\n    // If the date has nanosecond precision (e.g. 2014-10-17T21:22:56.949763914Z), remove the last\r\n    // six digits so we can create a Date object, which only support milliseconds.\r\n    if (source.matches(\".+\\\\.\\\\d{9}Z$\")) {\r\n      source = source.replaceAll(\"\\\\d{6}Z$\", \"Z\");\r\n    }\r\n\r\n    return super.parse(source);\r\n  }\r\n```\r\n\r\nOutput in our environment (`docker inspect 93151d9254cb1f79c577c850a12598027e4568fecc6343327029cdf556463f5b`):\r\n\r\n{\r\n    \"Id\": \"93151d9254cb1f79c577c850a12598027e4568fecc6343327029cdf556463f5b\",\r\n    \"Created\": \"2016-04-14T06:49:58.742349663Z\",\r\n    \"Path\": \"/test.sh\",\r\n    \"Args\": [\r\n        \"normal\"\r\n    ],\r\n    \"State\": {\r\n        \"Status\": \"exited\",\r\n        \"Running\": false,\r\n        \"Paused\": false,\r\n        \"Restarting\": false,\r\n        \"OOMKilled\": false,\r\n        \"Dead\": false,\r\n        \"Pid\": 0,\r\n        \"ExitCode\": 0,\r\n        \"Error\": \"\",\r\n        \"StartedAt\": \"2016-04-14T06:49:59.089717628Z\",\r\n        \"FinishedAt\": \"**2016-04-14T06:50:20.24937831Z**\"\r\n    },\r\n    \"Image\": \"0ecc8d08d01f4304b7ea2098d080c41b77c1844717f7c9f5c1b14f8e024ca428\",\r\n    \"ResolvConfPath\": \"/var/lib/docker/containers/93151d9254cb1f79c577c850a12598027e4568fecc6343327029cdf556463f5b/resolv.conf\",\r\n    \"HostnamePath\": \"/var/lib/docker/containers/93151d9254cb1f79c577c850a12598027e4568fecc6343327029cdf556463f5b/hostname\",\r\n    \"HostsPath\": \"/var/lib/docker/containers/93151d9254cb1f79c577c850a12598027e4568fecc6343327029cdf556463f5b/hosts\",\r\n    \"LogPath\": \"\",\r\n    \"Name\": \"/job-4-instance-50\",\r\n    \"RestartCount\": 0,\r\n    \"Driver\": \"aufs\",\r\n    \"ExecDriver\": \"native-0.2\",\r\n    \"MountLabel\": \"\",\r\n    \"ProcessLabel\": \"\",\r\n    \"AppArmorProfile\": \"\",\r\n    \"ExecIDs\": null,\r\n    \"HostConfig\": {\r\n        \"Binds\": null,\r\n        \"ContainerIDFile\": \"\",\r\n        \"LxcConf\": null,\r\n        \"Memory\": 0,\r\n        \"MemoryReservation\": 0,\r\n        \"MemorySwap\": 0,\r\n        \"KernelMemory\": 0,\r\n        \"CpuShares\": 0,\r\n        \"CpuPeriod\": 0,\r\n        \"CpusetCpus\": \"\",\r\n        \"CpusetMems\": \"\",\r\n        \"CpuQuota\": 0,\r\n        \"BlkioWeight\": 0,\r\n        \"OomKillDisable\": false,\r\n        \"MemorySwappiness\": null,\r\n        \"Privileged\": false,\r\n        \"PortBindings\": null,\r\n        \"Links\": null,\r\n        \"PublishAllPorts\": false,\r\n        \"Dns\": null,\r\n        \"DnsOptions\": null,\r\n        \"DnsSearch\": null,\r\n        \"ExtraHosts\": null,\r\n        \"VolumesFrom\": null,\r\n        \"Devices\": null,\r\n        \"NetworkMode\": \"default\",\r\n        \"IpcMode\": \"\",\r\n        \"PidMode\": \"\",\r\n        \"UTSMode\": \"\",\r\n        \"CapAdd\": null,\r\n        \"CapDrop\": null,\r\n        \"GroupAdd\": null,\r\n        \"RestartPolicy\": {\r\n            \"Name\": \"\",\r\n            \"MaximumRetryCount\": 0\r\n        },\r\n        \"SecurityOpt\": null,\r\n        \"ReadonlyRootfs\": false,\r\n        \"Ulimits\": null,\r\n        \"LogConfig\": {\r\n            \"Type\": \"gelf\",\r\n            \"Config\": {\r\n                \"gelf-address\": \"udp://localhost:12201\",\r\n                \"labels\": \"com.emc.prometheus.component.type,com.emc.prometheus.container.log.type,com.emc.prometheus.job.jobId,com.emc.prometheus.job.jobInstanceId,com.emc.prometheus.job.jobRunnerId,com.emc.prometheus.job.jobTriggerSource,com.emc.prometheus.job.jobTriggerType,com.emc.prometheus.job.jobTriggerTime\"\r\n            }\r\n        },\r\n        \"CgroupParent\": \"\",\r\n        \"ConsoleSize\": [\r\n            0,\r\n            0\r\n        ],\r\n        \"VolumeDriver\": \"\"\r\n    },\r\n    \"GraphDriver\": {\r\n        \"Name\": \"aufs\",\r\n        \"Data\": null\r\n    },\r\n    \"Mounts\": [],\r\n    \"Config\": {\r\n        \"Hostname\": \"93151d9254cb\",\r\n        \"Domainname\": \"\",\r\n        \"User\": \"\",\r\n        \"AttachStdin\": false,\r\n        \"AttachStdout\": false,\r\n        \"AttachStderr\": false,\r\n        \"Tty\": false,\r\n        \"OpenStdin\": false,\r\n        \"StdinOnce\": false,\r\n        \"Env\": [\r\n            \"PROMETHEUS_JOB_INSTANCE_ID=50\",\r\n            \"PROMETHEUS_JOB_TRIGGERSOURCE=job-scheduler-CNENWEIW3L1C\",\r\n            \"PROMETHEUS_JOB_ID=4\",\r\n            \"PROMETHEUS_JOB_TRIGGERTYPE=SCHEDULED\",\r\n            \"PROMETHEUS_JOB_TRIGGERTIME=1460616599999\",\r\n            \"PROMETHEUS_JOB_NAME=test job scheduled\",\r\n            \"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\"\r\n        ],\r\n        \"Cmd\": [\r\n            \"normal\"\r\n        ],\r\n        \"Image\": \"ctdcto23:5000/test/testjob:latest\",\r\n        \"Volumes\": null,\r\n        \"WorkingDir\": \"\",\r\n        \"Entrypoint\": [\r\n            \"/test.sh\"\r\n        ],\r\n        \"OnBuild\": null,\r\n        \"Labels\": {\r\n            \"com.emc.prometheus.component.type\": \"job\",\r\n            \"com.emc.prometheus.container.type\": \"job\",\r\n            \"com.emc.prometheus.job.jobId\": \"4\",\r\n            \"com.emc.prometheus.job.jobInstanceId\": \"50\",\r\n            \"com.emc.prometheus.job.jobRunnerId\": \"job-runner-CNENWEIW3L1C\",\r\n            \"com.emc.prometheus.job.jobTriggerSource\": \"job-scheduler-CNENWEIW3L1C\",\r\n            \"com.emc.prometheus.job.jobTriggerTime\": \"1460616599999\",\r\n            \"com.emc.prometheus.job.jobTriggerType\": \"SCHEDULED\"\r\n        }\r\n    },\r\n    \"NetworkSettings\": {\r\n        \"Bridge\": \"\",\r\n        \"SandboxID\": \"\",\r\n        \"HairpinMode\": false,\r\n        \"LinkLocalIPv6Address\": \"\",\r\n        \"LinkLocalIPv6PrefixLen\": 0,\r\n        \"Ports\": null,\r\n        \"SandboxKey\": \"\",\r\n        \"SecondaryIPAddresses\": null,\r\n        \"SecondaryIPv6Addresses\": null,\r\n        \"EndpointID\": \"\",\r\n        \"Gateway\": \"\",\r\n        \"GlobalIPv6Address\": \"\",\r\n        \"GlobalIPv6PrefixLen\": 0,\r\n        \"IPAddress\": \"\",\r\n        \"IPPrefixLen\": 0,\r\n        \"IPv6Gateway\": \"\",\r\n        \"MacAddress\": \"\",\r\n        \"Networks\": {\r\n            \"bridge\": {\r\n                \"EndpointID\": \"\",\r\n                \"Gateway\": \"\",\r\n                \"IPAddress\": \"\",\r\n                \"IPPrefixLen\": 0,\r\n                \"IPv6Gateway\": \"\",\r\n                \"GlobalIPv6Address\": \"\",\r\n                \"GlobalIPv6PrefixLen\": 0,\r\n                \"MacAddress\": \"\"\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/spotify/docker-client/issues/comments/211413653","html_url":"https://github.com/spotify/docker-client/issues/416#issuecomment-211413653","issue_url":"https://api.github.com/repos/spotify/docker-client/issues/416","id":211413653,"user":{"login":"johnflavin","id":1417503,"avatar_url":"https://avatars.githubusercontent.com/u/1417503?v=3","gravatar_id":"","url":"https://api.github.com/users/johnflavin","html_url":"https://github.com/johnflavin","followers_url":"https://api.github.com/users/johnflavin/followers","following_url":"https://api.github.com/users/johnflavin/following{/other_user}","gists_url":"https://api.github.com/users/johnflavin/gists{/gist_id}","starred_url":"https://api.github.com/users/johnflavin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnflavin/subscriptions","organizations_url":"https://api.github.com/users/johnflavin/orgs","repos_url":"https://api.github.com/users/johnflavin/repos","events_url":"https://api.github.com/users/johnflavin/events{/privacy}","received_events_url":"https://api.github.com/users/johnflavin/received_events","type":"User","site_admin":false},"created_at":"2016-04-18T14:54:09Z","updated_at":"2016-04-18T14:54:09Z","body":"Two questions:\r\n1. Can you format that `docker inspect` output as a code block? That would make it more easily readable. ([GitHub Help: Fenced Code Blocks](https://help.github.com/articles/creating-and-highlighting-code-blocks/#fenced-code-blocks))\r\n2. I'm not sure exactly what you’re saying the problem is, but let me repeat it back to make sure I have it right. \r\n  * The `parse(String)` method is designed to truncate the date/time string down to milliseconds\r\n  * It does this by using a regular expression match on the date/time string, but only matches on exactly nine digits of precision\r\n  * Occasionally the date/time string has fewer than nine digits (and in the case you've shown, it has eight), which means there is no match and no truncation.\r\n  * And then... something happens? I don't know what. What is the bad effect from this?"}}