-
Notifications
You must be signed in to change notification settings - Fork 9
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
Dualstack Network Support #549
Open
majst01
wants to merge
35
commits into
master
Choose a base branch
from
dualstack-support
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 20 commits
Commits
Show all changes
35 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 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
91 changes: 91 additions & 0 deletions
91
cmd/metal-api/internal/datastore/migrations/07_childprefixlength.go
This file contains 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,91 @@ | ||
package migrations | ||
|
||
import ( | ||
"net/netip" | ||
|
||
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 { | ||
// In theory this might be set in a partition, but in reality its not set anywhere | ||
PrivateNetworkPrefixLength uint8 `rethinkdb:"privatenetworkprefixlength"` | ||
} | ||
datastore.MustRegisterMigration(datastore.Migration{ | ||
Name: "migrate partition.childprefixlength to tenant super network", | ||
Version: 7, | ||
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 ( | ||
af metal.AddressFamily | ||
defaultChildPrefixLength = metal.ChildPrefixLength{} | ||
) | ||
// FIXME check all prefixes | ||
parsed, err := netip.ParsePrefix(new.Prefixes[0].String()) | ||
if err != nil { | ||
return err | ||
} | ||
if parsed.Addr().Is4() { | ||
af = metal.IPv4AddressFamily | ||
defaultChildPrefixLength[af] = 22 | ||
} | ||
if parsed.Addr().Is6() { | ||
af = metal.IPv6AddressFamily | ||
defaultChildPrefixLength[af] = 64 | ||
} | ||
|
||
if new.AddressFamilies == nil { | ||
new.AddressFamilies = make(map[metal.AddressFamily]bool) | ||
} | ||
new.AddressFamilies[af] = true | ||
|
||
if new.PrivateSuper { | ||
if new.DefaultChildPrefixLength == nil { | ||
new.DefaultChildPrefixLength = make(map[metal.AddressFamily]uint8) | ||
} | ||
if partition.PrivateNetworkPrefixLength > 0 { | ||
new.DefaultChildPrefixLength[af] = partition.PrivateNetworkPrefixLength | ||
} else { | ||
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 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 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 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 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.
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.
Not sure if this was ok to delete