Skip to content

Commit

Permalink
JIRA: PMK-5805 (#350)
Browse files Browse the repository at this point in the history
Allow decommission for partial installation of hostagent
Similar fix implemented in prep-node
  • Loading branch information
psarwate authored May 10, 2023
1 parent 8fabfd7 commit fcaee7f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 23 deletions.
23 changes: 10 additions & 13 deletions pkg/pmk/checkNode.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,18 @@ func CheckNode(ctx objects.Config, allClients client.Client, auth keystone.Keyst
if !v.Result {
zap.S().Debug("Platform9 Packages are present")
zap.S().Debug("Checking if host is connected or not")
ip, err := allClients.Executor.RunWithStdout("bash", "-c", "hostname -I")
// Directly use host_id instead of relying on IP to get host details
// host_id file is created as part hostagent installation. File missing should mean
// that installation was partial
cmd := `grep host_id /etc/pf9/host_id.conf | cut -d '=' -f2`
hostID, err := allClients.Executor.RunWithStdout("bash", "-c", cmd)
if err != nil {
zap.S().Debug("Failed to get host ip")
zap.S().Debugf("Unable to get host id %s", err.Error())
}
ip = strings.Split(ip, " ")[0]
ip = strings.TrimSpace(ip)
var add = []string{ip}
id := allClients.Resmgr.GetHostId(auth.Token, add)
//If node is already connected then resmgr will return hostID
//If hostID is empty then host could be connected to other DU
var connected bool
if len(id) != 0 {
connected = allClients.Resmgr.HostStatus(auth.Token, id[0])
} else {
zap.S().Fatalf("Hostagent is installed on this host, but this host is not part of the DU %s specified in the config", ctx.Fqdn)
hostID = strings.TrimSpace(hostID)
connected := false
if len(hostID) != 0 {
connected = allClients.Resmgr.HostStatus(auth.Token, hostID)
}
if connected {
zap.S().Debug("Node is already connected")
Expand Down
17 changes: 7 additions & 10 deletions pkg/pmk/decomissionNode.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,6 @@ func DecommissionNode(cfg *objects.Config, nc objects.NodeConfig, removePf9 bool
zap.S().Debug("Failed to get keystone %s", err.Error())
}

// Directly use host_id instead of relying on IP to get host details
cmd := `grep host_id /etc/pf9/host_id.conf | cut -d '=' -f2`
hostID, err := c.Executor.RunWithStdout("bash", "-c", cmd)
if err != nil {
zap.S().Fatalf("Unable to get host id %s", err.Error())
}
if len(hostID) == 0 {
zap.S().Fatalf("Invalid host id found")
}
hostID = strings.TrimSpace(hostID)
hostOS, err := ValidatePlatform(c.Executor)
if err != nil {
zap.S().Fatalf("Error getting OS version")
Expand All @@ -104,6 +94,13 @@ func DecommissionNode(cfg *objects.Config, nc objects.NodeConfig, removePf9 bool
//check if node is connected to any cluster
var nodeInfo qbert.Node
var nodeConnectedToDU bool
// Directly use host_id instead of relying on IP to get host details
cmd := `grep host_id /etc/pf9/host_id.conf | cut -d '=' -f2`
hostID, err := c.Executor.RunWithStdout("bash", "-c", cmd)
if err != nil {
zap.S().Debugf("Unable to get host id %s", err.Error())
}
hostID = strings.TrimSpace(hostID)
if len(hostID) != 0 {
nodeConnectedToDU = true
nodeInfo, err = c.Qbert.GetNodeInfo(auth.Token, auth.ProjectID, hostID)
Expand Down

0 comments on commit fcaee7f

Please sign in to comment.