Skip to content
This repository was archived by the owner on Jul 25, 2019. It is now read-only.

Add more HostSubnet logging #296

Merged
merged 1 commit into from
Apr 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions plugins/osdn/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ type OsdnController struct {
// Called by plug factory functions to initialize the generic plugin instance
func (oc *OsdnController) BaseInit(registry *Registry, pluginHooks PluginHooks, multitenant bool, hostname string, selfIP string) error {

log.Infof("Starting with configured hostname '%s' (IP '%s')", hostname, selfIP)

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, but that's after the fixups. I'd like to see what the configured/command-line values are too.

if hostname == "" {
output, err := kexec.New().Command("uname", "-n").CombinedOutput()
if err != nil {
Expand Down Expand Up @@ -280,3 +282,7 @@ func GetPodContainerID(pod *kapi.Pod) string {
}
return ""
}

func HostSubnetToString(subnet *osapi.HostSubnet) string {
return fmt.Sprintf("%s [host: '%s'] [ip: '%s'] [subnet: '%s']", subnet.Name, subnet.Host, subnet.HostIP, subnet.Subnet)
}
5 changes: 3 additions & 2 deletions plugins/osdn/ovs/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/openshift/openshift-sdn/pkg/ipcmd"
"github.com/openshift/openshift-sdn/pkg/netutils"
"github.com/openshift/openshift-sdn/pkg/ovs"
"github.com/openshift/openshift-sdn/plugins/osdn"
osapi "github.com/openshift/origin/pkg/sdn/api"

kapi "k8s.io/kubernetes/pkg/api"
Expand Down Expand Up @@ -333,7 +334,7 @@ func (plugin *ovsPlugin) GetName() string {
}

func (plugin *ovsPlugin) AddHostSubnetRules(subnet *osapi.HostSubnet) {
glog.V(5).Infof("AddHostSubnetRules for %v", subnet)
glog.Infof("AddHostSubnetRules for %s", osdn.HostSubnetToString(subnet))
otx := ovs.NewTransaction(BR)

otx.AddFlow("table=1, priority=100, tun_src=%s, actions=goto_table:5", subnet.HostIP)
Expand All @@ -347,7 +348,7 @@ func (plugin *ovsPlugin) AddHostSubnetRules(subnet *osapi.HostSubnet) {
}

func (plugin *ovsPlugin) DeleteHostSubnetRules(subnet *osapi.HostSubnet) {
glog.V(5).Infof("DeleteHostSubnetRules for %v", subnet)
glog.Infof("DeleteHostSubnetRules for %s", osdn.HostSubnetToString(subnet))

otx := ovs.NewTransaction(BR)
otx.DeleteFlows("table=1, tun_src=%s", subnet.HostIP)
Expand Down
5 changes: 2 additions & 3 deletions plugins/osdn/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,15 @@ func (registry *Registry) DeleteSubnet(nodeName string) error {
return registry.oClient.HostSubnets().Delete(nodeName)
}

func (registry *Registry) CreateSubnet(nodeName, nodeIP, subnetCIDR string) error {
func (registry *Registry) CreateSubnet(nodeName, nodeIP, subnetCIDR string) (*osapi.HostSubnet, error) {
hs := &osapi.HostSubnet{
TypeMeta: unversioned.TypeMeta{Kind: "HostSubnet"},
ObjectMeta: kapi.ObjectMeta{Name: nodeName},
Host: nodeName,
HostIP: nodeIP,
Subnet: subnetCIDR,
}
_, err := registry.oClient.HostSubnets().Create(hs)
return err
return registry.oClient.HostSubnets().Create(hs)
}

func (registry *Registry) WatchSubnets(receiver chan<- *HostSubnetEvent) error {
Expand Down
12 changes: 8 additions & 4 deletions plugins/osdn/subnets.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ func (oc *OsdnController) SubnetStartMaster(clusterNetwork *net.IPNet, hostSubne
if err := oc.validateNode(sub.HostIP); err != nil {
// Don't error out; just warn so the error can be corrected with 'oc'
log.Errorf("Failed to validate HostSubnet %s: %v", err)
} else {
log.Infof("Found existing HostSubnet %s", HostSubnetToString(&sub))
}
}

Expand All @@ -44,12 +46,12 @@ func (oc *OsdnController) addNode(nodeName string, nodeIP string) error {
if err != nil {
return fmt.Errorf("Error allocating network for node %s: %v", nodeName, err)
}
err = oc.Registry.CreateSubnet(nodeName, nodeIP, sn.String())
sub, err := oc.Registry.CreateSubnet(nodeName, nodeIP, sn.String())
if err != nil {
return fmt.Errorf("Error writing subnet %v to etcd for node %s: %v", sn, nodeName, err)
}

log.Infof("Created HostSubnet %v for node %s (%s)", sn, nodeName, nodeIP)
log.Infof("Created HostSubnet %s", HostSubnetToString(sub))
return nil
}

Expand All @@ -68,7 +70,7 @@ func (oc *OsdnController) deleteNode(nodeName string) error {
return fmt.Errorf("Error deleting subnet %v for node %q: %v", sub, nodeName, err)
}

log.Infof("Deleted HostSubnet %v for node %s", sub, nodeName)
log.Infof("Deleted HostSubnet %s", HostSubnetToString(sub))
return nil
}

Expand Down Expand Up @@ -118,6 +120,7 @@ func (oc *OsdnController) initSelfSubnet() error {
return fmt.Errorf("Failed to validate own HostSubnet: %v", err)
}

log.Infof("Found local HostSubnet %s", HostSubnetToString(subnet))
oc.localSubnet = subnet
return nil
}
Expand Down Expand Up @@ -155,11 +158,12 @@ func watchNodes(oc *OsdnController) {
continue
}
if nodeErr == nil {
err = oc.Registry.CreateSubnet(ev.Node.Name, nodeIP, sub.Subnet)
_, err := oc.Registry.CreateSubnet(ev.Node.Name, nodeIP, sub.Subnet)
if err != nil {
log.Errorf("Error creating subnet for node %s, ip %s: %v", ev.Node.Name, sub.HostIP, err)
continue
}
log.Infof("Updated HostSubnet %s to HostIP %s", HostSubnetToString(sub), nodeIP)
} else {
log.Errorf("Ignoring creating invalid node %s/%s: %v", ev.Node.Name, nodeIP, nodeErr)
}
Expand Down