Compare commits

...

1 Commits

Author SHA1 Message Date
dkeven
063a82b2b5 fix(cli): only (un)label current node in multi-node cluster 2025-12-17 16:57:19 +08:00
2 changed files with 11 additions and 9 deletions

View File

@@ -251,7 +251,7 @@ func (l *NodeLabelingModule) Init() {
Name: "UpdateNode",
Prepare: &prepare.PrepareCollection{
new(CudaInstalled),
new(K8sNodeInstalled),
new(CurrentNodeInK8s),
},
Action: new(UpdateNodeLabels),
Retry: 1,
@@ -262,7 +262,7 @@ func (l *NodeLabelingModule) Init() {
Prepare: &prepare.PrepareCollection{
new(common.OnlyFirstMaster),
new(CudaInstalled),
new(K8sNodeInstalled),
new(CurrentNodeInK8s),
},
Action: new(RestartPlugin),
Retry: 1,
@@ -286,7 +286,7 @@ func (l *NodeUnlabelingModule) Init() {
Hosts: l.Runtime.GetHostsByRole(common.Master),
Prepare: &prepare.PrepareCollection{
new(common.OnlyFirstMaster),
new(K8sNodeInstalled),
new(CurrentNodeInK8s),
},
Action: new(RemoveNodeLabels),
Parallel: false,
@@ -298,7 +298,7 @@ func (l *NodeUnlabelingModule) Init() {
Hosts: l.Runtime.GetHostsByRole(common.Master),
Prepare: &prepare.PrepareCollection{
new(common.OnlyFirstMaster),
new(K8sNodeInstalled),
new(CurrentNodeInK8s),
new(GpuDevicePluginInstalled),
},
Action: new(RestartPlugin),

View File

@@ -63,11 +63,11 @@ func (p *CudaNotInstalled) PreCheck(runtime connector.Runtime) (bool, error) {
return false, nil
}
type K8sNodeInstalled struct {
type CurrentNodeInK8s struct {
common.KubePrepare
}
func (p *K8sNodeInstalled) PreCheck(runtime connector.Runtime) (bool, error) {
func (p *CurrentNodeInK8s) PreCheck(runtime connector.Runtime) (bool, error) {
client, err := clientset.NewKubeClient()
if err != nil {
logger.Debug(errors.Wrap(errors.WithStack(err), "kubeclient create error"))
@@ -84,11 +84,13 @@ func (p *K8sNodeInstalled) PreCheck(runtime connector.Runtime) (bool, error) {
return false, nil
}
if len(node.Items) == 0 {
return false, nil
for _, node := range node.Items {
if node.Name == runtime.GetSystemInfo().GetHostname() {
return true, nil
}
}
return true, nil
return false, nil
}
type NvidiaGraphicsCard struct {