Skip to content
This repository was archived by the owner on Dec 21, 2023. It is now read-only.

#4079 support timeframe property in lighthouse service#4083

Merged
bacherfl merged 8 commits intomasterfrom
feature/4075/evaluation-timeframe
May 18, 2021
Merged

#4079 support timeframe property in lighthouse service#4083
bacherfl merged 8 commits intomasterfrom
feature/4075/evaluation-timeframe

Conversation

@bacherfl
Copy link
Copy Markdown
Member

@bacherfl bacherfl commented May 17, 2021

Closes #4079
Closes #4091

This PR also fixes a problem that caused the triggeredid of a <stage>.<sequence>.finishedevent to not be set properly when there are multiple iterations of the same sequence.

Signed-off-by: Florian Bacher florian.bacher@dynatrace.com

Remediation with one iteration:

Screenshot 2021-05-18 at 08 20 21

Note: The warning result is caused by a modification I did to the SLO.yaml in order to provoke another iteration

Remediation with two iterations:

Screenshot 2021-05-18 at 08 38 59

Integration test run: https://github.com/keptn/keptn/actions/runs/852286068

Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
@bacherfl bacherfl added the CI:trigger-build-everything Trigger CI Build: Set BUILD_EVERYTHING=TRUE label May 17, 2021
@codecov
Copy link
Copy Markdown

codecov bot commented May 17, 2021

Codecov Report

Merging #4083 (2fe3813) into master (1b37ce1) will decrease coverage by 0.49%.
The diff coverage is 88.37%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4083      +/-   ##
==========================================
- Coverage   43.64%   43.14%   -0.50%     
==========================================
  Files         236      236              
  Lines       12322    12265      -57     
  Branches      348      348              
==========================================
- Hits         5378     5292      -86     
- Misses       6244     6286      +42     
+ Partials      700      687      -13     
Flag Coverage Δ
api 29.89% <ø> (ø)
approval-service 84.61% <ø> (ø)
bridge 29.70% <ø> (ø)
cli 43.71% <83.33%> (-0.17%) ⬇️
configuration-service 19.51% <ø> (ø)
distributor 54.58% <ø> (ø)
helm-service 46.59% <ø> (ø)
jmeter-service 13.81% <ø> (ø)
lighthouse-service 56.63% <100.00%> (-5.93%) ⬇️
mongodb-datastore 24.34% <ø> (ø)
openshift-route-service 33.82% <ø> (ø)
remediation-service 46.85% <ø> (ø)
secret-service 80.00% <ø> (ø)
shipyard-controller 54.24% <86.36%> (-0.62%) ⬇️
statistics-service 55.31% <ø> (ø)
Impacted Files Coverage Δ
shipyard-controller/common/keptn_helpers.go 11.76% <0.00%> (-0.15%) ⬇️
shipyard-controller/db/mongodb_event_repo.go 0.00% <0.00%> (ø)
cli/cmd/trigger_evaluation.go 62.33% <83.33%> (+0.73%) ⬆️
...-service/event_handler/start_evaluation_handler.go 33.60% <100.00%> (-28.14%) ⬇️
shipyard-controller/handler/evaluationmanager.go 84.31% <100.00%> (-5.94%) ⬇️
lighthouse-service/event_handler/common.go 38.63% <0.00%> (-4.55%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1b37ce1...2fe3813. Read the comment docs.

bacherfl added 5 commits May 17, 2021 13:10
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
@bacherfl bacherfl marked this pull request as ready for review May 18, 2021 06:39
Comment on lines +148 to +156
params := timeutils.GetStartEndTimeParams{
StartDate: e.Evaluation.Start,
EndDate: e.Evaluation.End,
Timeframe: e.Evaluation.Timeframe,
}
start, end, err := timeutils.GetStartEndTime(params)
if err != nil {
return "", "", err
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What happens when timeframe is set, but start and end are not set?

I think in issue #4079 I got it wrong, what I meant was that
end = evaluation.triggered.time, and start = end - timeframe

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

when only the time frame is set, we adapt the same logic we did previously in the evaluation endpoint: end = time.Now(), start = time.Now() - timeframe

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The big difference here is that the evaluation endpoint is called in a specific moment.

The cloudevent is sent at a specific moment, but the time it is retrieved by lighthouse could be a different time.
Hence I would propose to not use time.Now(), but the actual cloudevents triggered time (when was the evaluation triggered).

I know it doesn't make much difference in our current setup (maybe a couple of milliseconds), but using the cloudevents time would make the behaviour reproducible and deterministic.
Think about re-triggering an evaluation.

bacherfl added 2 commits May 18, 2021 08:58
# Conflicts:
#	cli/go.mod
#	cli/go.sum
#	cli/internal/cespec/data.go
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
@github-actions
Copy link
Copy Markdown
Contributor

The following Docker Images have been built:

  • Pushed keptn/api:0.8.2-dev-PR-4083.202105180700 and keptn/api:0.8.2-dev-PR-4083 (Source: api/)
  • Pushed keptn/bridge2:0.8.2-dev-PR-4083.202105180700 and keptn/bridge2:0.8.2-dev-PR-4083 (Source: bridge/)
  • Pushed keptn/distributor:0.8.2-dev-PR-4083.202105180700 and keptn/distributor:0.8.2-dev-PR-4083 (Source: distributor/)
  • Pushed keptn/jmeter-service:0.8.2-dev-PR-4083.202105180700 and keptn/jmeter-service:0.8.2-dev-PR-4083 (Source: jmeter-service/)
  • Pushed keptn/helm-service:0.8.2-dev-PR-4083.202105180700 and keptn/helm-service:0.8.2-dev-PR-4083 (Source: helm-service/)
  • Pushed keptn/approval-service:0.8.2-dev-PR-4083.202105180700 and keptn/approval-service:0.8.2-dev-PR-4083 (Source: approval-service/)
  • Pushed keptn/openshift-route-service:0.8.2-dev-PR-4083.202105180700 and keptn/openshift-route-service:0.8.2-dev-PR-4083 (Source: platform-support/openshift-route-service/)
  • Pushed keptn/shipyard-controller:0.8.2-dev-PR-4083.202105180700 and keptn/shipyard-controller:0.8.2-dev-PR-4083 (Source: shipyard-controller/)
  • Pushed keptn/secret-service:0.8.2-dev-PR-4083.202105180700 and keptn/secret-service:0.8.2-dev-PR-4083 (Source: secret-service/)
  • Pushed keptn/configuration-service:0.8.2-dev-PR-4083.202105180700 and keptn/configuration-service:0.8.2-dev-PR-4083 (Source: configuration-service/)
  • Pushed keptn/remediation-service:0.8.2-dev-PR-4083.202105180700 and keptn/remediation-service:0.8.2-dev-PR-4083 (Source: remediation-service/)
  • Pushed keptn/lighthouse-service:0.8.2-dev-PR-4083.202105180700 and keptn/lighthouse-service:0.8.2-dev-PR-4083 (Source: lighthouse-service/)
  • Pushed keptn/mongodb-datastore:0.8.2-dev-PR-4083.202105180700 and keptn/mongodb-datastore:0.8.2-dev-PR-4083 (Source: mongodb-datastore/)
  • Pushed keptn/statistics-service:0.8.2-dev-PR-4083.202105180700 and keptn/statistics-service:0.8.2-dev-PR-4083 (Source: statistics-service/)

Copy link
Copy Markdown
Member

@christian-kreuzberger-dtx christian-kreuzberger-dtx left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

CI:trigger-build-everything Trigger CI Build: Set BUILD_EVERYTHING=TRUE

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shipyard controller: triggeredID of <stage>.<sequence>.finished events not set properly lighthouse: Allow timeframe to be passed via cloudevent

2 participants