From 7c18e7fd11a1e604719385bd5c1984026d75bd40 Mon Sep 17 00:00:00 2001 From: "taekyu.kang" Date: Thu, 19 Oct 2023 14:14:35 +0900 Subject: [PATCH 1/2] bugfix. change return to conitinue on while loop --- cmd/server/cluster_byoh.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/server/cluster_byoh.go b/cmd/server/cluster_byoh.go index 6456c79..d8f010b 100644 --- a/cmd/server/cluster_byoh.go +++ b/cmd/server/cluster_byoh.go @@ -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 From 38c8075a34e9784bf88e78c64958c1815c85e169 Mon Sep 17 00:00:00 2001 From: "taekyu.kang" Date: Thu, 19 Oct 2023 14:51:57 +0900 Subject: [PATCH 2/2] bugfix. initialize cluster status when stack creating --- cmd/server/cluster_byoh.go | 3 ++- cmd/server/cluster_status.go | 2 +- internal/cluster/cluster.go | 14 +------------- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/cmd/server/cluster_byoh.go b/cmd/server/cluster_byoh.go index d8f010b..a4e7113 100644 --- a/cmd/server/cluster_byoh.go +++ b/cmd/server/cluster_byoh.go @@ -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 } diff --git a/cmd/server/cluster_status.go b/cmd/server/cluster_status.go index a048f5c..4f93e52 100644 --- a/cmd/server/cluster_status.go +++ b/cmd/server/cluster_status.go @@ -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 diff --git a/internal/cluster/cluster.go b/internal/cluster/cluster.go index ec9e9a8..6bbefec 100644 --- a/internal/cluster/cluster.go +++ b/internal/cluster/cluster.go @@ -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). @@ -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 -}