isotime format with milliseconds

298 views
Skip to first unread message

Anil Sb

unread,
Jun 3, 2018, 9:38:27 PM6/3/18
to Packer

I am trying to figure out, if we can get packer images names with the timestamp extending upto milliseconds with isotime and the correct format to use.

From [2.] we use the format to get -HHMM (-1504). I have tested this to extend to -HHMMSS (-150405) which works, but the format (-150405000) translates to ZZCI - Ubuntu 16.04 - docker - 20180522-082218000.

I was recommend to use a period (-150405.000), from an [3.] but does not seem to work and returns the following error:

to become ready: unexpected state 'ERROR', wanted target '[ACTIVE]'

Is this format supported, I've opened this issue [3.] and would like to know if anyone has to got this working.
Unfortunatly the docs does not have an example if this format is supported.


- Anil

[1.] https://golang.org/pkg/time/#example_Time_Format
[2.] https://github.com/opendaylight/releng-builder/blob/master/packer/templates/devstack-pre-pip-ocata.json#L26

[3.] https://github.com/hashicorp/packer/issues/6293


 

Alvaro Miranda Aguilera

unread,
Jun 4, 2018, 3:08:17 AM6/4/18
to packe...@googlegroups.com
How many zeros you tried?





        RFC3339Nano = "2006-01-02T15:04:05.999999999Z07:00"
..
        StampMilli = "Jan _2 15:04:05.000"
        StampMicro = "Jan _2 15:04:05.000000"
        StampNano  = "Jan _2 15:04:05.000000000"



--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/09f44811-4570-41fd-90c0-98f0495b8e61%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Rickard von Essen

unread,
Jun 4, 2018, 3:25:46 AM6/4/18
to packe...@googlegroups.com
It works, but it seems like you cloud (OpenStack?) doesn't allow that name and thus fails. Unfortunatley OS don't document any restrictions on image names, so it might be different from different vendors.

A full example:
{
  "builders": [
    {
      "type": "docker",
      "pull": "true",
      "image": "alpine",
      "run_command": [ "-d", "-t", "-i", "{{.Image}}", "/bin/ash"],
      "changes": [
        "WORKDIR /tmp",
        "EXPOSE 8080",
        "USER alpine",
        "LABEL buildtime {{isotime \"20060102-150405.000\"}}"
      ],
      "author": "Rickard von Essen <rickard....@gmail.com>",
      "commit": true
    }
  ],
  "provisioners": [
    {
      "type": "file",
      "source": "dirA/",
      "destination": "/tmp/"
    }
  ]
}

$ packer build alpine.json
docker output will be in this color.

==> docker: Creating a temporary directory for sharing data...
==> docker: Pulling Docker image: alpine
    docker: Using default tag: latest
    docker: latest: Pulling from library/alpine
    docker: Digest: sha256:e1871801d30885a610511c867de0d6baca7ed4e6a2573d506bbec7fd3b03873f
    docker: Status: Image is up to date for alpine:latest
==> docker: Starting docker container...
    docker: Run command: docker run -v /Users/rickard/.packer.d/tmp/packer-docker969467560:/packer-files -d -t -i alpine /bin/ash
    docker: Container ID: ae9933cbd3f0824fc249c99626623611c5de9bbe35c70ea8472833d00a1f6ab9
==> docker: Uploading dirA/ => /tmp/
==> docker: Committing the container
    docker: Image ID: sha256:46a9ee230651e08d39d5296f98c5209949c3a27c8794e66ed04aa6a22f8908fc
==> docker: Killing the container: ae9933cbd3f0824fc249c99626623611c5de9bbe35c70ea8472833d00a1f6ab9
Build 'docker' finished.

==> Builds finished. The artifacts of successful builds are:
--> docker: Imported Docker image: sha256:46a9ee230651e08d39d5296f98c5209949c3a27c8794e66ed04aa6a22f8908fc

$ docker inspect sha256:46a9ee230651e08d39d5296f98c5209949c3a27c8794e66ed04aa6a22f8908fc | grep build
                "buildtime": "20180604-071856.954"



Anil Sb

unread,
Jun 4, 2018, 10:11:05 PM6/4/18
to Packer
Thanks for the sharing a quick working example. Can confirm that this is an issue seen on the OpenStack/cloud because of the using name ending with period+number.
The workaround is to use a proper `instance_name:` Maybe worth documenting if it helps others too.

- Anil

https://bugs.launchpad.net/nova/+bug/1581977
https://www.packer.io/docs/builders/openstack.html#instance_name
https://jira.linuxfoundation.org/browse/RELENG-971
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.



--
Alvaro

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages