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

Conversation

@ralfgehrer
Copy link
Contributor

@ralfgehrer ralfgehrer commented Nov 16, 2020

Expected result:

  • Regular exposure checks are visible in the exposure log around every 4 hours (increased frequency for exposure checks)

Note for testing:

  • only time travel into the future, please.

@ralfgehrer ralfgehrer added the maintainers Tag pull requests created by maintainers label Nov 16, 2020
@ralfgehrer ralfgehrer added this to the 1.7.0 milestone Nov 16, 2020
@ralfgehrer ralfgehrer requested a review from a team November 16, 2020 13:41
@chiljamgossow chiljamgossow self-assigned this Nov 16, 2020
chiljamgossow
chiljamgossow previously approved these changes Nov 16, 2020
@chiljamgossow
Copy link
Contributor

I couldn't test on a device (do not have one yet)

@Oliver-Zimmerman Oliver-Zimmerman self-assigned this Nov 16, 2020
@harambasicluka harambasicluka added the prio PRs to review first. label Nov 16, 2020
@harambasicluka
Copy link
Contributor

Will do the device testing for @chiljamgossow .

@harambasicluka harambasicluka self-assigned this Nov 16, 2020
@d4rken d4rken self-requested a review November 16, 2020 14:38
)
return (LocalData.lastTimeDiagnosisKeysFromServerFetch() == null ||
currentDate.withTimeAtStartOfDay() != lastFetch.withTimeAtStartOfDay()).also {
currentDate.isAfter(lastFetch)).also {
Copy link
Member

@d4rken d4rken Nov 16, 2020

Choose a reason for hiding this comment

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

What effect will this have? Won't this always be true, unless we have a sub-milliseconds racecondition (unlikely).
timeStamper.nowUTC will always be after LocalData.lastTimeDiagnosisKeysFromServerFetch().

Copy link
Contributor

Choose a reason for hiding this comment

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

i agree. what harm would it do if we just delete the complete condition?

Copy link
Member

Choose a reason for hiding this comment

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

I think it's already effectively removed, because currentDate.isAfter(lastFetch) will almost always return true.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, my thinking too. The check solely protects us from someone time traveling backward.
IMHO all these checks should not be implemented by the Task but rather by the KeyPackageSyncTool.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I tested again and it seems it is always returning true.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed it entirely while ensuring that the task is only being run once every hour.

val keysWereNotAlreadyRetrieved =
LocalData.lastTimeDiagnosisKeysFromServerFetch() == null ||
currentDate.withTimeAtStartOfDay() != lastFetch.withTimeAtStartOfDay()
currentDate.isAfter(lastFetch)
Copy link
Member

Choose a reason for hiding this comment

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

Same here, against what case of unwated execution does the check of currentDate.isAfter(lastFetch) protect us?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

see above. Same check.

Copy link
Contributor Author

@ralfgehrer ralfgehrer Nov 16, 2020

Choose a reason for hiding this comment

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

Implemented this differently now. Making sure the task is only run once every hour.

@d4rken
Copy link
Member

d4rken commented Nov 16, 2020

It should be tested how often the task is now executed, especially when opening/closing the UI.

We should observe the webrequests in the log. Even if we run the task more often:

  • KeyPackageSyncTool should not make a network request unless new day or hour packages are expected (based on last data and current timestamp)
  • AppConfig will get called each time. This may still be an issue, because despite our current caching we will still load the app-config headers from the server to compare the ETag against the one we have cached.

After that, before submission we would evaluate these conditions and abort if called too often:

if (exposureConfig.maxExposureDetectionsPerUTCDay == 0) {
Timber.tag(TAG).w("Exposure detections are disabled! maxExposureDetectionsPerUTCDay=0")
return object : Task.Result {}
}
if (wasLastDetectionPerformedRecently(now, exposureConfig, trackedExposureDetections)) {
// At most one detection every 6h
return object : Task.Result {}
}
if (hasRecentDetectionAndNoNewFiles(now, keySyncResult, trackedExposureDetections)) {
// Last check was within 24h, and there are no new files.
return object : Task.Result {}
}

@Oliver-Zimmerman Oliver-Zimmerman dismissed their stale review November 16, 2020 14:55

it seems D4rken is correct about the condition always returning true

Copy link
Contributor

@harambasicluka harambasicluka left a comment

Choose a reason for hiding this comment

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

Could you please add some tests. Will let it run over the night and check the logs tomorrow.

@harambasicluka
Copy link
Contributor

clean install, that's what I see directly after the onboarding
image

I only got the "Unknown Risk" after a force close.

@ralfgehrer
Copy link
Contributor Author

clean install, that's what I see directly after the onboarding

I only got the "Unknown Risk" after a force close.

Fixed.

@mlenkeit
Copy link
Member

mlenkeit commented Nov 17, 2020

Download looks better, I'll keep it running for some time.
But after I installed the client from this branch (over 1.7.0-RC3), the risk card changed from red to green and from 4 encounters to zero without updating the timestamp. Is that just another fix that's missing in this branch here?

See screenshot below:
right at 10:30 with 1.7.0-RC3 and left at 11:00 with this branch.

image

harambasicluka
harambasicluka previously approved these changes Nov 17, 2020
Copy link
Contributor

@harambasicluka harambasicluka left a comment

Choose a reason for hiding this comment

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

Coding looks fine, ticket is solved, tested it over night, logs & exposure logs in os settings looks as expected. Also the initial wrong state is resolved.

@d4rken
Copy link
Member

d4rken commented Nov 17, 2020

But after I installed the client from this branch (over 1.7.0-RC3), the risk card changed from red to green and from 4 encounters to zero without updating the timestamp. Is that just another fix that's missing in this branch here?

And it never changed back to the red card?

@mlenkeit
Copy link
Member

But after I installed the client from this branch (over 1.7.0-RC3), the risk card changed from red to green and from 4 encounters to zero without updating the timestamp. Is that just another fix that's missing in this branch here?

And it never changed back to the red card?

I'll tell you in 30 minutes when the next Risk Calculation runs...

@mlenkeit
Copy link
Member

mlenkeit commented Nov 17, 2020

But after I installed the client from this branch (over 1.7.0-RC3), the risk card changed from red to green and from 4 encounters to zero without updating the timestamp. Is that just another fix that's missing in this branch here?

And it never changed back to the red card?

It's a bit chaotic.

  • previous risk calculation was at 7:56, red with 4 encounters
  • next one should run no earlier than 11:56
  • at 11:05, I installed this branch and the card turned green with 0 encounters
  • at 11:58, I opened the app, nothing happened
  • at 12:01, I terminated the app, opened it again
  • client downloaded new hour package as expected, runs the risk calculation (which should have run at 11:58 already), returns to a red card with 4 encounters; timestamp did not update (still shows 07:56)

I have logs, videos, etc.

@mlenkeit
Copy link
Member

And another navigation inside the app leads to:
image

@ralfgehrer
Copy link
Contributor Author

But after I installed the client from this branch (over 1.7.0-RC3), the risk card changed from red to green and from 4 encounters to zero without updating the timestamp. Is that just another fix that's missing in this branch here?

And it never changed back to the red card?

It's a bit chaotic.

  • previous risk calculation was at 7:56, red with 4 encounters
  • next one should run no earlier than 11:56
  • at 11:05, I installed this branch and the card turned green with 0 encounters
  • at 11:58, I opened the app, nothing happened
  • at 12:01, I terminated the app, opened it again
  • client downloaded new hour package as expected, runs the risk calculation (which should have run at 11:58 already), returns to a red card with 4 encounters; timestamp did not update (still shows 07:56)

I have logs, videos, etc.

At 11:05 - the download task run - hence it won't run for another hour (with the current implementation) IF the app is not terminated (next "regular" download would be at 12:05)

At 12:01 - app was killed, download triggered by opening the app - next download should be expected at 13:01

To my understanding, the download task runs as expected BUT there seems to be some issue regarding the UI states and their update.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@harambasicluka harambasicluka merged commit 87a5f7a into release/1.7.x Nov 17, 2020
@harambasicluka harambasicluka deleted the fix/3771-increased-exposue-check branch November 17, 2020 16:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

maintainers Tag pull requests created by maintainers prio PRs to review first.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants