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

[COST-4624] do not show progress update during initial data gather #296

Merged
merged 5 commits into from
Feb 28, 2024
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
2 changes: 0 additions & 2 deletions internal/controller/kokumetricsconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -844,8 +844,6 @@ func (r *MetricsConfigReconciler) Reconcile(ctx context.Context, req ctrl.Reques
log.Info("collected 96 hours of data, packaging files")
packageFiles(packager, cr)
startTime = t
// update status to show progress
r.updateStatusAndLogError(ctx, cr)
}
}

Expand Down
71 changes: 36 additions & 35 deletions internal/controller/kokumetricsconfig_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1316,41 +1316,6 @@ var _ = Describe("MetricsConfigController - CRD Handling", Ordered, func() {
Expect(err).To(BeNil())
Expect(len(files)).To(Equal(0))
})
It("8day retention period - successfully queried but there was no data on first day, but data on all remaining days", func() {
resetReconciler(WithSecretOverride(true))

testConfigMap.Data = map[string]string{"config.yaml": "prometheusK8s:\n retention: 8d"}
createObject(ctx, testConfigMap)

t := metav1.Now().UTC().Truncate(1 * time.Hour).Add(-1 * time.Hour)
t2 := t.Truncate(24 * time.Hour).Add(-24 * 8 * time.Hour) // midnight 8 days ago
timeRangeInitial := promv1.Range{
Start: t2,
End: t2.Add(59*time.Minute + 59*time.Second),
Step: time.Minute,
}
mockpconn.EXPECT().QueryRange(gomock.Any(), gomock.Any(), timeRangeInitial, gomock.Any()).Return(model.Matrix{}, nil, nil).MinTimes(1)
mockpconn.EXPECT().QueryRange(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(asModelMatrix(metricjson, nodeallocatablecpucores), nil, nil).MinTimes(1)

instCopy.Spec.Packaging.MaxReports = 2
instCopy.Spec.PrometheusConfig.CollectPreviousData = &trueDef
instCopy.Spec.PrometheusConfig.DisableMetricsCollectionResourceOptimization = &trueDef
instCopy.Spec.Upload.UploadToggle = &falseValue
createObject(ctx, instCopy)

fetched := &metricscfgv1beta1.MetricsConfig{}

Eventually(func() bool {
_ = k8sClient.Get(ctx, types.NamespacedName{Name: instCopy.Name, Namespace: namespace}, fetched)
return fetched.Status.Prometheus.LastQuerySuccessTime.Equal(&metav1.Time{Time: t})
}, timeout, interval).Should(BeTrue())

Expect(fetched.Status.Reports.DataCollected).To(BeTrue())
Expect(len(fetched.Status.Packaging.PackagedFiles)).To(Equal(2))
Expect(fetched.Status.Packaging.ReportCount).ToNot(BeNil())
Expect(*fetched.Status.Packaging.ReportCount).To(BeEquivalentTo(2))

})
It("query failed due to error", func() {
resetReconciler(WithSecretOverride(true))

Expand Down Expand Up @@ -1431,5 +1396,41 @@ var _ = Describe("MetricsConfigController - CRD Handling", Ordered, func() {

Expect(fetched.Status.Reports.DataCollected).To(BeTrue())
})
It("8day retention period - successfully queried but there was no data on first day, but data on all remaining days", func() {
// slow test, always run this one last
resetReconciler(WithSecretOverride(true))

testConfigMap.Data = map[string]string{"config.yaml": "prometheusK8s:\n retention: 8d"}
createObject(ctx, testConfigMap)

t := metav1.Now().UTC().Truncate(1 * time.Hour).Add(-1 * time.Hour)
t2 := t.Truncate(24 * time.Hour).Add(-24 * 8 * time.Hour) // midnight 8 days ago
timeRangeInitial := promv1.Range{
Start: t2,
End: t2.Add(59*time.Minute + 59*time.Second),
Step: time.Minute,
}
mockpconn.EXPECT().QueryRange(gomock.Any(), gomock.Any(), timeRangeInitial, gomock.Any()).Return(model.Matrix{}, nil, nil).MinTimes(1)
mockpconn.EXPECT().QueryRange(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(asModelMatrix(metricjson, nodeallocatablecpucores), nil, nil).MinTimes(1)

instCopy.Spec.Packaging.MaxReports = 2
instCopy.Spec.PrometheusConfig.CollectPreviousData = &trueDef
instCopy.Spec.PrometheusConfig.DisableMetricsCollectionResourceOptimization = &trueDef
instCopy.Spec.Upload.UploadToggle = &falseValue
createObject(ctx, instCopy)

fetched := &metricscfgv1beta1.MetricsConfig{}

Eventually(func() bool {
_ = k8sClient.Get(ctx, types.NamespacedName{Name: instCopy.Name, Namespace: namespace}, fetched)
return fetched.Status.Prometheus.LastQuerySuccessTime.Equal(&metav1.Time{Time: t})
}, timeout, interval).Should(BeTrue())

Expect(fetched.Status.Reports.DataCollected).To(BeTrue())
Expect(len(fetched.Status.Packaging.PackagedFiles)).To(Equal(2))
Expect(fetched.Status.Packaging.ReportCount).ToNot(BeNil())
Expect(*fetched.Status.Packaging.ReportCount).To(BeEquivalentTo(2))

})
})
})
Loading