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

Fix pod_forwarder to support two part DNS names, adjust e2e http_client #1297

Merged
merged 2 commits into from
Jul 21, 2019
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
4 changes: 2 additions & 2 deletions operators/pkg/dev/portforward/pod_forwarder.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func newDefaultKubernetesClientset() (*kubernetes.Clientset, error) {
}

// podDNSRegex matches pods FQDN such as {name}.{namespace}.pod
var podDNSRegex = regexp.MustCompile(`^.+\..+\..*$`)
var podDNSRegex = regexp.MustCompile(`^.+\..+$`)

// podIPRegex matches any ipv4 address.
var podIPv4Regex = regexp.MustCompile(`^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$`)
Expand All @@ -118,7 +118,7 @@ func parsePodAddr(addr string, clientSet *kubernetes.Clientset) (*types.Namespac
// retrieve pod name and namespace from addr
// TODO: subdomains in pod names would change this.
parts := strings.SplitN(host, ".", 3)
if len(parts) <= 2 {
if len(parts) <= 1 {
return nil, fmt.Errorf("unsupported pod address format: %s", host)
}
return &types.NamespacedName{Namespace: parts[1], Name: parts[0]}, nil
Expand Down
9 changes: 7 additions & 2 deletions operators/pkg/dev/portforward/pod_forwarder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,15 @@ func Test_parsePodAddr(t *testing.T) {
args: args{addr: "foo.bar.pod:1234"},
want: types.NamespacedName{Namespace: "bar", Name: "foo"},
},
{
name: "pod DNS with pod and namespace only",
args: args{addr: "foopod.barnamespace:1234"},
want: types.NamespacedName{Namespace: "barnamespace", Name: "foopod"},
},
{
name: "invalid",
args: args{addr: "example.com:1234"},
wantErr: errors.New("unsupported pod address format: example.com"),
args: args{addr: "foobar:1234"},
wantErr: errors.New("unsupported pod address format: foobar"),
},
}
for _, tt := range tests {
Expand Down
2 changes: 1 addition & 1 deletion operators/test/e2e/test/elasticsearch/http_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func NewElasticsearchClient(es v1alpha1.Elasticsearch, k *test.K8sClient) (clien
if err != nil {
return nil, err
}
inClusterURL := fmt.Sprintf("https://%s:9200", name.HTTPService(es.Name))
inClusterURL := fmt.Sprintf("https://%s.%s.svc:9200", name.HTTPService(es.Name), es.Namespace)
var dialer net.Dialer
if test.AutoPortForward {
dialer = portforward.NewForwardingDialer()
Expand Down