Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

on updating Docker service : cannot unmarshal array into Go value of type swarm.Resources #1

Open
rsalimian opened this issue Oct 28, 2016 · 0 comments

Comments

@rsalimian
Copy link

I get this error when there is empty items in array:

json: cannot unmarshal array into Go value of type swarm.Resources

I'm trying to update service image. for that I have to first inspect current Service and then pull the whole Spec section then make my changed and then call the service update.

let say the JSON object is like:
`

{
"Name":"myservice",
"Labels":{
"com.df.distribute":"true",

        "com.df.notify":"true",
        "com.df.port":"80",
        "com.df.serviceDomain":"my.domain.com",
        "com.df.servicePath":"/"
    },
    "TaskTemplate":{
        "ContainerSpec":{
            "Image":"my/image:2.1.1"
        },
        "Resources":{
            "Limits":{
            },
            "Reservations":{
            }
        },
        "RestartPolicy":{
            "Condition":"any",
            "MaxAttempts":0
        },
        "Placement":{
            "Constraints":[
                "node.role==worker"
            ]
        },
        "Networks":[
            {
                "Target":"47ov8tcgvmuie3qhde3xfpb2y"
            },
            {
                "Target":"4naryq4iva5unmq1u5ye2z2tj"
            }
        ]
    },
    "Mode":{
        "Replicated":{
            "Replicas":2
        }
    },
    "UpdateConfig":{
        "Parallelism":1,
        "FailureAction":"pause"
    },
    "Networks":[
        {
            "Target":"proxy"
        },
        {
            "Target":"mynet"
        }
    ],
    "EndpointSpec":{
        "Mode":"vip"
    }
}

`

as you see in the JSON the Resource has empty arrays and if I take them off the API will works fine.

the point is using Curl command it works with no error and i dont need to remove emty items.

quick work around for this is that I have to process the array and remove all empty elements.
seems this is like GO error

Docker Version:
`
Client:
Version: 1.12.3-cs3
API version: 1.24
Go version: go1.6.3
Git commit: 781bb16
Built:
OS/Arch: linux/amd64

Server:
Version: 1.12.3-cs3
API version: 1.24
Go version: go1.6.3
Git commit: 781bb16
Built:
OS/Arch: linux/amd64
`

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

No branches or pull requests

1 participant