Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix. change return to conitinue on while loop #20

Merged
merged 2 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
Loading