-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Specify log file through API #250
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
Conversation
assert!(&desc.into_parsed_request().is_ok()); | ||
// I will test this when the other unit tests are merged | ||
//let (sender, receiver) = oneshot::channel(); | ||
//assert!(&desc.into_parsed_request().eq(&Ok(ParsedRequest::Sync(SyncRequest::PutLogger(desc, sender), receiver)))); |
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.
In order for this to work, you need to implement the use case for PutLogger
in impl PartialEq for SyncRequest
.
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.
Done. Thanks for the hint.
logger/src/lib.rs
Outdated
|
||
static INIT: Once = ONCE_INIT; | ||
static mut INIT_RES: Result<usize> = Ok(UNINITIALIZED); | ||
//static INIT: Once = ONCE_INIT; |
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.
If INIT isn't needed any more, please remove it instead of commenting it out.
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.
Removed.
INIT_RES = Err(LoggerError::NeverInitialized(format!("{}", e))) | ||
Err(ref e) => { | ||
STATE.store(UNINITIALIZED, Ordering::SeqCst); | ||
return Err(LoggerError::NeverInitialized(format!("{}", e))); |
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.
Cosmetic concern: the error e
is propagated all the way up from libstd::io::File::create
and is one of libstd::io::error::ErrorKind
, the string representations of which are all lowercase. So the error message (as seen in the tests run) looks like
{
"fault_message": "Cannot initialize logging system! Failed to create log file. entity not found"
}
Can you please make the error message something like Failed to create log file. Error: <propagated error>
?
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.
Solved it; Take a look at error.rs in impl fmt::Display for LoggerError
.
vmm/src/lib.rs
Outdated
} | ||
} | ||
SyncRequest::PutLogger(logger_description, sender) => { | ||
eprintln!( |
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.
Is this for debugging purposes only?
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 mistakenly left it there. I removed it now.
api/swagger/firecracker-beta.yaml
Outdated
description: | ||
Describes the configuration option for the logger intitialization. | ||
properties: | ||
source_type: |
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.
This field is not necessary. Just use the path like all other resources currently do. When we move to FD passing, we will change all API calls from using path to using FDs.
I believe this field will never be used so I suggest removing it.
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.
Are you confident that we will only support FD passing? Why not keep around both versions?
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 am confident we will not support both versions at the same time 😃
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.
hehe :) I will do the change.
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.
done, take a look please
@@ -143,6 +143,29 @@ paths: | |||
schema: | |||
$ref: "#/definitions/Error" | |||
|
|||
/logger: |
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.
Please add these to firecracker-v1.0.yaml as well.
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.
We discussed about it yesterday. firecracker-v1.0.yaml is very outdated. So we have here two possibilities: either update it to match what we have now in firecracker-beta, or we don't update it at all for now and only use it as a " What the future looks like" yaml. Since we are sort of time bound, I suggest we don't update it for now.
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.
Ok
api_server/src/http_service.rs
Outdated
@@ -258,6 +277,8 @@ fn parse_request<'a>( | |||
method, | |||
path, | |||
str::from_utf8(body.as_ref()).unwrap() | |||
// when time will come, we could better do | |||
serde_json::from_slice(&body).unwrap() |
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.
Uncommenting this debug block breaks compilation with this change.
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 know. I left it there to consider it as an option 'when time will come'. Do we want me to remove it or solve the compilation errors?
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's more of a nit, you could leave it as is, but I would add '//' to it so that the code still works when uncommenting the whole block.
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 added a comment.
|
||
type Result<T> = result::Result<T, APILoggerError>; | ||
|
||
pub fn init_logger(api_logger: APILoggerDescription) -> Result<()> { |
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.
Ideally you could've/should've used the new API<->VMM model that uses common data structs for both api_server and vmm.
This new model is the one proposed in @andreeaflorescu 's PR #248 in the data_model crate.
The code here looks very good and I'm personally fine with merging it, but do have a look at the aforementioned PR and decide for yourself.
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.
So, if you take a closer look you will see that logger_config does not redefine any type; What #248 wants is to remove the necessity to redefine types inside vmm, which in my case does not happen.
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.
Ok
logger/src/error.rs
Outdated
"{:?}", | ||
LoggerError::Poisoned(String::from("Never Initialized")) | ||
).contains("Poisoned") | ||
println!( |
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.
Why do we want to print all of these (all the println!s in this test) during unit tests?
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.
to increase coverage; this prints are the ones that exercise the Debug trait.
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.
They exercise, but don't check anything thus giving us false coverage.
Without proper checking we could break something and unittests and coverage will still look good.
I suggest you find a way to actually check the Debug trait output, or otherwise remove this and leave it without coverage.
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.
done, take a look.
through an API call. Signed-off-by: Diana Popa <[email protected]>
* removed static variable for keeping status * used AtomicSize for safely sharing state between threads * appended relevant error on top of the low level one * removed Poison status error as it stopped us from being able to try reinitialization Signed-off-by: Diana Popa <[email protected]>
* call asserts on the last code in the test_init * exercise Display for the LoggerError Signed-off-by: Diana Popa <[email protected]>
Signed-off-by: Diana Popa <[email protected]>
inside the vmm as an intermediate step in the logger setup triggered by the API. Signed-off-by: Diana Popa <[email protected]>
Changes
Testing
Build Time
Prerequisite
## add the necessary musl target to the active toolchain rustup target add x86_64-unknown-linux-musl
Build tests
Coverage report for logger related files
Integration Testing
rm -f /tmp/firecracker.socket && \ target/x86_64-unknown-linux-musl/debug/firecracker --api-sock=/tmp/firecracker.socket