Skip to content
This repository has been archived by the owner on Feb 24, 2020. It is now read-only.

stage0: prevent skipping some images in image gc #3778

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

sanicheev
Copy link

…ion is unable to process whole image tree

…ration is unable to process whole image tree
@iaguis
Copy link
Member

iaguis commented Aug 22, 2017

About the first break, we're iterating over a slice that was obtained by calling

aciinfos, err := s.GetAllACIInfos([]string{"lastused"}, true)

This means the images will be sorted by lastused in ascending order so when we reach the grace period, we should break to avoid unnecessary processing.

About the second break, it seems like a bug, images can be in the running set even if they're older than the grace period so we might miss some of them.

@sanicheev
Copy link
Author

@iaguis, i think 1st one should be using break and the 2nd one should be using continue. Should i adjust my PR?

…ration is unable to process whole image tree
@sanicheev
Copy link
Author

Looks like semaphoreci has failed with an error: no disk space left on device. Build should be stable.

@iaguis
Copy link
Member

iaguis commented Aug 23, 2017

This looks good. Do you mind adjusting the commit message to follow our commit convention?

It can start like this:

rkt: prevent skipping some images in image gc

We were using break when we found an image with a pod in running state...

Thanks a lot for the contribution!

@iaguis
Copy link
Member

iaguis commented Aug 23, 2017

It'd be great if you could write a functional test for this. It's a more challenging task but I can try to guide you through it if you want to give it a try.

@lucab
Copy link
Member

lucab commented Aug 23, 2017

@sanicheev don't worry too much about temporary flakes, I re-triggered semaphore and it's green now.

@sanicheev
Copy link
Author

@iaguis i'll try. is it ok if i'll create 'getRunningImages' test function which will return fake data?( i couldn't find if it's already exists)

@sanicheev
Copy link
Author

guys give me some time plz to adjust my commit message and to write proper unit tests.

@iaguis
Copy link
Member

iaguis commented Aug 23, 2017

I had in mind adding a functional test to https://github.com/rkt/rkt/blob/master/tests/rkt_image_gc_test.go but maybe a unit test is enough to cover this change. In that case a mock getRunningImages is fine.

@iaguis
Copy link
Member

iaguis commented Aug 23, 2017

guys give me some time plz to adjust my commit message and to write proper unit tests.

No hurries :)

@sanicheev
Copy link
Author

@iaguis , almost done. just not sure how to populate acinfo DB properly.

@lucab lucab changed the title #3772 continue should be used instead break. Otherwise cleanup operat… stage0: prevent skipping some images in image gc Aug 23, 2017
@lucab lucab requested a review from iaguis September 20, 2017 12:18
@iaguis
Copy link
Member

iaguis commented Sep 20, 2017

@sanicheev any chance you can finish this test?

@sanicheev
Copy link
Author

Sorry for a delay. Yes i'll push it during this weekend.

@lucab lucab added this to the 1.30.0 milestone Sep 21, 2017
Serghei Anicheev added 3 commits September 24, 2017 19:27
```
Attempting to add unit tests for image_gc

```
```
Attempting to fix image_gc unit tests
```
```
Attempting to fix image_gc tests
```
@sanicheev
Copy link
Author

sanicheev commented Sep 24, 2017

@iaguis am i going the right path here?(my go background is not strong enough at the moment and i want to fix that)

Because i'm thinking to use database/sql package functionality instead of hardcoding image info in a file. And it might be a good idea to put it under testutils/populateimagestore.go file and then call it during the test.

Serghei Anicheev added 5 commits September 24, 2017 21:02
```
Trying to fix image_gc unit tests
```
```
Applying gofmt suggestions
```
```
Attempting to fix image_gc unit tests
```
```
Attempting to fim image_gc unit tests
```
```
Attempting to fix image_gc unit tests
```
@sanicheev
Copy link
Author

@iaguis , @lucab guys is everything ok with this unit test or should it be adjusted as i suggested?

@iaguis
Copy link
Member

iaguis commented Oct 13, 2017

Sorry for the late reply.

What you did was copying the function logic to the test function, substituting the pieces that interact with the store with mock functions.

The mocking part is fine, what's problematic is copying the code to the test function. Keep in mind that unit tests need to test the actual functions that are present in the code, so that when the function changes, we can detect problems. The way you did it, you'd have to remember to change the code in the test when you change the function in the code.

What I'd do is extract the loop to its own function in rkt's code and then test that function. In this way you can keep using the mock functions you added in the test and you'll be testing the actual rkt code.

@sanicheev
Copy link
Author

@iaguis, thank you i'll try to adjust

@iaguis iaguis mentioned this pull request Nov 1, 2017
@iaguis iaguis modified the milestones: 1.30.0, vfuture Apr 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants