-
Notifications
You must be signed in to change notification settings - Fork 90
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
state, filter: Fix the interpretation of ifaces names #709
state, filter: Fix the interpretation of ifaces names #709
Conversation
b0fe982
to
98bc857
Compare
change: Fixed gofmt |
In order to ease the interpretation of the state yaml data, use a type structure that represents the basic root items of state: - interfaces - routes: - config - running In order to keep the generic nature of these items content, they use as value a generic Go interface{}. The filter helper functions, with this change, have been also made immutable. They now return the filtered values. Signed-off-by: Edward Haas <[email protected]>
98bc857
to
d735b2c
Compare
change: Do not expose the new state types |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a question
0390c71
to
1212087
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work I know how much time to end with this kind of solutions, added some coments to simplify stuff.
be618a0
to
651d6d6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/hold
First I want to see how so nmstate team is reporting that quotes are included and why we don't see it here.
Looks like problem is just with float64
@EdDev can you add a unit test for that ? |
Interfaces names with numeric values are accepted by the kernel. Introduce tests that checks the behavior when using numeric names. Signed-off-by: Edward Haas <[email protected]>
In scenarios where an interface name is composed of numbers in scientific notation without a dot, the application panics with a failure to extract a string type from a Go interface (which is actually a float64). In order to fix the problem, the parsing of the interface name is performed using a dedicated interface-state structure. Note: this change does not solve the problem of incorrectly representing valid scientific numeric values like `10e+02` as strings (they are now represented back as full integers: "1000"). This is due to the YAML-to-JSON conversion which does not obey to the defined member type. ref: yaml/pyyaml#173 Signed-off-by: Edward Haas <[email protected]>
This change solves the problem of incorrectly representing valid scientific numeric valuesi without a dot in them (e.g. `10e20`) as strings (e.g. represented back as `1000`). The problem originates from the YAML-to-JSON conversion which does not obey to the defined member type. Fixed by using the go-yaml package (which does not perform such a conversion from YAML to JSON). The go-yaml is used just to unmarshal the name from the original raw byte stream and update the state structure with the proper name string. Signed-off-by: Edward Haas <[email protected]>
651d6d6
to
4db577f
Compare
I have changed a bit the commits to show better what has been done and what each fixes. |
/lgtm We will do a follow up to try to use just one yaml parser. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: qinqon The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@EdDev: The following test failed, say
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
Is this a BUG FIX or a FEATURE ?:
/kind bug
What this PR does / why we need it:
In scenarios where an interface has only numeric characters, the
application panics with a failure to extract a string type from a Go
interface (which is actually a float64).
In order to fix the problem, the parsing of the interface name is performed
using a dedicated interface-state structure.
In addition, the representation of special numeric values that an interface name can have is also fixed, such that
0xfe
can be correctly represented back and not shown as an integer (254
).In order to support this, a type structure that represents the basic state root items has been used.
This structure includes:
In order to keep the generic nature of these items content,
they use as value a generic Go interface{}.
Special notes for your reviewer:
Release note: