mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 10:20:51 +00:00
Ensure the execHostnameTest() compares hostnames
We do not have guarantee that the agnhost's `/hostname` endpoint returns a hostname and not an FQDN. We also do not have guarantee a hostname gets passed to the execHostnameTest() function for comparison. So make sure we're comparing hostnames in execHostnameTest().
This commit is contained in:
parent
5f809703a6
commit
363ad4c3b3
@ -143,6 +143,8 @@ func execSourceIPTest(sourcePod v1.Pod, targetAddr string) (string, string) {
|
||||
|
||||
// execHostnameTest executes curl to access "/hostname" endpoint on target address
|
||||
// from given Pod to check the hostname of the target destination.
|
||||
// It also converts FQDNs to hostnames, so if an FQDN is passed as
|
||||
// targetHostname only the hostname part will be considered for comparison.
|
||||
func execHostnameTest(sourcePod v1.Pod, targetAddr, targetHostname string) {
|
||||
var (
|
||||
err error
|
||||
@ -166,8 +168,12 @@ func execHostnameTest(sourcePod v1.Pod, targetAddr, targetHostname string) {
|
||||
break
|
||||
}
|
||||
|
||||
// Ensure we're comparing hostnames and not FQDNs
|
||||
targetHostname = strings.Split(targetHostname, ".")[0]
|
||||
hostname := strings.TrimSpace(strings.Split(stdout, ".")[0])
|
||||
|
||||
framework.ExpectNoError(err)
|
||||
framework.ExpectEqual(strings.TrimSpace(stdout), targetHostname)
|
||||
framework.ExpectEqual(hostname, targetHostname)
|
||||
}
|
||||
|
||||
// createSecondNodePortService creates a service with the same selector as config.NodePortService and same HTTP Port
|
||||
|
Loading…
Reference in New Issue
Block a user