Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

fix(cli): osm namespace add should fail when adding osm-system NS #1499

Merged
merged 7 commits into from
Aug 18, 2020

Conversation

Sheshagiri
Copy link
Contributor

@Sheshagiri Sheshagiri commented Aug 11, 2020

fixes: #1196
This has changes to return an error when a user tries to add a namespace which has osm control plane running in it.

Please mark with X for applicable areas.

  • New Functionality [ ]
  • Documentation [ ]
  • Install [X]
  • Control Plane [ ]
  • CLI Tool [x]
  • Certificate Management [ ]
  • Networking [ ]
  • Metrics [ ]
  • SMI Policy [ ]
  • Security [ ]
  • Tests / CI System [ ]
  • Other [ ]

Please answer the following questions with yes/no.

  • Does this change contain code from or inspired by another project? If so, did you notify the maintainers and provide attribution? No

todo:

  • update tests

This has changes to return an error when a user tries to add
a ns which has osm control plane installed to the mesh.
This will fix openservicemesh#1196.
ksubrmnn
ksubrmnn previously approved these changes Aug 11, 2020
if err != nil {
return errors.Errorf("Could not label namespace [%s]: %v", ns, err)
deploymentsClient := a.clientSet.AppsV1().Deployments(ns)
labelSelector := metav1.LabelSelector{MatchLabels: map[string]string{"app": "osm-controller"}}
Copy link
Contributor

Choose a reason for hiding this comment

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

we should probably make this a constant

@shashankram
Copy link
Member

@Sheshagiri, thanks for the change, would you mind adding tests prior to merging?

@Sheshagiri
Copy link
Contributor Author

@Sheshagiri, thanks for the change, would you mind adding tests prior to merging?

Sure, I have a todo. I'll add those and mark this as ready for review.

@shashankram shashankram added the wip Work-in-Progress label Aug 13, 2020
    This has changes to return an error when a user tries to add
    a ns which has osm control plane installed to the mesh.
    This will fix openservicemesh#1196.
@Sheshagiri Sheshagiri marked this pull request as ready for review August 15, 2020 15:52
@Sheshagiri Sheshagiri requested a review from a team as a code owner August 15, 2020 15:52
cmd/cli/install.go Outdated Show resolved Hide resolved
@Sheshagiri Sheshagiri changed the title [WIP] osm namespace add should fail when adding osm-system NS osm namespace add should fail when adding osm-system NS Aug 18, 2020
@ksubrmnn ksubrmnn changed the title osm namespace add should fail when adding osm-system NS fix: osm namespace add should fail when adding osm-system NS Aug 18, 2020
@ksubrmnn ksubrmnn changed the title fix: osm namespace add should fail when adding osm-system NS fix(cli): osm namespace add should fail when adding osm-system NS Aug 18, 2020
Copy link
Contributor

@michelleN michelleN left a comment

Choose a reason for hiding this comment

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

Thank you

fakeClientSet.AppsV1().Deployments(testNamespace).Create(context.TODO(), deploymentSpec, metav1.CreateOptions{})

nsSpec := createNamespaceSpec(testNamespace, "")
fakeClientSet.CoreV1().Namespaces().Create(context.TODO(), nsSpec, metav1.CreateOptions{})
Copy link
Contributor

Choose a reason for hiding this comment

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

I was surprised to see that we're creating the namespace after creating the deployment in the namespace. Does this work because we're using fakeClientSet so it is not validating that the value of testNamespace exists before creating the Deployment with that Namespace?

@michelleN michelleN merged commit 7e709dd into openservicemesh:main Aug 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
wip Work-in-Progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

osm namespace add should fail when adding osm-system NS
4 participants