-
Notifications
You must be signed in to change notification settings - Fork 173
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
[specific ci=Group23-Vic-Machine-Service] syslog support added to VCH create and inspect API #6582
[specific ci=Group23-Vic-Machine-Service] syslog support added to VCH create and inspect API #6582
Conversation
Are there any unit or integration tests required for this? |
@andrewtchin yes but not implemented yet. Since it's part of VCH create and inspect APIs (part of create API handler input and inspect API output), I would expect the tests be included in the create API and inspect API tests (I'm not sure how to test this separately |
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.
lgtm, pls make sure to track somewhere to add integration test for this later as in desc.
lib/apiservers/service/swagger.json
Outdated
"syslog_addr": { | ||
"type": "string", | ||
"format": "uri", | ||
"pattern": "^(tc|ud)p.*" |
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.
The documentation on SysLogConfig
(in container_vm.go
) says "Network can be udp, tcp, udp6, or tcp6". I think we should add the optional "6" to this regex.
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.
actually from the output of vic-machine-linux create -x | grep syslog
:
--syslog-address value Address of the syslog server to send Virtual Container Host logs to. Must be in the format transport://host[:port], where transport is udp or tcp.
It seems like only "udp" or "tcp" transport is supported.
I modified the swagger tried with address tcp6://127.0.0.1:4444
, it won't go into vchConfig, so even if build succeeds, inspect won't give it as output.
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.
https://github.com/vmware/vic/blob/master/lib/install/validate/validator.go#L860
Here in validator, only udp
and tcp
transport goes into config. It doesn't accept anything else
Not sure if it's a bug...
@zjs
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.
confirmed with @hmahmood that ipv6 is not officially supported by syslogs yet. So we'll go with ^(tc|ud)p
for now
@@ -79,7 +80,7 @@ func (h *VCHCreate) Handle(params operations.PostTargetTargetVchParams, principa | |||
|
|||
validator, err := validateTarget(params.HTTPRequest.Context(), d) | |||
if err != nil { | |||
return operations.NewPostTargetTargetVchDefault(400).WithPayload(&models.Error{Message: err.Error()}) | |||
return operations.NewPostTargetTargetVchDefault(http.StatusBadRequest).WithPayload(&models.Error{Message: err.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.
I think this is a really good change. Can you file an issue so that we remember to clean this up in the rest of the handlers?
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 can do it in this pr
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.
fixes done
} | ||
} | ||
} | ||
|
||
if len(vch.SyslogAddr) > 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.
Other places in this handler, we seem to be checking != ""
. I don't know which pattern is better, but I think it would be good to be consistent.
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.
!= ""
makes more sense.
I was still in the java mindset that strings cannot be directly compared with equals
if err := c.ProcessSyslog(); err != nil { | ||
return nil, util.NewError(http.StatusBadRequest, fmt.Sprintf("Error processing syslog server address: %s", err)) | ||
} | ||
} |
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 can't you write a simple unit test to verify these new code paths?
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 is part of the create API handler and we haven't figured out a pattern to do unit tests on swagger handlers yet.
The new code path validates a field in http GET request JSON, and it's very hard to test it separately from all the other fields related to vch create params.
We're planning to integrate this in unit tests for create API as a whole (the tracking story is: #6018)
* syslog support added to VCH create API * syslog addr added to inspect output * syslog_addr format changed in swagger * use status code in http package * empty syslog_addr string checking * swagger format changed for syslog_addr * roll back in swagger: only tcp and udp are accepted
* syslog support added to VCH create API * syslog addr added to inspect output * syslog_addr format changed in swagger * use status code in http package * empty syslog_addr string checking * swagger format changed for syslog_addr * roll back in swagger: only tcp and udp are accepted
* syslog support added to VCH create API * syslog addr added to inspect output * syslog_addr format changed in swagger * use status code in http package * empty syslog_addr string checking * swagger format changed for syslog_addr * roll back in swagger: only tcp and udp are accepted
* syslog support added to VCH create API * syslog addr added to inspect output * syslog_addr format changed in swagger * use status code in http package * empty syslog_addr string checking * swagger format changed for syslog_addr * roll back in swagger: only tcp and udp are accepted
* syslog support added to VCH create API * syslog addr added to inspect output * syslog_addr format changed in swagger * use status code in http package * empty syslog_addr string checking * swagger format changed for syslog_addr * roll back in swagger: only tcp and udp are accepted
* syslog support added to VCH create API * syslog addr added to inspect output * syslog_addr format changed in swagger * use status code in http package * empty syslog_addr string checking * swagger format changed for syslog_addr * roll back in swagger: only tcp and udp are accepted
* syslog support added to VCH create API * syslog addr added to inspect output * syslog_addr format changed in swagger * use status code in http package * empty syslog_addr string checking * swagger format changed for syslog_addr * roll back in swagger: only tcp and udp are accepted
* syslog support added to VCH create API * syslog addr added to inspect output * syslog_addr format changed in swagger * use status code in http package * empty syslog_addr string checking * swagger format changed for syslog_addr * roll back in swagger: only tcp and udp are accepted
* syslog support added to VCH create API * syslog addr added to inspect output * syslog_addr format changed in swagger * use status code in http package * empty syslog_addr string checking * swagger format changed for syslog_addr * roll back in swagger: only tcp and udp are accepted
* syslog support added to VCH create API * syslog addr added to inspect output * syslog_addr format changed in swagger * use status code in http package * empty syslog_addr string checking * swagger format changed for syslog_addr * roll back in swagger: only tcp and udp are accepted
* syslog support added to VCH create API * syslog addr added to inspect output * syslog_addr format changed in swagger * use status code in http package * empty syslog_addr string checking * swagger format changed for syslog_addr * roll back in swagger: only tcp and udp are accepted
Fixes #6476
syslog support is now added to vic-machine create API and inspect API.
Details
POST request body includes a
syslog_addr
field of type string that specifies the syslog server address.syslog_addr
must have formattransport://host[:port]
, where transport is udp or tcp (ipv6 is not officially supported yet)(For example:
tcp://127.0.0.1:4444
)An example of vic-machine create API request body:
The response body of POST request now includes a field
syslog_addr
field of type string that includes the syslog server address that the user is specified when the VCH is first created.Example vic-machine inspect GET response body:
Remaining work
Pending integration tests that checks if syslog server configuration on create and inspect, and unit tests.
Will be integrated after create API test and inspect API test are ready.
(tracking story: #6018 )