Skip to content
This repository has been archived by the owner on Aug 14, 2020. It is now read-only.

"name" and "value" keys unnecessarily verbose? #501

Open
jaypipes opened this issue Sep 25, 2015 · 3 comments
Open

"name" and "value" keys unnecessarily verbose? #501

jaypipes opened this issue Sep 25, 2015 · 3 comments

Comments

@jaypipes
Copy link

Hi again!

Is there any particular reason why the "name" and "value" keys are used for labels, annotations, isolators, eventHandlers and environment variable lists? If those things were objects themselves, instead of lists, the ACI image schema would be much simpler and less verbose.

For instance, if you made the lists into objects for the above mentioned attributes of the image schema, you would go from this (from the examples):

{
    "acKind": "ImageManifest",
    "acVersion": "0.7.0",
    "name": "example.com/reduce-worker",
    "labels": [
        {
            "name": "version",
            "value": "1.0.0"
        },
        {
            "name": "arch",
            "value": "amd64"
        },
        {
            "name": "os",
            "value": "linux"
        }
    ],
    "app": {
        "exec": [
            "/usr/bin/reduce-worker",
            "--quiet"
        ],
        "user": "100",
        "group": "300",
        "supplementaryGids": [
                400,
                500
        ],
        "eventHandlers": [
            {
                "exec": [
                    "/usr/bin/data-downloader"
                ],
                "name": "pre-start"
            },
            {
                "exec": [
                    "/usr/bin/deregister-worker",
                    "--verbose"
                ],
                "name": "post-stop"
            }
        ],
        "workingDirectory": "/opt/work",
        "environment": [
            {
                "name": "REDUCE_WORKER_DEBUG",
                "value": "true"
            }
        ],
        "isolators": [
            {
                "name": "resource/cpu",
                "value": {
                    "request": "250m",
                    "limit": "500m"
                }
            },
            {
                "name": "resource/memory",
                "value": {
                    "request": "1G",
                    "limit": "2G"
                }
            },
            {
                "name": "os/linux/capabilities-retain-set",
                "value": {
                    "set": ["CAP_NET_BIND_SERVICE"]
                }
            }
        ],
        "mountPoints": [
            {
                "name": "work",
                "path": "/var/lib/work",
                "readOnly": false
            }
        ],
        "ports": [
            {
                "name": "health",
                "port": 4000,
                "protocol": "tcp",
                "socketActivated": true
            },
            {
                "name": "ftp-data",
                "port": 20000,
                "count": 1000,
                "protocol": "tcp"
            }
        ]
    },
    "dependencies": [
        {
            "imageName": "example.com/reduce-worker-base",
            "imageID": "sha512-...",
            "labels": [
                {
                    "name": "os",
                    "value": "linux"
                },
                {
                    "name": "env",
                    "value": "canary"
                }
            ],
            "size": 22017258
        }
    ],
    "pathWhitelist": [
        "/etc/ca/example.com/crt",
        "/usr/bin/map-reduce-worker",
        "/opt/libs/reduce-toolkit.so",
        "/etc/reduce-worker.conf",
        "/etc/systemd/system/"
    ],
    "annotations": [
        {
            "name": "authors",
            "value": "Carly Container <carly@example.com>, Nat Network <[nat@example.com](mailto:nat@example.com)>"
        },
        {
            "name": "created",
            "value": "2014-10-27T19:32:27.67021798Z"
        },
        {
            "name": "documentation",
            "value": "https://example.com/docs"
        },
        {
            "name": "homepage",
            "value": "https://example.com"
        }
    ]
}

to this:

{
    "acKind": "ImageManifest",
    "acVersion": "0.7.0",
    "name": "example.com/reduce-worker",
    "labels": {
        "version": "1.0.0",
        "arch": "amd64",
        "os": "linux"
    },
    "app": {
        "exec": [
            "/usr/bin/reduce-worker",
            "--quiet"
        ],
        "user": "100",
        "group": "300",
        "supplementaryGids": [
                400,
                500
        ],
        "eventHandlers": {
            "pre-start": {
                "exec": [
                    "/usr/bin/data-downloader"
                ]
            },
            "post-stop": {
                "exec": [
                    "/usr/bin/deregister-worker",
                    "--verbose"
                ]
            }
        },
        "workingDirectory": "/opt/work",
        "environment": {
            "REDUCE_WORKER_DEBUG": "true"
        },       
        "isolators": {
            "resource/cpu": {
                    "request": "250m",
                    "limit": "500m"
            },
            "resource/memory": {
                    "request": "1G",
                    "limit": "2G"
            },
            "os/linux/capabilities-retain-set": {
                "set": ["CAP_NET_BIND_SERVICE"]
            }
        },
        "mountPoints": {
            "work": {
                "path": "/var/lib/work",
                "readOnly": false
            }
        },
        "ports": {
            "health": {
                "port": 4000,
                "protocol": "tcp",
                "socketActivated": true
            },
            "ftp-data": {
                "port": 20000,
                "count": 1000,
                "protocol": "tcp"
            }
        }
    },
    "dependencies": [
        {
            "imageName": "example.com/reduce-worker-base",
            "imageID": "sha512-...",
            "labels": {
                "os": "linux",
                "env": "canary"
            },
            "size": 22017258
        }
    ],
    "pathWhitelist": [
        "/etc/ca/example.com/crt",
        "/usr/bin/map-reduce-worker",
        "/opt/libs/reduce-toolkit.so",
        "/etc/reduce-worker.conf",
        "/etc/systemd/system/"
    ],
    "annotations": {
        "authors": "Carly Container <carly@example.com>, Nat Network <[nat@example.com](mailto:nat@example.com)>",
        "created": "2014-10-27T19:32:27.67021798Z",
        "documentation": "https://example.com/docs",
        "homepage": "https://example.com"
    }
}

The latter doesn't lose any information, and is significantly less verbose (and IMHO easier to read).

Thoughts?

Best,
-jay

@cdaylward
Copy link
Contributor

Hmm, this has been discussed before in #58, #62, #64, and #84 and we landed on the more verbose format. To reiterate here:
It maintains that field names on the left are schema, values on the right are user values. Behavior during duplicate JSON object field names are not part of the JSON spec and may be handled differently based on the library being used...but generally an ill-formed manifest will have duplicate errors swallowed during JSON parsing. Some label names are not valid JSON object member names.

@jaypipes
Copy link
Author

OK, that's good information, thank you. I guess I don't really see why AppC would use JSON as its file format and then allow "label names [to not be] valid JSON object member names." That doesn't make a whole lot of sense to me. Why bother using JSON at all, then, if you're just going to override what JSON means with the parser.go implementation? Or, put another way, what does not conforming to the JSON spec give AppC?

@jonboulle
Copy link
Contributor

I guess I don't really see why AppC would use JSON as its file format and then allow "label names [to not be] valid JSON object member names." That doesn't make a whole lot of sense to me. Why bother using JSON at all, then, if you're just going to override what JSON means with the parser.go implementation? Or, put another way, what does not conforming to the JSON spec give AppC?

I'm a bit confused by @cdaylward's point here, as I don't know of cases where label names are invalid member names.

As justification for this schema I would lean more on his other points with respect to the field name/user value split.

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

No branches or pull requests

3 participants