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

Removed env provided namespace #253

Merged
Show file tree
Hide file tree
Changes from 2 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
8 changes: 4 additions & 4 deletions pkg/registry/etcd/ns_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (n *etcdNSRegistryServer) Register(ctx context.Context, request *registry.N
)
if apierrors.IsAlreadyExists(err) {
var exist *v1.NetworkService
exist, err = n.client.NetworkservicemeshV1().NetworkServices(n.ns).Get(ctx, request.Name, metav1.GetOptions{})
exist, err = n.client.NetworkservicemeshV1().NetworkServices("").Get(ctx, request.Name, metav1.GetOptions{})
if err == nil {
exist.Spec = *(*v1.NetworkServiceSpec)(request)
apiResp, err = n.client.NetworkservicemeshV1().NetworkServices(n.ns).Update(ctx, exist, metav1.UpdateOptions{})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally I think we should keep n.ns for Create and Update.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, done

Expand All @@ -78,7 +78,7 @@ func (n *etcdNSRegistryServer) watch(query *registry.NetworkServiceQuery, s regi
var watchErr error
for watchErr == nil {
timeoutSeconds := int64(time.Minute / time.Second)
watcher, err := n.client.NetworkservicemeshV1().NetworkServices(n.ns).Watch(s.Context(), metav1.ListOptions{
watcher, err := n.client.NetworkservicemeshV1().NetworkServices("").Watch(s.Context(), metav1.ListOptions{
TimeoutSeconds: &timeoutSeconds,
})
if err != nil {
Expand Down Expand Up @@ -126,7 +126,7 @@ func (n *etcdNSRegistryServer) handleWatcher(
}

func (n *etcdNSRegistryServer) Find(query *registry.NetworkServiceQuery, s registry.NetworkServiceRegistry_FindServer) error {
list, err := n.client.NetworkservicemeshV1().NetworkServices(n.ns).List(s.Context(), metav1.ListOptions{})
list, err := n.client.NetworkservicemeshV1().NetworkServices("").List(s.Context(), metav1.ListOptions{})
if err != nil {
return err
}
Expand Down Expand Up @@ -155,7 +155,7 @@ func (n *etcdNSRegistryServer) Unregister(ctx context.Context, request *registry
if err != nil {
return nil, err
}
err = n.client.NetworkservicemeshV1().NetworkServices(n.ns).Delete(
err = n.client.NetworkservicemeshV1().NetworkServices("").Delete(
ctx,
request.Name,
metav1.DeleteOptions{},
Expand Down
6 changes: 3 additions & 3 deletions pkg/registry/etcd/ns_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
)

func Test_NSReRegister(t *testing.T) {
s := etcd.NewNetworkServiceRegistryServer(context.Background(), "default", fake.NewSimpleClientset())
s := etcd.NewNetworkServiceRegistryServer(context.Background(), "", fake.NewSimpleClientset())
_, err := s.Register(context.Background(), &registry.NetworkService{Name: "ns-1"})
require.NoError(t, err)
_, err = s.Register(context.Background(), &registry.NetworkService{Name: "ns-1", Payload: "IP"})
Expand All @@ -46,14 +46,14 @@ func Test_K8sNERegistry_ShouldMatchMetadataToName(t *testing.T) {

var myClientset = fake.NewSimpleClientset()

_, err := myClientset.NetworkservicemeshV1().NetworkServices("default").Create(ctx, &v1.NetworkService{
_, err := myClientset.NetworkservicemeshV1().NetworkServices("").Create(ctx, &v1.NetworkService{
ObjectMeta: metav1.ObjectMeta{
Name: "ns-1",
},
}, metav1.CreateOptions{})
require.NoError(t, err)

s := etcd.NewNetworkServiceRegistryServer(ctx, "default", myClientset)
s := etcd.NewNetworkServiceRegistryServer(ctx, "", myClientset)
c := adapters.NetworkServiceServerToClient(s)

stream, err := c.Find(ctx, &registry.NetworkServiceQuery{
Expand Down
8 changes: 4 additions & 4 deletions pkg/registry/etcd/nse_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (n *etcdNSERegistryServer) Register(ctx context.Context, request *registry.
)
if apierrors.IsAlreadyExists(err) {
var exist *v1.NetworkServiceEndpoint
exist, err = n.client.NetworkservicemeshV1().NetworkServiceEndpoints(n.ns).Get(ctx, request.Name, metav1.GetOptions{})
exist, err = n.client.NetworkservicemeshV1().NetworkServiceEndpoints("").Get(ctx, request.Name, metav1.GetOptions{})
if err == nil {
exist.Spec = *(*v1.NetworkServiceEndpointSpec)(request)
apiResp, err = n.client.NetworkservicemeshV1().NetworkServiceEndpoints(n.ns).Update(ctx, exist, metav1.UpdateOptions{})
Expand All @@ -77,7 +77,7 @@ func (n *etcdNSERegistryServer) Register(ctx context.Context, request *registry.
}

func (n *etcdNSERegistryServer) Find(query *registry.NetworkServiceEndpointQuery, s registry.NetworkServiceEndpointRegistry_FindServer) error {
list, err := n.client.NetworkservicemeshV1().NetworkServiceEndpoints(n.ns).List(s.Context(), metav1.ListOptions{})
list, err := n.client.NetworkservicemeshV1().NetworkServiceEndpoints("").List(s.Context(), metav1.ListOptions{})
if err != nil {
return err
}
Expand Down Expand Up @@ -106,7 +106,7 @@ func (n *etcdNSERegistryServer) Unregister(ctx context.Context, request *registr
if err != nil {
return nil, err
}
err = n.client.NetworkservicemeshV1().NetworkServiceEndpoints(n.ns).Delete(
err = n.client.NetworkservicemeshV1().NetworkServiceEndpoints("").Delete(
ctx,
request.Name,
metav1.DeleteOptions{})
Expand All @@ -120,7 +120,7 @@ func (n *etcdNSERegistryServer) watch(query *registry.NetworkServiceEndpointQuer
var watchErr error
for watchErr == nil {
timeoutSeconds := int64(time.Minute / time.Second)
watcher, err := n.client.NetworkservicemeshV1().NetworkServiceEndpoints(n.ns).Watch(s.Context(), metav1.ListOptions{
watcher, err := n.client.NetworkservicemeshV1().NetworkServiceEndpoints("").Watch(s.Context(), metav1.ListOptions{
TimeoutSeconds: &timeoutSeconds,
})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/registry/etcd/nse_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
)

func Test_NSEReRegister(t *testing.T) {
s := etcd.NewNetworkServiceEndpointRegistryServer(context.Background(), "default", fake.NewSimpleClientset())
s := etcd.NewNetworkServiceEndpointRegistryServer(context.Background(), "", fake.NewSimpleClientset())
_, err := s.Register(context.Background(), &registry.NetworkServiceEndpoint{Name: "nse-1"})
require.NoError(t, err)
_, err = s.Register(context.Background(), &registry.NetworkServiceEndpoint{Name: "nse-1", NetworkServiceNames: []string{"ns-1"}})
Expand Down