Skip to content
This repository has been archived by the owner on Jun 21, 2024. It is now read-only.

update metadata to latest structure #227

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

displague
Copy link
Contributor

@displague displague commented Dec 13, 2020

TODO

  • tests should unmarshal the new structs (fix the ipnet tests)
  • provide examples of the new structures in the text fixture
  • provide comments for each field (and examples when vague)

prior art (https://github.com/packethost/packetmetadata/blob/master/packetmetadata/packetmetadata.go) (no longer online)

Signed-off-by: Marques Johansson <mjohansson@equinix.com>
@t0mk
Copy link
Contributor

t0mk commented Dec 14, 2020

To test this means to run a device and try to read the metada via GetMetadataFromURL?

@displague
Copy link
Contributor Author

displague commented Jan 6, 2021

To test this means to run a device and try to read the metada via GetMetadataFromURL?

@t0mk, yes.

Or running metadata.GetMetadata()

This package doesn't seem to be getting much attention or use. I would like to see us use it in #189 so we could self-discover project and organization values for clients like the CCM which are expected to be run from Equinix Metal devices (for the benefit of fewer configuration parameters in cases where it can be detected).

I hadn't really looked at GetMetadata or GetMetadataFromURL before you asked. I think we'll want to revise these functions to take a context.Context parameter.

@t0mk
Copy link
Contributor

t0mk commented Jan 7, 2021

@displague I'm testing this. I get

panic: json: cannot unmarshal number into Go struct field .storage.disks.partitions.size of type string

For

	// Partition size is sometimes str and sometimes int
	/*
	 "storage": {
	    "disks": [
	      {
	        "device": "/dev/sda",
	        "wipeTable": true,
	        "partitions": [
	          {
	            "label": "BIOS",
	            "number": 1,
	            "size": 4096
	          },
	          {
	            "label": "SWAP",
	            "number": 2,
	            "size": "3993600"
	          },
	          {
	            "label": "ROOT",
	            "number": 3,
	            "size": 0
	          }
	        ]
	      }
	    ],
	*/

@displague
Copy link
Contributor Author

displague commented Jan 11, 2021

@t0mk I have an internal issue filed against this behavior.
It is currently possible for the size response to be any of 0, "1", "123MB". I suppose the correct behavior for the client is to translate the possible responses into an integer of fixed units (bytes?).

@t0mk t0mk added the api bug label Feb 8, 2021
@@ -108,18 +116,98 @@ func (m BondingMode) String() string {
return fmt.Sprintf("%d", m)
}

type PrivateSubnet struct {
// TODO(displague): Discover the fields

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there's any fields -- right now at least, the private_subnets field on the metadata is just a list of strings like a.b.c.d/cidr

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants