-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Bug 1547284 - Do not allow 'default' project to be isolated using 'oc adm pod-network' #18687
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ import ( | |
| "github.com/spf13/cobra" | ||
|
|
||
| kerrors "k8s.io/apimachinery/pkg/util/errors" | ||
| kapi "k8s.io/kubernetes/pkg/apis/core" | ||
| "k8s.io/kubernetes/pkg/kubectl/cmd/templates" | ||
| kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util" | ||
|
|
||
|
|
@@ -72,8 +73,12 @@ func (i *IsolateOptions) Run() error { | |
|
|
||
| errList := []error{} | ||
| for _, project := range projects { | ||
| if project.Name == kapi.NamespaceDefault { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does this require a CLI change? The server should decide what is forbidden as the CLI can always be bypassed.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SDN controller handles isolating project networks. As controllers run asynchronously, we will see forbidden error in the master log but the client only sees timeout error after few seconds (unfortunately there is no status field to report messages). This CLI change will not make a request to server when it knows that the server is going to reject for the given namespace and can also throw meaningful error message in this case. |
||
| errList = append(errList, fmt.Errorf("network isolation for project %q is forbidden", project.Name)) | ||
| continue | ||
| } | ||
| if err = i.Options.UpdatePodNetwork(project.Name, network.IsolatePodNetwork, ""); err != nil { | ||
| errList = append(errList, fmt.Errorf("Network isolation for project %q failed, error: %v", project.Name, err)) | ||
| errList = append(errList, fmt.Errorf("network isolation for project %q failed, error: %v", project.Name, err)) | ||
| } | ||
| } | ||
| return kerrors.NewAggregate(errList) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What makes this special? Do all reserved namespaces need this?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'default' namespace is special because openshift deploys kube service in 'default' namespace by default and by allowing the namespace to be isolated, other namespaces can not access the kube api.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"default" is treated specially in the SDN code; there are places that just assume that it has VNID 0 without checking. The fact that it was possible to renumber it at all was an accident.