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

types changes for 1.0.0 #783

Merged
merged 4 commits into from
Nov 19, 2020
Merged

types changes for 1.0.0 #783

merged 4 commits into from
Nov 19, 2020

Conversation

dcbw
Copy link
Member

@dcbw dcbw commented Aug 12, 2020

Moving to spec 1.0.0 requires more complicated conversions, so
put the converter determination logic in a separate module that
any of the types can call to convert between arbitrary versions.
This is necessary to ensure the types don't have import cycles.

This also implements downconversion, which we never claimed
not to support, but didn't implement.

It also verifies that the Result object unmarshalled by
each result type's NewResult() function is actually supported
by the result type. This is a potentially breaking change as
this was not previously done, and for example may now fail
attempts to read a cached PrevResult written by a previous
version.

Signed-off-by: Dan Williams dcbw@redhat.com

@dcbw dcbw force-pushed the 100 branch 2 times, most recently from fd6dbbb to 3d29b0b Compare August 13, 2020 15:14
@coveralls
Copy link

coveralls commented Aug 13, 2020

Coverage Status

Coverage decreased (-4.4%) to 70.781% when pulling 7555ca3 on dcbw:100 into 6fc72a4 on containernetworking:master.

@dcbw dcbw changed the title [wip] types changes for 1.0 types changes for 1.0 Aug 27, 2020
@dcbw dcbw changed the title types changes for 1.0 types changes for 1.0.0 Aug 27, 2020
@dcbw
Copy link
Member Author

dcbw commented Aug 27, 2020

@containernetworking/cni-maintainers no longer WIP, please review. Thanks!

@dcbw dcbw force-pushed the 100 branch 2 times, most recently from 843df8a to 5e8469c Compare August 28, 2020 19:22
Copy link
Contributor

@bboreham bboreham left a comment

Choose a reason for hiding this comment

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

I have a few questions.

pkg/types/convert/convert.go Outdated Show resolved Hide resolved
Comment on lines 70 to 75
func copyIPConfig(from *IPConfig) *IPConfig {
if from == nil {
return nil
}
return from.Copy()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not very clear why this function exists. The if nil bit could go in IPConfig.Copy.

Copy link
Member Author

Choose a reason for hiding this comment

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

@bboreham can't do that, becuase .Copy() is a struct method, and if you can't do <nil>.Copy() right?

Copy link
Contributor

Choose a reason for hiding this comment

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

I haven't tried it, but I can't currently see why not. In Go, nil can have a type, but I think all the calls to this one would be statically dispatched.

libcni/api_test.go Show resolved Hide resolved

var SupportedVersions = []string{"0.3.0", "0.3.1", ImplementedSpecVersion}
var SupportedVersions = []string{ImplementedSpecVersion}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this right? Looks like we would still support 0.3.x and 0.4.0.

Copy link
Member Author

Choose a reason for hiding this comment

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

No, because 1.0.0 doesn't have the "Version" field in the IPConfig struct and perhaps we'll make other changes before final.

Copy link
Member Author

Choose a reason for hiding this comment

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

Follow-up: Bryan was really asking why the plugins export this at all; there are only two uses in the reference plugins and those are for error-checking and can be trivially replaced.

Copy link
Contributor

@bboreham bboreham left a comment

Choose a reason for hiding this comment

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

LGTM!

Moving to spec 1.0.0 requires more complicated conversions, so
put the converter determination logic in a separate module that
any of the types can call to convert between arbitrary versions.
This is necessary to ensure the types don't have import cycles.

This also implements downconversion, which we never claimed
*not* to support, but didn't implement.

It also verifies that the Result object unmarshalled by
each result type's NewResult() function is actually supported
by the result type. This is a potentially breaking change as
this was not previously done, and for example may now fail
attempts to read a cached PrevResult written by a previous
version.

Signed-off-by: Dan Williams <dcbw@redhat.com>
@dcbw dcbw force-pushed the 100 branch 2 times, most recently from 839d9b0 to dbe3a52 Compare October 28, 2020 17:17
@dcbw
Copy link
Member Author

dcbw commented Oct 29, 2020

@squeed @jellonek @mccv1r0 @bboreham updated, I think this is final now

Only change this time is removal of the IPConfig "Version" field
which was deemed redundant.

Signed-off-by: Dan Williams <dcbw@redhat.com>
The testcase checking if a prevResult was invalid is not actually
useful, because it was testing that an empty prevResult could be
unmarshalled. But due to an oversight, prevResults may not have
a CNIVersion key, which is all we can check for validity.

Signed-off-by: Dan Williams <dcbw@redhat.com>
…esses

Redundant and easily determined from the address itself.

Signed-off-by: Dan Williams <dcbw@redhat.com>
Copy link
Contributor

@bboreham bboreham left a comment

Choose a reason for hiding this comment

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

Let's go ahead with this and see if anything shakes out when we link with plugins and runtimes.

@dcbw dcbw merged commit d1e1ae3 into containernetworking:master Nov 19, 2020
jmanero added a commit to jmanero/cni-plugins that referenced this pull request Dec 20, 2020
github.com/containernetworking/cni/pkg/types/current has moved to
github.com/containernetworking/cni/pkg/types/040

See containernetworking/cni#783
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.

3 participants