-
Notifications
You must be signed in to change notification settings - Fork 733
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove some circular dependencies on container engine (#1547)
* make container_engine_base * remove direct container_manager and sinsp dependencies inside container_engine
- Loading branch information
Showing
26 changed files
with
285 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
userspace/libsinsp/container_engine/container_cache_interface.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
Copyright (C) 2013-2018 Draios Inc dba Sysdig. | ||
This file is part of sysdig. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "container_info.h" | ||
|
||
namespace libsinsp | ||
{ | ||
namespace container_engine | ||
{ | ||
|
||
/** | ||
* Interface for a container cache for container engines. | ||
*/ | ||
class container_cache_interface | ||
{ | ||
public: | ||
virtual ~container_cache_interface() = default; | ||
|
||
virtual void notify_new_container(const sinsp_container_info& container_info) = 0; | ||
|
||
virtual bool should_lookup(const std::string& container_id, sinsp_container_type ctype) = 0; | ||
|
||
virtual void set_lookup_status(const std::string& container_id, sinsp_container_type ctype, sinsp_container_lookup_state state) = 0; | ||
|
||
/** | ||
* Get a container from the cache. | ||
*/ | ||
virtual sinsp_container_info::ptr_t get_container(const std::string& id) const = 0; | ||
|
||
/** | ||
* Add a new container to the cache. | ||
*/ | ||
virtual void add_container(const sinsp_container_info::ptr_t& container_info, sinsp_threadinfo *thread) = 0; | ||
|
||
/** | ||
* Return whether the container exists in the cache. | ||
*/ | ||
virtual bool container_exists(const std::string& container_id) const = 0; | ||
}; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
userspace/libsinsp/container_engine/container_engine_base.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
Copyright (C) 2013-2019 Draios Inc dba Sysdig. | ||
This file is part of sysdig. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "container_engine/container_cache_interface.h" | ||
|
||
class sinsp_threadinfo; | ||
|
||
namespace libsinsp { | ||
namespace container_engine { | ||
|
||
/** | ||
* Base class for container engine. This provided the interfaces to | ||
* associate a container with a thread. | ||
*/ | ||
class container_engine_base { | ||
public: | ||
virtual ~container_engine_base() = default; | ||
|
||
/** | ||
* Find a container associated with the given tinfo and add it to the | ||
* cache. | ||
*/ | ||
virtual bool resolve(container_cache_interface* cache, | ||
sinsp_threadinfo* tinfo, | ||
bool query_os_for_missing_info) = 0; | ||
|
||
virtual void cleanup(); | ||
}; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.