Change the v1b3 default for service ContainerPort

In v1b1 and v1b2 we choose the "first defined port" if you do not specify a
ContainerPort.  I am proposing that v1b3 just assume the ContainerPort is the
same as the service port unless explicitly provided.  This leaves named ports
for now, but that is under discussion on its own.

This is strictly compatible, though to implement this we have to leave the
internal objects with the looser behavior until v1b[12] die.  This also adds a
link dependency so that when we DO kill v1b[12] the endpoints controller will
blow up, prompting a fix.
This commit is contained in:
Tim Hockin
2015-03-01 13:34:57 -08:00
parent 3beca3a4e8
commit 5aadd6ecae
8 changed files with 65 additions and 1 deletions

View File

@@ -245,6 +245,27 @@ func FuzzerFor(t *testing.T, version string, src rand.Source) *fuzz.Fuzzer {
c.Fuzz(&http.Port)
c.Fuzz(&http.Host)
},
func(ss *api.ServiceSpec, c fuzz.Continue) {
// TODO: I wish I could say "fuzz myself but without the custom fuzz-func"
c.Fuzz(&ss.Port)
c.Fuzz(&ss.Protocol)
c.Fuzz(&ss.Selector)
c.Fuzz(&ss.PortalIP)
c.Fuzz(&ss.CreateExternalLoadBalancer)
c.Fuzz(&ss.PublicIPs)
c.Fuzz(&ss.SessionAffinity)
// TODO: would be great if types could voluntarily fuzz themselves.
kinds := []util.IntstrKind{util.IntstrInt, util.IntstrString}
ss.ContainerPort.Kind = kinds[c.Rand.Intn(len(kinds))]
switch ss.ContainerPort.Kind {
case util.IntstrInt:
ss.ContainerPort.IntVal = 1 + c.Rand.Intn(65535) // non-zero
ss.ContainerPort.StrVal = "" // needed because we reuse objects without zeroing them
case util.IntstrString:
ss.ContainerPort.StrVal = "x" + c.RandString() // non-empty
ss.ContainerPort.IntVal = 0 // needed because we reuse objects without zeroing them
}
},
)
return f
}