Skip to content

Commit

Permalink
MGMT-13711: it takes the assisted-service few minutes to notice that …
Browse files Browse the repository at this point in the history
…the cluster installation is completed (openshift#4988)

Update trigger_timestamp on update finalization state when it get to
100%
Update trigger_timestamp on upload ingress ca
  • Loading branch information
tsorya authored Feb 20, 2023
1 parent 489e5e6 commit 324362e
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internal/bminventory/inventory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9207,6 +9207,7 @@ var _ = Describe("V2UploadClusterIngressCert test", func() {
status := models.ClusterStatusInstalled
c.Status = &status
db.Save(&c)

data, err := os.Open("../../subsystem/test_kubeconfig")
Expect(err).ShouldNot(HaveOccurred())
kubeConfigAsBytes, err := io.ReadAll(data)
Expand All @@ -9217,11 +9218,21 @@ var _ = Describe("V2UploadClusterIngressCert test", func() {
objectExists()
mockS3Client.EXPECT().Download(ctx, kubeconfigNoingress).Return(kubeconfigFile, int64(0), nil).Times(1)
mockS3Client.EXPECT().Upload(ctx, merged, kubeconfigObject).Return(nil)

// validate triggeredMonitored timestamp is zero
Expect(c.TriggerMonitorTimestamp.IsZero()).To(Equal(true))

generateReply := bm.V2UploadClusterIngressCert(ctx, installer.V2UploadClusterIngressCertParams{
ClusterID: clusterID,
IngressCertParams: ingressCa,
})
Expect(generateReply).Should(Equal(installer.NewV2UploadClusterIngressCertCreated()))

// validate triggeredMonitored was updated
updated, err := common.GetClusterFromDB(db, clusterID, common.UseEagerLoading)
Expect(err).ToNot(HaveOccurred())
Expect(updated.TriggerMonitorTimestamp.IsZero()).To(Equal(false))

})
})
var _ = Describe("List clusters", func() {
Expand Down
9 changes: 9 additions & 0 deletions internal/bminventory/inventory_v2_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,15 @@ func (b *bareMetalInventory) V2UploadClusterIngressCert(ctx context.Context, par
return installer.NewV2UploadClusterIngressCertCreated()
}

// update trigger_monitor_timestamp in order to run cluster monitor for this cluster as fast as possible
updates := map[string]interface{}{
"trigger_monitor_timestamp": time.Now(),
}
err = b.db.Model(&common.Cluster{}).Where("id = ?", cluster.ID.String()).UpdateColumns(updates).Error
if err != nil {
return common.NewApiError(http.StatusInternalServerError, err)
}

noingress := fmt.Sprintf("%s/%s-noingress", cluster.ID, constants.Kubeconfig)
resp, _, err := b.objectHandler.Download(ctx, noingress)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions internal/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,9 @@ func (m *Manager) UpdateFinalizingProgress(ctx context.Context, db *gorm.DB, clu
"progress_finalizing_stage_percentage": finalizingStagePercentage,
"progress_total_percentage": totalPercentage,
}
if finalizingStagePercentage == 100 {
updates["trigger_monitor_timestamp"] = time.Now()
}

return db.Model(&common.Cluster{}).Where("id = ?", cluster.ID.String()).UpdateColumns(updates).Error
}
Expand Down
29 changes: 29 additions & 0 deletions internal/cluster/progress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,35 @@ var _ = Describe("Progress bar test", func() {
expectProgressToBe(&c, 0, 0, 75)
})
})
It("UpdateFinalizingProgress test - 100%", func() {
clusterId := strfmt.UUID(uuid.New().String())
c := common.Cluster{
Cluster: models.Cluster{
ID: &clusterId,
MonitoredOperators: []*models.MonitoredOperator{
{
Name: operators.OperatorConsole.Name,
OperatorType: models.OperatorTypeBuiltin,
Status: models.OperatorStatusAvailable,
},
{
Name: operators.OperatorCVO.Name,
OperatorType: models.OperatorTypeBuiltin,
Status: models.OperatorStatusAvailable,
},
},
},
}
Expect(db.Create(&c).Error).ShouldNot(HaveOccurred())
err := clusterApi.UpdateFinalizingProgress(ctx, db, clusterId)
Expect(err).NotTo(HaveOccurred())

c = getClusterFromDB(clusterId, db)
expectProgressToBe(&c, 0, 0, 100)
// validate triggeredMonitored was updated
Expect(c.TriggerMonitorTimestamp.IsZero()).To(Equal(false))

})

Context("update progress on transition", func() {

Expand Down

0 comments on commit 324362e

Please sign in to comment.