mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 10:51:29 +00:00
agnhost image: use actual DNS domain instead of hardcoded cluster.local
'agnhost' image uses hardcoded 'cluster.local' value for DNS domain. It leads to failure of a bunch of HPA tests when test cluster is configured to use custom DNS domain and there is no alias for default 'cluster.local' one. So, fix it by reusing it's own function for reading DNS domain suffixes. Signed-off-by: Valerii Ponomarov <kiparis.kh@gmail.com>
This commit is contained in:
parent
d9b576d61e
commit
c55b6cdbb4
@ -1,7 +1,7 @@
|
||||
dependencies:
|
||||
# agnhost: bump this one first
|
||||
- name: "agnhost"
|
||||
version: "2.23"
|
||||
version: "2.24"
|
||||
refPaths:
|
||||
- path: test/images/agnhost/VERSION
|
||||
match: \d.\d
|
||||
|
@ -1 +1 @@
|
||||
2.23
|
||||
2.24
|
||||
|
@ -51,7 +51,7 @@ import (
|
||||
func main() {
|
||||
rootCmd := &cobra.Command{
|
||||
Use: "app",
|
||||
Version: "2.23",
|
||||
Version: "2.24",
|
||||
}
|
||||
|
||||
rootCmd.AddCommand(auditproxy.CmdAuditProxy)
|
||||
|
@ -52,7 +52,7 @@ var CmdEtcHosts = &cobra.Command{
|
||||
}
|
||||
|
||||
func printDNSSuffixList(cmd *cobra.Command, args []string) {
|
||||
dnsSuffixList := getDNSSuffixList()
|
||||
dnsSuffixList := GetDNSSuffixList()
|
||||
fmt.Println(strings.Join(dnsSuffixList, ","))
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,9 @@ const etcHostsFile = "/etc/hosts"
|
||||
// nameserver DNS_CLUSTER_IP
|
||||
// search test-dns.svc.cluster.local svc.cluster.local cluster.local q53aahaikqaehcai3ylfqdtc5b.bx.internal.cloudapp.net
|
||||
// options ndots:5
|
||||
func getDNSSuffixList() []string {
|
||||
|
||||
// GetDNSSuffixList reads DNS config file and returns the list of configured DNS suffixes
|
||||
func GetDNSSuffixList() []string {
|
||||
fileData := readFile("/etc/resolv.conf")
|
||||
lines := strings.Split(fileData, "\n")
|
||||
for _, line := range lines {
|
||||
|
@ -80,8 +80,8 @@ func getRegistryValue(reg, key string) string {
|
||||
return regValue
|
||||
}
|
||||
|
||||
// getDNSSuffixList reads DNS config file and returns the list of configured DNS suffixes
|
||||
func getDNSSuffixList() []string {
|
||||
// GetDNSSuffixList reads DNS config file and returns the list of configured DNS suffixes
|
||||
func GetDNSSuffixList() []string {
|
||||
// We start with the general suffix list that apply to all network connections.
|
||||
allSuffixes := []string{}
|
||||
suffixes := getRegistryValue(netRegistry, "SearchList")
|
||||
|
@ -10,6 +10,7 @@ go_library(
|
||||
srcs = ["controller.go"],
|
||||
importpath = "k8s.io/kubernetes/test/images/agnhost/resource-consumer-controller",
|
||||
deps = [
|
||||
"//test/images/agnhost/dns:go_default_library",
|
||||
"//test/images/resource-consumer/common:go_default_library",
|
||||
"//vendor/github.com/spf13/cobra:go_default_library",
|
||||
],
|
||||
|
@ -21,11 +21,13 @@ import (
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"sync"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"k8s.io/kubernetes/test/images/agnhost/dns"
|
||||
"k8s.io/kubernetes/test/images/resource-consumer/common"
|
||||
)
|
||||
|
||||
@ -43,8 +45,31 @@ var (
|
||||
consumerPort int
|
||||
consumerServiceName string
|
||||
consumerServiceNamespace string
|
||||
dnsDomain string
|
||||
)
|
||||
|
||||
// getDNSDomain walks through DNS configuration and looks for "svc.foo" record
|
||||
// where "foo" is currently configured DNS suffix. Then picks that 'foo' part up
|
||||
// and returns to a caller.
|
||||
func getDNSDomain() string {
|
||||
if dnsDomain != "" {
|
||||
return dnsDomain
|
||||
}
|
||||
dnsSuffixList := dns.GetDNSSuffixList()
|
||||
r, _ := regexp.Compile("^svc.")
|
||||
for _, currentDNSSuffix := range dnsSuffixList {
|
||||
if r.MatchString(currentDNSSuffix) {
|
||||
// Save DNS suffix without the 'svc.' part
|
||||
dnsDomain = currentDNSSuffix[4:]
|
||||
break
|
||||
}
|
||||
}
|
||||
if dnsDomain == "" {
|
||||
panic("Could not find DNS suffix starting with 'svc.' substring")
|
||||
}
|
||||
return dnsDomain
|
||||
}
|
||||
|
||||
func init() {
|
||||
CmdResourceConsumerController.Flags().IntVar(&port, "port", 8080, "Port number.")
|
||||
CmdResourceConsumerController.Flags().IntVar(&consumerPort, "consumer-port", 8080, "Port number of consumers.")
|
||||
@ -214,7 +239,8 @@ func (c *controller) sendConsumeCustomMetric(w http.ResponseWriter, metric strin
|
||||
}
|
||||
|
||||
func createConsumerURL(suffix string) string {
|
||||
return fmt.Sprintf("http://%s.%s.svc.cluster.local:%d%s", consumerServiceName, consumerServiceNamespace, consumerPort, suffix)
|
||||
// NOTE: full DNS name is used due to the Windows platform restriction where PQDNs are not supported.
|
||||
return fmt.Sprintf("http://%s.%s.svc.%s:%d%s", consumerServiceName, consumerServiceNamespace, getDNSDomain(), consumerPort, suffix)
|
||||
}
|
||||
|
||||
// sendOneConsumeCPURequest sends POST request for cpu consumption
|
||||
|
Loading…
Reference in New Issue
Block a user