Skip to content
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

Add logging to the GLBCFromVIP for debugging #338

Merged
merged 1 commit into from
Jun 15, 2018
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
2 changes: 1 addition & 1 deletion cmd/e2e-test/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func TestBasic(t *testing.T) {
vip := ing.Status.LoadBalancer.Ingress[0].IP
gclb, err := fuzz.GCLBForVIP(context.Background(), Framework.Cloud, vip, fuzz.FeatureValidators(features.All))
if err != nil {
t.Fatalf("Error getting GCP resources for LB with IP = %q", vip)
t.Fatalf("Error getting GCP resources for LB with IP = %q: %v", vip, err)
}
// Do some cursory checks on the GCP objects.
if len(gclb.ForwardingRule) != tc.numForwardingRules {
Expand Down
28 changes: 22 additions & 6 deletions pkg/fuzz/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,24 +109,25 @@ func GCLBForVIP(ctx context.Context, c cloud.Cloud, vip string, validators []Fea
gclb := NewGCLB()
allGFRs, err := c.GlobalForwardingRules().List(ctx, filter.None)
if err != nil {
glog.Warningf("Error listing forwarding rules: %v", err)
return nil, err
}

var urlMapKey *meta.Key

var gfrs []*compute.ForwardingRule
for _, gfr := range allGFRs {
if gfr.IPAddress == vip {
gfrs = append(gfrs, gfr)
}
}

var urlMapKey *meta.Key
for _, gfr := range gfrs {
frKey := meta.GlobalKey(gfr.Name)
gclb.ForwardingRule[*frKey] = &ForwardingRule{GA: gfr}
if hasAlphaResource("forwardingRule", validators) {
fr, err := c.AlphaForwardingRules().Get(ctx, frKey)
if err != nil {
glog.Warningf("Error getting alpha forwarding rules: %v", err)
return nil, err
}
gclb.ForwardingRule[*frKey].Alpha = fr
Expand All @@ -138,12 +139,14 @@ func GCLBForVIP(ctx context.Context, c cloud.Cloud, vip string, validators []Fea
// ForwardingRule => TargetProxy
resID, err := cloud.ParseResourceURL(gfr.Target)
if err != nil {
glog.Warningf("Error parsing Target (%q): %v", gfr.Target, err)
return nil, err
}
switch resID.Resource {
case "targetHttpProxies":
p, err := c.TargetHttpProxies().Get(ctx, resID.Key)
if err != nil {
glog.Warningf("Error getting TargetHttpProxy %s: %v", resID.Key, err)
return nil, err
}
gclb.TargetHTTPProxy[*resID.Key] = &TargetHTTPProxy{GA: p}
Expand All @@ -153,12 +156,20 @@ func GCLBForVIP(ctx context.Context, c cloud.Cloud, vip string, validators []Fea

urlMapResID, err := cloud.ParseResourceURL(p.UrlMap)
if err != nil {
panic(err)
glog.Warningf("Error parsing urlmap URL (%q): %v", p.UrlMap, err)
return nil, err
}
if urlMapKey == nil {
urlMapKey = urlMapResID.Key
}
if *urlMapKey != *urlMapResID.Key {
glog.Warningf("Error targetHttpProxy references are not the same (%s != %s)", *urlMapKey, *urlMapResID.Key)
return nil, fmt.Errorf("targetHttpProxy references are not the same: %+v != %+v", *urlMapKey, *urlMapResID.Key)
}
urlMapKey = urlMapResID.Key
case "targetHttpsProxies":
p, err := c.TargetHttpsProxies().Get(ctx, resID.Key)
if err != nil {
glog.Warningf("Error getting targetHttpsProxy (%s): %v", resID.Key, err)
return nil, err
}
gclb.TargetHTTPSProxy[*resID.Key] = &TargetHTTPSProxy{GA: p}
Expand All @@ -168,10 +179,15 @@ func GCLBForVIP(ctx context.Context, c cloud.Cloud, vip string, validators []Fea

urlMapResID, err := cloud.ParseResourceURL(p.UrlMap)
if err != nil {
panic(err)
glog.Warningf("Error parsing urlmap URL (%q): %v", p.UrlMap, err)
return nil, err
}
if urlMapKey == nil {
urlMapKey = urlMapResID.Key
}
if *urlMapKey != *urlMapResID.Key {
return nil, fmt.Errorf("%+v != %+v", *urlMapKey, *urlMapResID.Key) // XXX
glog.Warningf("Error targetHttpsProxy references are not the same (%s != %s)", *urlMapKey, *urlMapResID.Key)
return nil, fmt.Errorf("targetHttpsProxy references are not the same: %+v != %+v", *urlMapKey, *urlMapResID.Key)
}
default:
glog.Errorf("Unhandled resource: %q, grf = %+v", resID.Resource, gfr)
Expand Down