Skip to content

Commit

Permalink
bugfix. initialize cluster status when stack creating
Browse files Browse the repository at this point in the history
  • Loading branch information
ktkfree committed Oct 19, 2023
1 parent 7c18e7f commit 38c8075
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 15 deletions.
3 changes: 2 additions & 1 deletion cmd/server/cluster_byoh.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,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 38c8075

Please sign in to comment.