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

RHIROS-1326 Kruize 0.0.20.1_rm Integration #129

Merged
merged 5 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ coverage.txt
output.csv
.idea/
.DS_Store
.go/
34 changes: 18 additions & 16 deletions internal/services/recommendation_poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,12 @@ func requestAndSaveRecommendation(kafkaMsg types.RecommendationKafkaMsg, recomme
return poll_cycle_complete
}

// TODO: Is_valid_recommendation to be called on every container record v20.1 upgrade on wards
if kruize.Is_valid_recommendation(recommendation) {
containers := recommendation[0].Kubernetes_objects[0].Containers
recommendationSetList := []model.RecommendationSet{}
histRecommendationSetList := []model.HistoricalRecommendationSet{}
containers := recommendation[0].Kubernetes_objects[0].Containers
recommendationSetList := []model.RecommendationSet{}
histRecommendationSetList := []model.HistoricalRecommendationSet{}

for _, container := range containers {
for _, container := range containers {
if kruize.Is_valid_recommendation(container.Recommendations, experiment_name, maxEndTimeFromReport) {
for _, v := range container.Recommendations.Data {
marshalData, err := json.Marshal(v)
if err != nil {
Expand All @@ -89,8 +88,8 @@ func requestAndSaveRecommendation(kafkaMsg types.RecommendationKafkaMsg, recomme
recommendationSet := model.RecommendationSet{
WorkloadID: kafkaMsg.Metadata.Workload_id,
ContainerName: container.Container_name,
MonitoringStartTime: v.Duration_based.Short_term.Monitoring_start_time,
MonitoringEndTime: v.Duration_based.Short_term.Monitoring_end_time,
MonitoringStartTime: v.RecommendationTerms.Short_term.MonitoringStartTime,
MonitoringEndTime: v.MonitoringEndTime,
Recommendations: marshalData,
}
recommendationSetList = append(recommendationSetList, recommendationSet)
Expand All @@ -100,20 +99,24 @@ func requestAndSaveRecommendation(kafkaMsg types.RecommendationKafkaMsg, recomme
OrgId: kafkaMsg.Metadata.Org_id,
WorkloadID: kafkaMsg.Metadata.Workload_id,
ContainerName: container.Container_name,
MonitoringStartTime: v.Duration_based.Short_term.Monitoring_start_time,
MonitoringEndTime: v.Duration_based.Short_term.Monitoring_end_time,
MonitoringStartTime: v.RecommendationTerms.Short_term.MonitoringStartTime,
MonitoringEndTime: v.MonitoringEndTime,
Recommendations: marshalData,
}
histRecommendationSetList = append(histRecommendationSetList, historicalRecommendationSet)
}
} else {
poll_cycle_complete = true
continue
}
}
if len(recommendationSetList) > 0 {
txError := transactionForRecommendation(recommendationSetList, histRecommendationSetList, experiment_name, recommendationType)
if txError == nil {
poll_cycle_complete = true
} else {
poll_cycle_complete = false
}
} else {
poll_cycle_complete = true
invalidRecommendation.Inc()
}
return poll_cycle_complete
}
Expand Down Expand Up @@ -157,10 +160,9 @@ func PollForRecommendations(msg *kafka.Message, consumer_object *kafka.Consumer)
commitKafkaMsg(msg, consumer_object)
}
// To consume upcoming Kafka msg, explicitly
// Especially in case of un-committed msgs
return
return
case true:
// MonitoringEndTime.UTC() defaults to 0001-01-01 00:00:00 +0000 UTC if not found
// MonitoringEndTime.UTC() defaults to 0001-01-01 00:00:00 +0000 UTC if not set
if !recommendation_stored_in_db.MonitoringEndTime.UTC().IsZero() {
duration := maxEndTimeFromReport.Sub(recommendation_stored_in_db.MonitoringEndTime.UTC())
if int(duration.Hours()) >= cfg.RecommendationPollIntervalHours {
Expand Down
3 changes: 1 addition & 2 deletions scripts/samples/ros-ocp-usage-24Hrs.csv
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ report_period_start,report_period_end,interval_start,interval_end,container_name
2023-02-01 00:00:00 +0000 UTC,2023-03-01 00:00:00 +0000 UTC,2023-06-03 23:45:01 +0000 UTC,2023-06-04 00:00:00 +0000 UTC,Yuptoo-service,Yuptoo-app-standalone-1,Yuptoo-app,ReplicaSet,<none>,deployment,Yuptoo-prod,quay.io/cloudservices/yuptoo,ip-10-0-176-227.us-east-2.compute.internal,i-0dfbb3fa4d0e8fc94,1,1,1,1,0.047932,0.031571,0.064131,0.047932,0,0,0,1073741824,1073741824,1073741824,1073741824,513587266.064516,510009344,513900544,513587266.064516,493311537.548387,493293568,493371392,493311537.548387
2023-02-01 00:00:00 +0000 UTC,2023-03-01 00:00:00 +0000 UTC,2023-06-04 00:00:01 +0000 UTC,2023-06-04 00:15:00 +0000 UTC,Yuptoo-service,Yuptoo-app-standalone-1,Yuptoo-app,ReplicaSet,<none>,deployment,Yuptoo-prod,quay.io/cloudservices/yuptoo,ip-10-0-176-227.us-east-2.compute.internal,i-0dfbb3fa4d0e8fc94,1,1,1,1,0.047932,0.031571,0.064131,0.047932,0,0,0,1073741824,1073741824,1073741824,1073741824,513587266.064516,510009344,513900544,513587266.064516,493311537.548387,493293568,493371392,493311537.548387
2023-02-01 00:00:00 +0000 UTC,2023-03-01 00:00:00 +0000 UTC,2023-06-04 00:15:01 +0000 UTC,2023-06-04 00:30:00 +0000 UTC,Yuptoo-service,Yuptoo-app-standalone-1,Yuptoo-app,ReplicaSet,<none>,deployment,Yuptoo-prod,quay.io/cloudservices/yuptoo,ip-10-0-176-227.us-east-2.compute.internal,i-0dfbb3fa4d0e8fc94,1,1,1,1,0.047932,0.031571,0.064131,0.047932,0,0,0,1073741824,1073741824,1073741824,1073741824,513587266.064516,510009344,513900544,513587266.064516,493311537.548387,493293568,493371392,493311537.548387
2023-02-01 00:00:00 +0000 UTC,2023-03-01 00:00:00 +0000 UTC,2023-06-04 00:30:01 +0000 UTC,2023-06-04 00:45:00 +0000 UTC,Yuptoo-service,Yuptoo-app-standalone-1,Yuptoo-app,ReplicaSet,<none>,deployment,Yuptoo-prod,quay.io/cloudservices/yuptoo,ip-10-0-176-227.us-east-2.compute.internal,i-0dfbb3fa4d0e8fc94,1,1,1,1,0.047932,0.031571,0.064131,0.047932,0,0,0,1073741824,1073741824,1073741824,1073741824,513587266.064516,510009344,513900544,513587266.064516,493311537.548387,493293568,493371392,493311537.548387
2023-02-01 00:00:00 +0000 UTC,2023-03-01 00:00:00 +0000 UTC,2023-06-04 00:30:01 +0000 UTC,2023-06-04 00:45:00 +0000 UTC,Yuptoo-service,Yuptoo-app-standalone-1,Yuptoo-app,ReplicaSet,<none>,deployment,Yuptoo-prod,quay.io/cloudservices/yuptoo,ip-10-0-176-227.us-east-2.compute.internal,i-0dfbb3fa4d0e8fc94,1,1,1,1,0.047932,0.031571,0.064131,0.047932,0,0,0,1073741824,1073741824,1073741824,1073741824,513587266.064516,510009344,513900544,513587266.064516,493311537.548387,493293568,493371392,493311537.548387
2023-02-01 00:00:00 +0000 UTC,2023-03-01 00:00:00 +0000 UTC,2023-06-04 00:30:01 +0000 UTC,2023-06-04 00:45:00 +0000 UTC,Yuptoo-service,Yuptoo-app-standalone-1,Yuptoo-app,ReplicaSet,<none>,deployment,Yuptoo-prod,quay.io/cloudservices/yuptoo,ip-10-0-176-227.us-east-2.compute.internal,i-0dfbb3fa4d0e8fc94,1,1,1,1,0.047932,0.031571,0.064131,0.047932,0,0,0,1073741824,1073741824,1073741824,1073741824,513587266.064516,510009344,513900544,513587266.064516,493311537.548387,493293568,493371392,493311537.548387
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate row removed

Loading