mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 18:24:07 +00:00
Cleanup firewalls, add nginx ingress to presubmit
This commit is contained in:
parent
5e44666fc1
commit
f609546b34
@ -421,7 +421,7 @@ func (j *federationTestJig) waitForFederatedIngress() {
|
|||||||
for _, p := range rules.IngressRuleValue.HTTP.Paths {
|
for _, p := range rules.IngressRuleValue.HTTP.Paths {
|
||||||
route := fmt.Sprintf("%v://%v%v", proto, address, p.Path)
|
route := fmt.Sprintf("%v://%v%v", proto, address, p.Path)
|
||||||
framework.Logf("Testing route %v host %v with simple GET", route, rules.Host)
|
framework.Logf("Testing route %v host %v with simple GET", route, rules.Host)
|
||||||
ExpectNoError(pollURL(route, rules.Host, lbPollTimeout, timeoutClient, false))
|
ExpectNoError(pollURL(route, rules.Host, lbPollTimeout, lbPollInterval, timeoutClient, false))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ const (
|
|||||||
nameLenLimit = 62
|
nameLenLimit = 62
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = framework.KubeDescribe("Loadbalancing: L7 [Feature:Ingress]", func() {
|
var _ = framework.KubeDescribe("Loadbalancing: L7", func() {
|
||||||
defer GinkgoRecover()
|
defer GinkgoRecover()
|
||||||
var (
|
var (
|
||||||
ns string
|
ns string
|
||||||
@ -130,10 +130,10 @@ var _ = framework.KubeDescribe("Loadbalancing: L7 [Feature:Ingress]", func() {
|
|||||||
|
|
||||||
By("waiting for Ingress to come up with ip: " + ip)
|
By("waiting for Ingress to come up with ip: " + ip)
|
||||||
httpClient := buildInsecureClient(reqTimeout)
|
httpClient := buildInsecureClient(reqTimeout)
|
||||||
ExpectNoError(pollURL(fmt.Sprintf("https://%v/", ip), "", lbPollTimeout, httpClient, false))
|
ExpectNoError(pollURL(fmt.Sprintf("https://%v/", ip), "", lbPollTimeout, jig.pollInterval, httpClient, false))
|
||||||
|
|
||||||
By("should reject HTTP traffic")
|
By("should reject HTTP traffic")
|
||||||
ExpectNoError(pollURL(fmt.Sprintf("http://%v/", ip), "", lbPollTimeout, httpClient, true))
|
ExpectNoError(pollURL(fmt.Sprintf("http://%v/", ip), "", lbPollTimeout, jig.pollInterval, httpClient, true))
|
||||||
|
|
||||||
// TODO: uncomment the restart test once we have a way to synchronize
|
// TODO: uncomment the restart test once we have a way to synchronize
|
||||||
// and know that the controller has resumed watching. If we delete
|
// and know that the controller has resumed watching. If we delete
|
||||||
@ -151,7 +151,7 @@ var _ = framework.KubeDescribe("Loadbalancing: L7 [Feature:Ingress]", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Time: borderline 5m, slow by design
|
// Time: borderline 5m, slow by design
|
||||||
framework.KubeDescribe("Nginx [Slow]", func() {
|
framework.KubeDescribe("Nginx", func() {
|
||||||
var nginxController *NginxIngressController
|
var nginxController *NginxIngressController
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
@ -188,6 +188,9 @@ var _ = framework.KubeDescribe("Loadbalancing: L7 [Feature:Ingress]", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("should conform to Ingress spec", func() {
|
It("should conform to Ingress spec", func() {
|
||||||
|
// Poll more frequently to reduce e2e completion time.
|
||||||
|
// This test runs in presubmit.
|
||||||
|
jig.pollInterval = 5 * time.Second
|
||||||
conformanceTests = createComformanceTests(jig, ns)
|
conformanceTests = createComformanceTests(jig, ns)
|
||||||
for _, t := range conformanceTests {
|
for _, t := range conformanceTests {
|
||||||
By(t.entryLog)
|
By(t.entryLog)
|
||||||
|
@ -90,6 +90,9 @@ type testJig struct {
|
|||||||
// `kubernetes.io/ingress.class`. It's added to all ingresses created by
|
// `kubernetes.io/ingress.class`. It's added to all ingresses created by
|
||||||
// this jig.
|
// this jig.
|
||||||
class string
|
class string
|
||||||
|
|
||||||
|
// The interval used to poll urls
|
||||||
|
pollInterval time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
type conformanceTests struct {
|
type conformanceTests struct {
|
||||||
@ -170,7 +173,7 @@ func createComformanceTests(jig *testJig, ns string) []conformanceTests {
|
|||||||
})
|
})
|
||||||
By("Checking that " + pathToFail + " is not exposed by polling for failure")
|
By("Checking that " + pathToFail + " is not exposed by polling for failure")
|
||||||
route := fmt.Sprintf("http://%v%v", jig.address, pathToFail)
|
route := fmt.Sprintf("http://%v%v", jig.address, pathToFail)
|
||||||
ExpectNoError(pollURL(route, updateURLMapHost, lbCleanupTimeout, &http.Client{Timeout: reqTimeout}, true))
|
ExpectNoError(pollURL(route, updateURLMapHost, lbCleanupTimeout, jig.pollInterval, &http.Client{Timeout: reqTimeout}, true))
|
||||||
},
|
},
|
||||||
fmt.Sprintf("Waiting for path updates to reflect in L7"),
|
fmt.Sprintf("Waiting for path updates to reflect in L7"),
|
||||||
},
|
},
|
||||||
@ -179,9 +182,9 @@ func createComformanceTests(jig *testJig, ns string) []conformanceTests {
|
|||||||
|
|
||||||
// pollURL polls till the url responds with a healthy http code. If
|
// pollURL polls till the url responds with a healthy http code. If
|
||||||
// expectUnreachable is true, it breaks on first non-healthy http code instead.
|
// expectUnreachable is true, it breaks on first non-healthy http code instead.
|
||||||
func pollURL(route, host string, timeout time.Duration, httpClient *http.Client, expectUnreachable bool) error {
|
func pollURL(route, host string, timeout time.Duration, interval time.Duration, httpClient *http.Client, expectUnreachable bool) error {
|
||||||
var lastBody string
|
var lastBody string
|
||||||
pollErr := wait.PollImmediate(lbPollInterval, timeout, func() (bool, error) {
|
pollErr := wait.PollImmediate(interval, timeout, func() (bool, error) {
|
||||||
var err error
|
var err error
|
||||||
lastBody, err = simpleGET(httpClient, route, host)
|
lastBody, err = simpleGET(httpClient, route, host)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -596,19 +599,18 @@ func (cont *GCEIngressController) canDelete(resourceName, creationTimestamp stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (cont *GCEIngressController) deleteFirewallRule(del bool) (msg string) {
|
func (cont *GCEIngressController) deleteFirewallRule(del bool) (msg string) {
|
||||||
gceCloud := cont.cloud.Provider.(*gcecloud.GCECloud)
|
fwList := []compute.Firewall{}
|
||||||
fwName := fmt.Sprintf("k8s-fw-l7--%v", cont.UID)
|
regex := fmt.Sprintf("%vfw-l7%v.*", k8sPrefix, clusterDelimiter)
|
||||||
fw, err := gceCloud.GetFirewall(fwName)
|
gcloudList("firewall-rules", regex, cont.cloud.ProjectID, &fwList)
|
||||||
if err != nil {
|
if len(fwList) != 0 {
|
||||||
if cont.isHTTPErrorCode(err, http.StatusNotFound) {
|
for _, f := range fwList {
|
||||||
return msg
|
if !cont.canDelete(f.Name, f.CreationTimestamp, del) {
|
||||||
}
|
continue
|
||||||
return fmt.Sprintf("Failed to get fw %v: %v", fwName, err)
|
}
|
||||||
}
|
msg += fmt.Sprintf("%v (firewall rule)\n", f.Name)
|
||||||
msg = fmt.Sprintf("%v (firewall-rule)\n", fw.Name)
|
if del {
|
||||||
if del {
|
gcloudDelete("firewall-rules", f.Name, cont.cloud.ProjectID)
|
||||||
if err := gceCloud.DeleteFirewall(fw.Name); err != nil && cont.isHTTPErrorCode(err, http.StatusNotFound) {
|
}
|
||||||
msg += fmt.Sprintf("Failed to delete %v: %v\n", fw.Name, err)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return msg
|
return msg
|
||||||
@ -833,7 +835,7 @@ func (j *testJig) waitForIngress() {
|
|||||||
j.curlServiceNodePort(j.ing.Namespace, p.Backend.ServiceName, int(p.Backend.ServicePort.IntVal))
|
j.curlServiceNodePort(j.ing.Namespace, p.Backend.ServiceName, int(p.Backend.ServicePort.IntVal))
|
||||||
route := fmt.Sprintf("%v://%v%v", proto, address, p.Path)
|
route := fmt.Sprintf("%v://%v%v", proto, address, p.Path)
|
||||||
framework.Logf("Testing route %v host %v with simple GET", route, rules.Host)
|
framework.Logf("Testing route %v host %v with simple GET", route, rules.Host)
|
||||||
ExpectNoError(pollURL(route, rules.Host, lbPollTimeout, timeoutClient, false))
|
ExpectNoError(pollURL(route, rules.Host, lbPollTimeout, j.pollInterval, timeoutClient, false))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -857,7 +859,7 @@ func (j *testJig) curlServiceNodePort(ns, name string, port int) {
|
|||||||
// TODO: Curl all nodes?
|
// TODO: Curl all nodes?
|
||||||
u, err := framework.GetNodePortURL(j.client, ns, name, port)
|
u, err := framework.GetNodePortURL(j.client, ns, name, port)
|
||||||
ExpectNoError(err)
|
ExpectNoError(err)
|
||||||
ExpectNoError(pollURL(u, "", 30*time.Second, &http.Client{Timeout: reqTimeout}, false))
|
ExpectNoError(pollURL(u, "", 30*time.Second, j.pollInterval, &http.Client{Timeout: reqTimeout}, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
// ingFromManifest reads a .json/yaml file and returns the rc in it.
|
// ingFromManifest reads a .json/yaml file and returns the rc in it.
|
||||||
@ -911,7 +913,7 @@ type GCEIngressController struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newTestJig(c clientset.Interface) *testJig {
|
func newTestJig(c clientset.Interface) *testJig {
|
||||||
return &testJig{client: c, rootCAs: map[string][]byte{}}
|
return &testJig{client: c, rootCAs: map[string][]byte{}, pollInterval: lbPollInterval}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NginxIngressController manages implementation details of Ingress on Nginx.
|
// NginxIngressController manages implementation details of Ingress on Nginx.
|
||||||
|
Loading…
Reference in New Issue
Block a user