{"record":{"id":"092c02d788afd27d","repo":"apache/dolphinscheduler","slug":"1300006","errorCode":"1300006","errorMessage":"k8s error with exception {0}","messagePattern":"k8s error with exception (.+?)","errorType":"error_code","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ClusterServiceImpl.java","lineNumber":248,"sourceCode":"\n        checkParams(name, config);\n\n        Cluster clusterExistByName = clusterDao.queryByClusterName(name);\n        if (clusterExistByName != null && !clusterExistByName.getCode().equals(code)) {\n            throw new ServiceException(Status.CLUSTER_NAME_EXISTS, name);\n        }\n\n        Cluster clusterExist = clusterDao.queryByClusterCode(code);\n        if (clusterExist == null) {\n            throw new ServiceException(Status.CLUSTER_NOT_EXISTS, name);\n        }\n\n        if (!Constants.K8S_LOCAL_TEST_CLUSTER_CODE.equals(clusterExist.getCode())\n                && !config.equals(ClusterConfUtils.getK8sConfig(clusterExist.getConfig()))) {\n            try {\n                k8sManager.getAndUpdateK8sClient(code, true);\n            } catch (Exception e) {\n                throw new ServiceException(Status.K8S_CLIENT_OPS_ERROR, name);\n            }\n        }\n\n        // update cluster\n        // need not update relation\n        clusterExist.setConfig(config);\n        clusterExist.setName(name);\n        clusterExist.setDescription(desc);\n        clusterExist.setUpdateTime(DateUtils.getCurrentDate());\n        clusterDao.updateById(clusterExist);\n        return clusterExist;\n    }\n\n    /**\n     * verify cluster name\n     *\n     * @param loginUser   login user\n     * @param clusterName cluster name","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ClusterServiceImpl.java#L230-L266","documentation":"When updating a cluster whose config changed (and it is not the local test cluster), updateClusterByCode calls k8sManager.getAndUpdateK8sClient(code, true) to rebuild the Kubernetes client; any exception there is rethrown as ServiceException(Status.K8S_CLIENT_OPS_ERROR, name; code 1300006) with message \"k8s error with exception {0}\". It signals the new cluster config could not be used to establish a working K8s client, so the update is aborted.","triggerScenarios":"PUT /clusters/{code} with a modified kubeconfig/config field for a non-test cluster where getAndUpdateK8sClient throws — invalid kubeconfig YAML, unreachable API server, bad certificates, wrong context, or expired tokens.","commonSituations":"Typo in the kube config; K8s API server behind a firewall/VPN not reachable from the API server host; rotated cluster certificates not yet updated in DolphinScheduler; switching contexts to a cluster that was decommissioned.","solutions":["Validate the new kube config (e.g. kubectl --kubeconfig <file> cluster-info) from the DolphinScheduler API server host before saving.","Check network reachability to the K8s API server (host, port, DNS, firewall) from the API server container/host.","Inspect the wrapped exception message in the API server logs for the root cause (the {0} parameter carries it).","Ensure certificates/keys and tokens in the config are current and correctly indented YAML.","Retry the update once the K8s connection issue is fixed."],"exampleFix":"// before: saving unverified config\nString config = newKubeconfigYaml;\nclusterService.updateClusterByCode(loginUser, code, name, config, desc);\n// after: test the client first\nKubeConfigValidation.validateOrThrow(newKubeconfigYaml); // runs kubectl-equivalent check\nclusterService.updateClusterByCode(loginUser, code, name, newKubeconfigYaml, desc);","handlingStrategy":"validation","validationCode":"// Bash: validate kubeconfig from the API server host before saving\nkubectl --kubeconfig /tmp/new-config cluster-info || echo \"invalid or unreachable cluster config\"","typeGuard":null,"tryCatchPattern":"try {\n    clusterService.updateClusterByCode(loginUser, code, name, config, desc);\n} catch (ServiceException e) {\n    if (e.getCode() == 1300006) {\n        log.error(\"K8s client could not be built from new config; check logs for root cause\", e);\n        // do NOT persist config; roll back UI form state\n    } else {\n        throw e;\n    }\n}","preventionTips":["Test kube configs with kubectl from the API server host before saving","Track certificate/token expiry for managed clusters","Verify network/VPN paths to K8s API servers","Keep a known-good config copy for rollback"],"tags":["k8s","network","kubeconfig","client-setup"],"backgroundTag":"k8s-client-error","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}