Skip to content

Commit

Permalink
Merge pull request #20 from openinfradev/byoh_host
Browse files Browse the repository at this point in the history
bugfix. change return to conitinue on while loop
  • Loading branch information
ktkfree authored Oct 19, 2023
2 parents 4c7590b + 38c8075 commit 88393ed
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
6 changes: 4 additions & 2 deletions cmd/server/cluster_byoh.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ func processClusterByoh() error {
url := fmt.Sprintf("clusters/%s/nodes", clusterId)
body, err := apiClient.Get(url)
if err != nil {
return err
log.Error(err)
continue
}

var out domain.GetClusterNodesResponse
Expand All @@ -55,7 +56,8 @@ func processClusterByoh() error {
//completed = true // FOR TEST
if completed {
log.Info(fmt.Sprintf("all agents registered! starting stack creation. clusterId %s", clusterId))
if err = clusterAccessor.UpdateClusterStatus(clusterId, domain.ClusterStatus_INSTALLING); err != nil {
// clusterId, newStatus, newMessage, workflowId
if err = clusterAccessor.UpdateClusterStatus(clusterId, domain.ClusterStatus_INSTALLING, "", ""); err != nil {
log.Error("Failed to update cluster status err : ", err)
continue
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/cluster_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func processClusterStatus() error {

if status != newStatus || statusDesc != newMessage {
log.Debug(fmt.Sprintf("update status!! clusterId [%s], newStatus [%s], newMessage [%s]", clusterId, newStatus, newMessage))
err := clusterAccessor.UpdateClusterStatusWithWorkflow(clusterId, newStatus, newMessage, workflowId)
err := clusterAccessor.UpdateClusterStatus(clusterId, newStatus, newMessage, workflowId)
if err != nil {
log.Error("Failed to update cluster status err : ", err)
continue
Expand Down
14 changes: 1 addition & 13 deletions internal/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (x *ClusterAccessor) GetBootstrappedByohClusters() ([]Cluster, error) {
return clusters, nil
}

func (x *ClusterAccessor) UpdateClusterStatusWithWorkflow(clusterId string, status domain.ClusterStatus, statusDesc string, workflowId string) error {
func (x *ClusterAccessor) UpdateClusterStatus(clusterId string, status domain.ClusterStatus, statusDesc string, workflowId string) error {
log.Info(fmt.Sprintf("UpdateClusterStatus. clusterId[%s], status[%d], statusDesc[%s], workflowId[%s]", clusterId, status, statusDesc, workflowId))
res := x.db.Model(Cluster{}).
Where("ID = ?", clusterId).
Expand All @@ -75,15 +75,3 @@ func (x *ClusterAccessor) UpdateClusterStatusWithWorkflow(clusterId string, stat
}
return nil
}

func (x *ClusterAccessor) UpdateClusterStatus(clusterId string, status domain.ClusterStatus) error {
log.Info(fmt.Sprintf("UpdateClusterStatus. clusterId[%s], status[%d]", clusterId, status))
res := x.db.Model(Cluster{}).
Where("ID = ?", clusterId).
Updates(map[string]interface{}{"Status": status})

if res.Error != nil || res.RowsAffected == 0 {
return fmt.Errorf("nothing updated in cluster with id %s", clusterId)
}
return nil
}

0 comments on commit 88393ed

Please sign in to comment.