Skip to content
This repository has been archived by the owner on Nov 23, 2019. It is now read-only.

Backward compatibility for container filters #171

Closed
nishanttotla opened this issue Mar 25, 2016 · 5 comments
Closed

Backward compatibility for container filters #171

nishanttotla opened this issue Mar 25, 2016 · 5 comments

Comments

@nishanttotla
Copy link
Contributor

Reference: https://github.com/docker/engine-api/blob/master/types/filters/parse.go
Currently, the Args struct looks like this

type Args struct {
    fields map[string]map[string]bool
}

but not too long ago, it looked like this

type Args map[string][]string

So basically I can’t use the newer client to work with older daemons, because I will get a json unmarshaling error. This is a problem for Swarm since we're moving to the engine-api and can't support older daemons on the cluster as a result.

Current Swarm PR blocked due to this issue: docker-archive/classicswarm#1983

This issue is in the same category as #144.

@nishanttotla
Copy link
Contributor Author

Ping @calavera @thaJeztah creating issue here so that discussion is saved :)

@thaJeztah
Copy link
Member

Thanks @nishanttotla!

@calavera
Copy link
Contributor

I guess we could try to version that ToParam function in the filters. I think the change was introduced in 1.21. We could do something like:

func ToParamWithVersion(arg Args, version string) (string, error) {
  if version < "1.21" {
     // serialize old version
  } else {
    return ToParam(args)
  }
}

@nishanttotla
Copy link
Contributor Author

@calavera thanks! I was just working on a fix that does the exact same thing. I'll open a PR later today.

@nishanttotla
Copy link
Contributor Author

One issue though, is that it's unclear where the daemon version will come from. Since filters is a separate package inside of types, and the version is stored inside the client package, the only way I can see to do this is to pass the version to ToParam from all places making the call.

Secondly in Swarm, an Engine in the cluster can go through a live update, in which case we'd need to update the version. Would it be possible to add an UpdateVersion function in the client package that allows this? It's possible to make a call to ServerVersion of course, but it would be nice to avoid extra function calls.

WDYT @calavera?

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

No branches or pull requests

3 participants