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

Remove namespace from core Entity #458

Merged
merged 13 commits into from
Nov 29, 2019
Merged

Conversation

jakubdyszkiewicz
Copy link
Contributor

@jakubdyszkiewicz jakubdyszkiewicz commented Nov 22, 2019

Summary

The idea is that our core model should not know anything about K8S namespace. To achieve that, we embed namespace into name. For example our name from core entity: sample.demo indicates that on k8s the name is sample and namespace is demo.

Postgres
In postgres we've got separate column for namespace. For now I left the column. We should solve the problem of migrations (especially since we plan to add new column which is creation/modify date).

Mesh
Mesh is now a Cluster scoped object on K8S. Meaning it does not belong to any namespace.

Changes from user perspective

kumactl output will look like following

❯❯❯ kumactl get dataplanes
MESH                  NAME                                     TAGS
kuma-system   demo-app-7df8d4b675-v6msc.kuma-demo      app=demo-app pod-template-hash=7df8d4b675 service=demo-app.kuma-demo.svc:8000
kuma-system   demo-client-6d8745c7d6-fvjfr.kuma-demo   app=demo-client pod-template-hash=6d8745c7d6 service=demo-client.kuma-demo.svc:3000

@jakubdyszkiewicz jakubdyszkiewicz requested a review from a team November 22, 2019 10:26
@CLAassistant
Copy link

CLAassistant commented Nov 22, 2019

CLA assistant check
All committers have signed the CLA.

@jakubdyszkiewicz jakubdyszkiewicz changed the title Remove namespace from core Entity - part 1 Remove namespace from core Entity Nov 26, 2019
Copy link
Contributor

@yskopets yskopets left a comment

Choose a reason for hiding this comment

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

Let's also document migration path

},
},
}),
Entry("TrafficRoutes should be ordered by namespace to consistently pick between two equally specific routes", testCase{
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's bring this test back.

It's very interesting to see how ordering will work on k8s now.

I'm afraid that it doesn't make any sense from a user perspective. That is not ok and should be taken into account.

Maybe, it's more practical to choose namespace.name convention (or namespace:name like Marco once suggested)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Namespace now is in name and we've already got test for ordering the name. Ordering will work with name first and then namespace if it's present in the name.

Is this that important anyways? I think the only situation it will matter to user is when there are equal number of tags. We will soon change the ordering to take into account the modification date.

)

func CoreNameToK8sName(coreName string) (string, string, error) {
parts := strings.Split(coreName, ".")
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's use strings.LastIndex() instead. I think, it will make the intention more clear

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think I understand how to apply the LastIndex() here. Can you provide what you have in mind?

Copy link
Contributor

Choose a reason for hiding this comment

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

idx := strings.LastIndex(coreName, ".")
if idx == -1 {
  return "", "", errors.New(`name must include namespace after the dot, ex. "name.namespace"`)
}
if idx == len(coreName) - 1 {
  return "", "", errors.New("namespace must be non-empty")
}
return coreName[:idx], coreName[idx + 1:], nil

},
},
}),
Entry("ProxyTemplates in different Namespaces", testCase{
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's bring this test back.

It's very interesting to see how ordering will work on k8s now.

I'm afraid that it doesn't make any sense from a user perspective. That is not ok and should be taken into account.

Maybe, it's more practical to choose namespace.name convention (or namespace:name like Marco once suggested)

)

func CoreNameToK8sName(coreName string) (string, string, error) {
parts := strings.Split(coreName, ".")
Copy link
Contributor

Choose a reason for hiding this comment

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

idx := strings.LastIndex(coreName, ".")
if idx == -1 {
  return "", "", errors.New(`name must include namespace after the dot, ex. "name.namespace"`)
}
if idx == len(coreName) - 1 {
  return "", "", errors.New("namespace must be non-empty")
}
return coreName[:idx], coreName[idx + 1:], nil

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants