Skip to content

Type alias spec in oci package#2336

Merged
dmcgowan merged 1 commit intocontainerd:masterfrom
crosbymichael:spec-alias
May 22, 2018
Merged

Type alias spec in oci package#2336
dmcgowan merged 1 commit intocontainerd:masterfrom
crosbymichael:spec-alias

Conversation

@crosbymichael
Copy link
Copy Markdown
Member

This allows Go to build third party packages correctly without vendoring
issues what want to create their own SpecOpts.

Fixes #2289

Signed-off-by: Michael Crosby [email protected]

@crosbymichael
Copy link
Copy Markdown
Member Author

crosbymichael commented May 10, 2018

@williammartin can you take a look and test this solution?

@codecov-io
Copy link
Copy Markdown

codecov-io commented May 10, 2018

Codecov Report

Merging #2336 into master will increase coverage by 4.29%.
The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2336      +/-   ##
==========================================
+ Coverage   44.99%   49.29%   +4.29%     
==========================================
  Files          92       84       -8     
  Lines        9336     7421    -1915     
==========================================
- Hits         4201     3658     -543     
+ Misses       4457     3088    -1369     
+ Partials      678      675       -3
Flag Coverage Δ
#linux 49.29% <50%> (ø) ⬆️
#windows ?
Impacted Files Coverage Δ
oci/spec.go 50% <100%> (+10%) ⬆️
oci/spec_unix.go 98.37% <100%> (ø) ⬆️
oci/spec_opts_unix.go 21.77% <42.85%> (ø) ⬆️
oci/spec_opts.go 66.03% <57.14%> (+1.42%) ⬆️
remotes/docker/auth.go 63.82% <0%> (-3.97%) ⬇️
remotes/docker/status.go 21.42% <0%> (-3.58%) ⬇️
platforms/cpuinfo.go 4.65% <0%> (-1.01%) ⬇️
log/context.go 36.84% <0%> (-0.66%) ⬇️
namespaces/context.go 55% <0%> (-0.56%) ⬇️
errdefs/grpc.go 74.6% <0%> (-0.4%) ⬇️
... and 55 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 80272bb...62e22a9. Read the comment docs.

@williammartin
Copy link
Copy Markdown

Have asked the team to take a look, thanks.

@crosbymichael
Copy link
Copy Markdown
Member Author

Any word on this fixing the issues you are seeing?

@crosbymichael
Copy link
Copy Markdown
Member Author

crosbymichael commented May 16, 2018

@containerd/containerd-maintainers you can review this as well

Copy link
Copy Markdown
Member

@estesp estesp left a comment

Choose a reason for hiding this comment

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

LGTM

@ehazlett
Copy link
Copy Markdown
Member

LGTM

@williammartin
Copy link
Copy Markdown

Thanks for chasing and sorry for the delay.

The place where we get this error is actually on

func WithSpec(s *specs.Spec, opts ...oci.SpecOpts) NewContainerOpts {
because we are still building the spec ourselves as a smaller change (https://github.com/cloudfoundry/guardian/blob/master/rundmc/runcontainerd/nerd/nerd.go#L27)

I did try to play the same trick by adding:

type Spec = specs.Spec

and changing the function signature to:

func WithSpec(s *Spec, opts ...oci.SpecOpts) NewContainerOpts

But it didn't resolve anything (not sure if the type is leaking somewhere else):

../../rundmc/runcontainerd/nerd/nerd.go:27:85: cannot use spec (type *"github.com/opencontainers/runtime-spec/specs-go".Spec) as type *"github.com/containerd/containerd/vendor/github.com/opencontainers/runtime-spec/specs-go".Spec in argument to containerd.WithSpec

Can you point me to where you found that type alias would resolve vendor conflicts? I can’t seem to find anything about it and in a simplified case (https://github.com/williammartin/alias) type aliasing doesn’t seem to resolve conflicts (but it’s totally possible I’m doing something stupid). Maybe you can fill me in on what I’m missing.

Finally, because of this, and a bunch of other reasons that have built up over time, we are in the process of switching all our vendoring to a more suitable scheme (dep or vndr) which as discussed previously, should flatten the vendor hierarchy and avoid this whole thing altogether. As such, I suspect we won't really need anything from containerd. Can update you as we progress with that, since it's halfway through in a weird state right now. Thanks.

@crosbymichael
Copy link
Copy Markdown
Member Author

@williammartin you actually have to change your implementations also to use oci.Spec instead of specs.Spec

This allows Go to build third party packages correctly without vendoring
issues what want to create their own SpecOpts.

Fixes containerd#2289

Signed-off-by: Michael Crosby <[email protected]>
@crosbymichael
Copy link
Copy Markdown
Member Author

@williammartin i also pushed an update changing the container opts to oci.Spec.

I believe if you change your calling code from having specs.Spec to oci.Spec it will resolve the issues you are seeing like it did for me. I was having the same issues.

@williammartin
Copy link
Copy Markdown

@crosbymichael Ah you're right, when I did that in my test example it seemed to work. I can give this a go in Garden when I have a spare moment (infrequently I'm afraid!).

@dmcgowan
Copy link
Copy Markdown
Member

LGTM

@dmcgowan dmcgowan merged commit 8ea01cc into containerd:master May 22, 2018
@crosbymichael crosbymichael deleted the spec-alias branch May 22, 2018 18:25
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

Successfully merging this pull request may close these issues.

6 participants