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
allow special hostsubnets to force a vnid on egress packets #11817
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ package plugin | |
import ( | ||
"fmt" | ||
"net" | ||
"strconv" | ||
|
||
log "github.com/golang/glog" | ||
|
||
|
@@ -45,7 +46,7 @@ func (master *OsdnMaster) SubnetStartMaster(clusterNetwork *net.IPNet, hostSubne | |
return nil | ||
} | ||
|
||
func (master *OsdnMaster) addNode(nodeName string, nodeIP string) error { | ||
func (master *OsdnMaster) addNode(nodeName string, nodeIP string, hsAnnotations map[string]string) error { | ||
// Validate node IP before proceeding | ||
if err := master.networkInfo.validateNodeIP(nodeIP); err != nil { | ||
return err | ||
|
@@ -76,7 +77,7 @@ func (master *OsdnMaster) addNode(nodeName string, nodeIP string) error { | |
|
||
sub = &osapi.HostSubnet{ | ||
TypeMeta: kapiunversioned.TypeMeta{Kind: "HostSubnet"}, | ||
ObjectMeta: kapi.ObjectMeta{Name: nodeName}, | ||
ObjectMeta: kapi.ObjectMeta{Name: nodeName, Annotations: hsAnnotations}, | ||
Host: nodeName, | ||
HostIP: nodeIP, | ||
Subnet: sn.String(), | ||
|
@@ -174,7 +175,7 @@ func (master *OsdnMaster) watchNodes() { | |
// Node status is frequently updated by kubelet, so log only if the above condition is not met | ||
log.V(5).Infof("Watch %s event for Node %q", delta.Type, name) | ||
|
||
err = master.addNode(name, nodeIP) | ||
err = master.addNode(name, nodeIP, nil) | ||
if err != nil { | ||
return fmt.Errorf("error creating subnet for node %s, ip %s: %v", name, nodeIP, err) | ||
} | ||
|
@@ -220,7 +221,17 @@ func (master *OsdnMaster) watchSubnets() { | |
log.Errorf("Error in deleting annotated subnet from master, name: %s, ip %s: %v", name, hostIP, err) | ||
return nil | ||
} | ||
err = master.addNode(name, hostIP) | ||
var hsAnnotations map[string]string | ||
if vnid, ok := hs.Annotations[osapi.FixedVnidHost]; ok { | ||
vnidInt, err := strconv.Atoi(vnid) | ||
if err == nil && vnidInt >= 0 && uint32(vnidInt) <= osapi.MaxVNID { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. err == nil && uint32(vnidInt) >= osapi.MinVNID && uint32(vnidInt) <= osapi.MaxVNID ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MinVnid will not catch 0 |
||
hsAnnotations = make(map[string]string) | ||
hsAnnotations[osapi.FixedVnidHost] = strconv.Itoa(vnidInt) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check hard-coded vnid is in the valid range (0 to 2^24-1) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, fixing.. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any reason to allow arbitrary VNIDs? Without corresponding translation on the incoming side, this isn't very useful unless vnid==0. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There may be a choice to have the f5 for a particular project only. Then we will have the facility to change the value per deployment. |
||
} else { | ||
log.Errorf("Vnid %s is an invalid value for annotation %s. Annotation will be ignored.", vnid, osapi.FixedVnidHost) | ||
} | ||
} | ||
err = master.addNode(name, hostIP, hsAnnotations) | ||
if err != nil { | ||
log.Errorf("Error creating subnet for node %s, ip %s: %v", name, hostIP, err) | ||
return nil | ||
|
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.
This check is only valid for multi-tenant sdn plugin, should ignore for subnet plugin (osapi.IsOpenShiftMultitenantNetworkPlugin)
If we know that F5 with multi-tenant sdn plugin needs this hack, may be enforce osapi.FixedVnidHost to be present when osapi.AssignHostSubnetAnnotation is passed?
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.
I'd say it's fine to do this in both multitenant and single-tenant. Especially if we only support 0 for the fixed vnid.
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.
It's probably useful for single tenant also because the tunnel id at the f5 side is configured by the admin separately. This code will allow us to comply to that setting.