validate cidr

only accept validated cidr.
And fix the error handle when network-isotate is diabled.
And remove the useless crd.

Signed-off-by: Duan Jiong <djduanjiong@gmail.com>
This commit is contained in:
Duan Jiong
2020-06-10 18:08:56 +08:00
parent d4b7d88b4b
commit 825e026930
3 changed files with 7 additions and 766 deletions

View File

@@ -428,19 +428,21 @@ func (c *NSNetworkPolicyController) syncNs(key string) error {
matchWorkspace := false
delete := false
nsnpList, _ := c.informer.Lister().NamespaceNetworkPolicies(ns.Name).List(labels.Everything())
nsnpList, err := c.informer.Lister().NamespaceNetworkPolicies(ns.Name).List(labels.Everything())
if isNetworkIsolateEnabled(ns) {
matchWorkspace = false
} else if wksp.Spec.NetworkIsolation {
matchWorkspace = true
} else {
delete = true
}
if delete || matchWorkspace {
//delete all namespace np when networkisolate not active
if err != nil && len(nsnpList) > 0 {
if err == nil && len(nsnpList) > 0 {
if c.ksclient.NamespaceNetworkPolicies(ns.Name).DeleteCollection(nil, typev1.ListOptions{}) != nil {
klog.Errorf("Error when delete all nsnps in namespace %s", ns.Name)
}
}
} else {
delete = true
}
policy := generateNSNP(workspaceName, ns.Name, matchWorkspace)