-
Notifications
You must be signed in to change notification settings - Fork 9
Dualstack Network Support #549
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
Merged
Merged
Changes from 72 commits
Commits
Show all changes
81 commits
Select commit
Hold shift + click to select a range
5ea7ea6
IPv6 Support
majst01 22d916e
More tests
majst01 e8571c9
Validate Prefixes and DestinationPrefixes on create and update network
majst01 59c7511
Constify defaultChildPrefixlength
majst01 9f52dfd
Merge branch 'master' of https://github.com/metal-stack/metal-api int…
majst01 89a0857
Merge branch 'master' of https://github.com/metal-stack/metal-api int…
majst01 aae9274
Support DualStack Networks
majst01 1b09d5d
Merge branch 'master' of https://github.com/metal-stack/metal-api int…
majst01 87a2a98
Merge branch 'master' of https://github.com/metal-stack/metal-api int…
majst01 23e4cbd
Merge branch 'master' of https://github.com/metal-stack/metal-api int…
majst01 a175469
Merge branch 'master' of https://github.com/metal-stack/metal-api int…
majst01 c519d3b
Merge branch 'master' of https://github.com/metal-stack/metal-api int…
majst01 a1575ef
Merge branch 'master' of https://github.com/metal-stack/metal-api int…
majst01 f553164
Merge master
majst01 fa47c76
Merge branch 'master' of https://github.com/metal-stack/metal-api int…
majst01 6430ea1
Make additional announcable cidrs configurable per tenant super network
majst01 5f3287e
Merge additionalannouncablecidrs in
majst01 1822069
Merge master
majst01 72ac513
satisfy linter
majst01 82cc73e
Merge master
majst01 d2cb195
sanitize go.mod
majst01 d408762
Merge branch 'master' of https://github.com/metal-stack/metal-api int…
majst01 8f06d84
Merge branch 'master' of https://github.com/metal-stack/metal-api int…
majst01 10f49c7
Merge branch 'master' of https://github.com/metal-stack/metal-api int…
majst01 88835d4
Merge branch 'master' into dualstack-support
majst01 02a518f
Merge master
majst01 44c8825
Remove false comment
majst01 fbe6a32
Merge branch 'master' of https://github.com/metal-stack/metal-api int…
majst01 7568f8e
Updates
majst01 9db0e6e
Merge master
majst01 84c63ad
Merge branch 'master' of https://github.com/metal-stack/metal-api int…
majst01 43dc320
Merge branch 'master' into dualstack-support
majst01 5719737
merge master
majst01 576df4a
Merge branch 'dualstack-support' of https://github.com/metal-stack/me…
majst01 2e72212
Introduce a type
majst01 f2da96e
Merge branch 'master' into dualstack-support
majst01 bd57dcb
Merge master
majst01 343ef3b
Merge branch 'master' into dualstack-support
majst01 f313f41
Merge branch 'master' of https://github.com/metal-stack/metal-api int…
majst01 4bb6603
Merge branch 'master' into dualstack-support
majst01 fbf1970
More consts
majst01 03c2436
Merge branch 'master' of https://github.com/metal-stack/metal-api int…
majst01 e726090
Merge branch 'master' into dualstack-support
majst01 c9c4b7e
Allow update DefaultChildPrefixLength
majst01 5e73c10
Do not allow mixed AddressFamilies in static firewall rules
majst01 3b7bb28
Better naming
majst01 a1a3428
If no Addressfamily is given during allocateIP in a ipv6 only network…
majst01 391d997
Better error messages on firewall rule validation
majst01 3fd8505
Simplify addressfamilies
majst01 3cc62cf
Better network usage
majst01 94bc6e8
Omit unused afs in consumption
majst01 ce53bcd
Fix test
majst01 a374b2c
Server side filtering by addressfamily for network and ip
majst01 6b2c3a8
Server side filtering by addressfamily for network and ip
majst01 9d1c340
Merge branch 'master' of https://github.com/metal-stack/metal-api int…
majst01 26a9b5e
Merge master
majst01 d3610e8
No addressfamilies in response
majst01 9ee694a
Fix typo
majst01 d964c1b
Update deps
majst01 04a84e5
Introduce helper function.
Gerrit91 e38db83
Fix ip query
majst01 60c9d8a
First bunch of review findings
majst01 0d64c98
Small fix
majst01 ff87efa
Validate Addressfamily
majst01 de2aee0
satisfy linter
majst01 2c79ab0
Better validation
majst01 66d8c71
Merge branch 'master' of https://github.com/metal-stack/metal-api int…
majst01 afd3f26
Small improvement
majst01 8a118c5
Better migration code
majst01 ce9b626
Linter fix
majst01 f2d560e
More validation
majst01 cd675fb
Merge branch 'master' into dualstack-support
Gerrit91 a21889e
Divide into validate and convert
majst01 7760e23
Add test for validation, and fix actual bug
majst01 b340472
Get rid of extra method to validate afs
majst01 76c3614
Do not store addressfamily in the network
majst01 091b132
Reuse existing conversions
majst01 df787e3
Reuse existing conversions
majst01 6b0fc18
Last fixes
majst01 84d154a
Fix linter config
majst01 ca9a6f4
merge master
majst01 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
cmd/metal-api/internal/datastore/migrations/08_childprefixlength.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| package migrations | ||
|
|
||
| import ( | ||
| "net/netip" | ||
| "slices" | ||
|
|
||
| r "gopkg.in/rethinkdb/rethinkdb-go.v6" | ||
|
|
||
| "github.com/metal-stack/metal-api/cmd/metal-api/internal/datastore" | ||
| "github.com/metal-stack/metal-api/cmd/metal-api/internal/metal" | ||
| ) | ||
|
|
||
| func init() { | ||
| type tmpPartition struct { | ||
| PrivateNetworkPrefixLength uint8 `rethinkdb:"privatenetworkprefixlength"` | ||
| } | ||
| datastore.MustRegisterMigration(datastore.Migration{ | ||
| Name: "migrate partition.childprefixlength to tenant super network", | ||
| Version: 8, | ||
| Up: func(db *r.Term, session r.QueryExecutor, rs *datastore.RethinkStore) error { | ||
| nws, err := rs.ListNetworks() | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| for _, old := range nws { | ||
| cursor, err := db.Table("partition").Get(old.PartitionID).Run(session) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| if cursor.IsNil() { | ||
| _ = cursor.Close() | ||
| continue | ||
| } | ||
| var partition tmpPartition | ||
| err = cursor.One(&partition) | ||
| if err != nil { | ||
| _ = cursor.Close() | ||
| return err | ||
| } | ||
| err = cursor.Close() | ||
| if err != nil { | ||
| return err | ||
| } | ||
| new := old | ||
|
|
||
| var ( | ||
| afs metal.AddressFamilies | ||
| defaultChildPrefixLength = metal.ChildPrefixLength{} | ||
| ) | ||
| for _, prefix := range new.Prefixes { | ||
| parsed, err := netip.ParsePrefix(prefix.String()) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| var af metal.AddressFamily | ||
| if parsed.Addr().Is4() { | ||
| af = metal.IPv4AddressFamily | ||
| defaultChildPrefixLength[af] = 22 | ||
| } | ||
| if parsed.Addr().Is6() { | ||
| af = metal.IPv6AddressFamily | ||
| defaultChildPrefixLength[af] = 64 | ||
| } | ||
| if !slices.Contains(afs, af) { | ||
| afs = append(afs, af) | ||
| } | ||
| } | ||
| new.AddressFamilies = afs | ||
|
|
||
| if new.PrivateSuper { | ||
| if new.DefaultChildPrefixLength == nil { | ||
| new.DefaultChildPrefixLength = metal.ChildPrefixLength{} | ||
| } | ||
| if partition.PrivateNetworkPrefixLength > 0 { | ||
| defaultChildPrefixLength[metal.IPv4AddressFamily] = partition.PrivateNetworkPrefixLength | ||
| } | ||
| new.DefaultChildPrefixLength = defaultChildPrefixLength | ||
| } | ||
| err = rs.UpdateNetwork(&old, &new) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| } | ||
|
|
||
| _, err = db.Table("partition").Replace(r.Row.Without("privatenetworkprefixlength")).RunWrite(session) | ||
| return err | ||
| }, | ||
| }) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
TODO check if required to store AF in the db