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

🐛 Set container image platform before calling SynchronizeAssets #172

Merged
merged 6 commits into from
Nov 21, 2022

Conversation

imilchev
Copy link
Member

@imilchev imilchev commented Nov 8, 2022

Discussed with @preslavgerchev and @jaym and we agreed that we should add a temporary fix for this problem until we have a more long term solution. Please see if you can come up with any other type of asset that might have the same issue so I can add it to the function that fixes the platform information

@chris-rock
Copy link
Member

I do not think we should do that approach if we do not cache the image

// TODO: this is a temporary fix for populating the platform information for assets that only set it
// during a scan, e.g. container images. This should be removed once we start using MQL for retrieving
// platform information.
if err := setPlatforms(ctx, assetList, im, job.DoRecord); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

this is problematic. Opening a connection can be very expensive. I think it would be better if you opened the connection, get the platform id, call sync asset, then scan the asset.

I think ebs scanning is one of the things that will suffer from this. cc @vjeffrey

Copy link
Member Author

Choose a reason for hiding this comment

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

I could do that. The only downside is that there will be 2 code paths that do asset synchronization

Copy link
Contributor

Choose a reason for hiding this comment

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

i'm not sure i understand why there would be 2

Copy link
Member Author

Choose a reason for hiding this comment

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

I changed it. Not sure if that is exactly what you had in mind

Copy link
Contributor

Choose a reason for hiding this comment

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

what is the original problem this is all fixing? is it that some assets do not get platform information until they are scanned?

Copy link
Contributor

Choose a reason for hiding this comment

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

@vjeffrey yup, previously we had a SyncAssets call after the scan was done that was populating that info (pre-v7). Thats no longer there

Copy link
Contributor

Choose a reason for hiding this comment

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

i think i'm still unclear, bc there also other cases where we don't have the platform info, right? e.g. aws with ec2 discovery, we likely won't be able to connect directly to all the instances, so a bunch of them won't have the platform info unless we scan the instance directly.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is not the latest change. In the latest change the assets which platform changes are being sync-ed

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 got it, so basically anything that doesn't get platform information during the first sync call never gets its platform information in the console, because we're no longer calling sync/set asset as part of the scan path.

just tested this with ebs volume scanning, it definitely suffers from the same issue. a lot of stuff is going to suffer from this (ec2 instances that are discovered along with an aws account, for example)

@chris-rock
Copy link
Member

If we go with this route, we also need to fix it for cnquery scan command

@vjeffrey
Copy link
Contributor

vjeffrey commented Nov 16, 2022

we had a mtg about this.

current idea:

  • we already get the platform information on line 274ish, so instead of calling synchronise assets once with all the assets, we're going to call it for each asset (once per asset), once we have the platform info (should also resolve a timeout that was observed)
  • follow up issue will be to look into batching for that (create issue in this repo, issue will be added to internal bugs board)

@imilchev
Copy link
Member Author

I updated the code according to what we discussed. Also opened a follow-up issue for looking into batching SynchronizeAssets calls #197

Signed-off-by: Ivan Milchev <ivan@mondoo.com>
Signed-off-by: Ivan Milchev <ivan@mondoo.com>
Signed-off-by: Ivan Milchev <ivan@mondoo.com>
Signed-off-by: Ivan Milchev <ivan@mondoo.com>
Signed-off-by: Ivan Milchev <ivan@mondoo.com>
Signed-off-by: Ivan Milchev <ivan@mondoo.com>
@imilchev imilchev merged commit 7b7a1c1 into main Nov 21, 2022
@imilchev imilchev deleted the ivan/set-container-platform branch November 21, 2022 10:16
@github-actions github-actions bot locked and limited conversation to collaborators Nov 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants