[ Agent ] [ App ] - fix app bugs
This commit is contained in:
@@ -249,8 +249,8 @@ func K8sCreateNamespace(namespaceName string) bool {
|
||||
}
|
||||
}
|
||||
|
||||
namespace, _ := k8sClient.CoreV1().Namespaces().Get(context.TODO(), namespaceName, metav1.GetOptions{})
|
||||
if namespace != nil {
|
||||
namespace, err := k8sClient.CoreV1().Namespaces().Get(context.TODO(), namespaceName, metav1.GetOptions{})
|
||||
if err == nil {
|
||||
log.InfoF("[K8sCreateNamespace] - namespace of [%s] already exists!", namespaceName)
|
||||
return true
|
||||
}
|
||||
@@ -263,7 +263,6 @@ func K8sCreateNamespace(namespaceName string) bool {
|
||||
},
|
||||
}
|
||||
// 使用客户端创建命名空间
|
||||
var err error
|
||||
namespace, err = k8sClient.CoreV1().Namespaces().Create(context.TODO(), namespace, metav1.CreateOptions{})
|
||||
if err != nil {
|
||||
log.ErrorF("Error getting namespace: %s ", err.Error())
|
||||
@@ -273,7 +272,6 @@ func K8sCreateNamespace(namespaceName string) bool {
|
||||
// check namespace exists
|
||||
// 尝试获取名为 "xxg" 的命名空间
|
||||
namespace, err = k8sClient.CoreV1().Namespaces().Get(context.TODO(), namespaceName, metav1.GetOptions{})
|
||||
|
||||
// 如果返回错误,需要判断是因为命名空间不存在还是其他错误
|
||||
if err != nil {
|
||||
if errors.IsNotFound(err) {
|
||||
|
||||
Reference in New Issue
Block a user