-
Notifications
You must be signed in to change notification settings - Fork 170
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
feat(libsinsp/container_info): change default / init lookup state to FAILED
#1707
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ docker_base::resolve_impl(sinsp_threadinfo *tinfo, const docker_lookup_request& | |
auto container = sinsp_container_info(); | ||
container.m_type = request.container_type; | ||
container.m_id = request.container_id; | ||
container.set_lookup_status(sinsp_container_lookup::state::SUCCESSFUL); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CRI and docker mostly handled the lookup state correctly, except here it was necessary to add. |
||
cache->notify_new_container(container, tinfo); | ||
return true; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,8 +131,13 @@ TEST_F(sinsp_with_test_input, event_sources) | |
ASSERT_FALSE(field_has_value(evt, "evt.asynctype")); | ||
|
||
// metaevents have the "syscall" event source | ||
evt = add_event_advance_ts(increasing_ts(), 1, PPME_CONTAINER_JSON_E, 1, "{\"value\": 1}"); | ||
ASSERT_EQ(evt->get_type(), PPME_CONTAINER_JSON_E); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was it intentional to use the deprecated event type There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cc @FedeDP There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't write those tests, i don't know why they used PPME_CONTAINER_JSON_E. Most probably it was just an oversight. |
||
std::shared_ptr<sinsp_container_info> container = std::make_shared<sinsp_container_info>(); | ||
container->m_type = CT_CONTAINERD; | ||
container->m_id = "3ad7b26ded6d"; | ||
container->set_lookup_status(sinsp_container_lookup::state::SUCCESSFUL); | ||
std::string container_json = m_inspector.m_container_manager.container_to_json(*container); | ||
evt = add_event_advance_ts(increasing_ts(), -1, PPME_CONTAINER_JSON_2_E, 1, container_json.c_str()); | ||
ASSERT_EQ(evt->get_type(), PPME_CONTAINER_JSON_2_E); | ||
ASSERT_EQ(evt->get_source_idx(), syscall_source_idx); | ||
ASSERT_EQ(std::string(evt->get_source_name()), syscall_source_name); | ||
ASSERT_EQ(get_field_as_string(evt, "evt.source"), syscall_source_name); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering whether it would be better to set the SUCCESSFUL lookup status inside
container_cache().notify_new_container()
: it requires less changes and it "feels" better, ie: since we are notifying the new container, we mark the container as successfully looked up.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels less error prone too (like: a new engine gets introduced and we forgot to add the
set_lookup_state
call).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except some container engines (e.g.
libvirt_lxc
) add the container to the cache and already expect the lookup status to be SUCCESSFUL, so that notify_new_container() doesn't do anything.As stated more at the beginning of the PR this change is just an initial improvement so that the lookup state is not SUCCESSFUL by default, which makes not a lot of sense and can backfire even more. We have this issue (#1708) we wanted to work on after Falco 0.38.0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sorry, i completely overlooked that. Then we are good to go!