摘要:本文首發(fā)于泊浮目的專欄在前文源碼剖析之二次開(kāi)發(fā)可擴(kuò)展框架中,我們大概的了解了如何在中進(jìn)行二次開(kāi)發(fā)。在還有相關(guān)的日志,有興趣的讀者可以自行搜索。掛斷點(diǎn)在掛斷點(diǎn)之前,請(qǐng)確定自己的開(kāi)放了相應(yīng)的端口。之后記得使用關(guān)掉。
本文首發(fā)于泊浮目的專欄:https://segmentfault.com/blog...
在前文 ZStack源碼剖析之二次開(kāi)發(fā)——可擴(kuò)展框架中,我們大概的了解了如何在ZStack中進(jìn)行二次開(kāi)發(fā)。在本文,筆者將和大家一起了解一下常用debug管理節(jié)點(diǎn)的方法,用于更好的了解運(yùn)行時(shí)的情況。
使用日志來(lái)debug閱讀日志可以算是最為輕量級(jí)的手段了——同理,在大多數(shù)情況下,我們最好通過(guò)打印日志來(lái)觀察我們的程序。我們以創(chuàng)建VM為例,看看如何在日志中跟蹤它的Trace。
當(dāng)創(chuàng)建VM以后,我們可以從右上角查看消息記錄。如:
請(qǐng)求: { "type": "post", "path": "vm-instances", "body": { "params": { "name": "vm1", "description": "", "instanceOfferingUuid": "aee8b43d672e4b019e76471d3767e93a", "imageUuid": "e588b839d3013f4fa1490695bc5cd5fb", "l3NetworkUuids": [ "62dc48a48f964e73b463dad1a86089df" ], "dataDiskOfferingUuids": [], "systemTags": [ "usbRedirect::false", "vmConsoleMode::vnc" ] } }, "sessionUuid": "5bcb2d86e1c64c8ea2568a2d311a90ed", "jobUuid": "84d99d2d663856dea44c6eb1a80f9599" } 返回: { "inventory": { "uuid": "557c0ee1abeb4cd7929675cf0a239610", "name": "vm1", "description": "", "zoneUuid": "04d920c5dd9342f3bbf7da6a6ece3270", "clusterUuid": "627ef14b478d4547ba8c3ef5df65e14f", "imageUuid": "e588b839d3013f4fa1490695bc5cd5fb", "hostUuid": "3cd0c0d21feb4b5bbf2d962494aa2747", "lastHostUuid": "3cd0c0d21feb4b5bbf2d962494aa2747", "instanceOfferingUuid": "aee8b43d672e4b019e76471d3767e93a", "rootVolumeUuid": "725fbcd4f29e4c7eb584dc83d444c9c3", "platform": "Linux", "defaultL3NetworkUuid": "62dc48a48f964e73b463dad1a86089df", "type": "UserVm", "hypervisorType": "KVM", "memorySize": 1073741824, "cpuNum": 1, "cpuSpeed": 0, "allocatorStrategy": "LeastVmPreferredHostAllocatorStrategy", "createDate": "Mar 13, 2018 10:02:58 PM", "lastOpDate": "Mar 13, 2018 10:03:03 PM", "state": "Running", "internalId": 9, "vmNics": [ { "uuid": "1537216f71d6439dab7e27d2c90e78ef", "vmInstanceUuid": "557c0ee1abeb4cd7929675cf0a239610", "usedIpUuid": "b9dc65ad184f3d8aae43e8082ee86705", "l3NetworkUuid": "62dc48a48f964e73b463dad1a86089df", "ip": "10.107.100.84", "mac": "fa:97:15:73:da:00", "netmask": "255.0.0.0", "gateway": "10.0.0.1", "internalName": "vnic9.0", "deviceId": 0, "createDate": "Mar 13, 2018 10:02:58 PM", "lastOpDate": "Mar 13, 2018 10:02:58 PM" } ], "allVolumes": [ { "uuid": "725fbcd4f29e4c7eb584dc83d444c9c3", "name": "ROOT-for-vm1", "description": "Root volume for VM[uuid:557c0ee1abeb4cd7929675cf0a239610]", "primaryStorageUuid": "53967115ef324a85b634ceb27e84952f", "vmInstanceUuid": "557c0ee1abeb4cd7929675cf0a239610", "rootImageUuid": "e588b839d3013f4fa1490695bc5cd5fb", "installPath": "/opt/zstack/nfsprimarystorage/prim-53967115ef324a85b634ceb27e84952f/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-725fbcd4f29e4c7eb584dc83d444c9c3/725fbcd4f29e4c7eb584dc83d444c9c3.qcow2", "type": "Root", "format": "qcow2", "size": 12682240, "actualSize": 7995392, "deviceId": 0, "state": "Enabled", "status": "Ready", "createDate": "Mar 13, 2018 10:02:58 PM", "lastOpDate": "Mar 13, 2018 10:03:00 PM", "isShareable": false } ] }, "jobUuid": "84d99d2d663856dea44c6eb1a80f9599", "success": true, "sessionUuid": "5bcb2d86e1c64c8ea2568a2d311a90ed" }
在這里可以看到j(luò)obUuid為84d99d2d663856dea44c6eb1a80f9599。那么我們用這個(gè)關(guān)鍵字對(duì)MN的日志進(jìn)行g(shù)rep:
[root@test-mn-ceph ~]# grep 84d99d2d663856dea44c6eb1a80f9599 /usr/local/zstack/apache-tomcat/logs/management-server.log 2018-03-13 22:02:58,545 TRACE [request] {} [ID: 41F5004148EA6A7A4D0DC1FF7E5120B4, Method: POST] Request from 127.0.0.1 (to /zstack/v1/vm-instances), Headers: {"accept":["text/plain, text/plain, application/json, application/*+json, */*, */*"],"content-type":["application/json;charsetu003dutf-8"],"authorization":["OAuth 5bcb2d86e1c64c8ea2568a2d311a90ed"],"x-job-uuid":["84d99d2d663856dea44c6eb1a80f9599"],"x-web-hook":["http://0.0.0.0:5000/webhook"],"accept-charset":["big5, big5-hkscs, cesu-8, euc-jp, euc-kr, gb18030, gb2312, gbk, ibm-thai, ibm00858, ibm01140, ibm01141, ibm01142, ibm01143, ibm01144, ibm01145, ibm01146, ibm01147, ibm01148, ibm01149, ibm037, ibm1026, ibm1047, ibm273, ibm277, ibm278, ibm280, ibm284, ibm285, ibm290, ibm297, ibm420, ibm424, ibm437, ibm500, ibm775, ibm850, ibm852, ibm855, ibm857, ibm860, ibm861, ibm862, ibm863, ibm864, ibm865, ibm866, ibm868, ibm869, ibm870, ibm871, ibm918, iso-2022-cn, iso-2022-jp, iso-2022-jp-2, iso-2022-kr, iso-8859-1, iso-8859-13, iso-8859-15, iso-8859-2, iso-8859-3, iso-8859-4, iso-8859-5, iso-8859-6, iso-8859-7, iso-8859-8, iso-8859-9, jis_x0201, jis_x0212-1990, koi8-r, koi8-u, shift_jis, tis-620, us-ascii, utf-16, utf-16be, utf-16le, utf-32, utf-32be, utf-32le, utf-8, windows-1250, windows-1251, windows-1252, windows-1253, windows-1254, windows-1255, windows-1256, windows-1257, windows-1258, windows-31j, x-big5-hkscs-2001, x-big5-solaris, x-compound_text, x-euc-jp-linux, x-euc-tw, x-eucjp-open, x-ibm1006, x-ibm1025, x-ibm1046, x-ibm1097, x-ibm1098, x-ibm1112, x-ibm1122, x-ibm1123, x-ibm1124, x-ibm1166, x-ibm1364, x-ibm1381, x-ibm1383, x-ibm300, x-ibm33722, x-ibm737, x-ibm833, x-ibm834, x-ibm856, x-ibm874, x-ibm875, x-ibm921, x-ibm922, x-ibm930, x-ibm933, x-ibm935, x-ibm937, x-ibm939, x-ibm942, x-ibm942c, x-ibm943, x-ibm943c, x-ibm948, x-ibm949, x-ibm949c, x-ibm950, x-ibm964, x-ibm970, x-iscii91, x-iso-2022-cn-cns, x-iso-2022-cn-gb, x-iso-8859-11, x-jis0208, x-jisautodetect, x-johab, x-macarabic, x-maccentraleurope, x-maccroatian, x-maccyrillic, x-macdingbat, x-macgreek, x-machebrew, x-maciceland, x-macroman, x-macromania, x-macsymbol, x-macthai, x-macturkish, x-macukraine, x-ms932_0213, x-ms950-hkscs, x-ms950-hkscs-xp, x-mswin-936, x-pck, x-sjis_0213, x-utf-16le-bom, x-utf-32be-bom, x-utf-32le-bom, x-windows-50220, x-windows-50221, x-windows-874, x-windows-949, x-windows-950, x-windows-iso2022jp"],"user-agent":["Java/1.8.0_102"],"host":["localhost:8080"],"connection":["keep-alive"],"content-length":["285"]}, Body: {"params":{"name":"vm1","description":"","instanceOfferingUuid":"aee8b43d672e4b019e76471d3767e93a","imageUuid":"e588b839d3013f4fa1490695bc5cd5fb","l3NetworkUuids":["62dc48a48f964e73b463dad1a86089df"],"dataDiskOfferingUuids":[],"systemTags":["usbRedirect::false","vmConsoleMode::vnc"]}} 2018-03-13 22:02:58,571 TRACE [CloudBusImpl2] {} [msg send]: {"org.zstack.header.vm.APICreateVmInstanceMsg":{"name":"vm1","instanceOfferingUuid":"aee8b43d672e4b019e76471d3767e93a","imageUuid":"e588b839d3013f4fa1490695bc5cd5fb","l3NetworkUuids":["62dc48a48f964e73b463dad1a86089df"],"dataDiskOfferingUuids":[],"description":"","strategy":"InstantStart","session":{"uuid":"5bcb2d86e1c64c8ea2568a2d311a90ed"},"timeout":-1,"systemTags":["usbRedirect::false","vmConsoleMode::vnc"],"headers":{"correlationId":"84d99d2d663856dea44c6eb1a80f9599","replyTo":"zstack.message.cloudbus.d40422d825634e3392e51e3ec488e2a3","noReply":"false","schema":{},"task-context":{}},"id":"84d99d2d663856dea44c6eb1a80f9599","serviceId":"api.portal","createdTime":1520949778545}} 2018-03-13 22:02:58,571 TRACE [request] {} [ID: 41F5004148EA6A7A4D0DC1FF7E5120B4] Response to 127.0.0.1 (/zstack/v1/vm-instances), Status Code: 202, Body: {"location":"http://10.0.50.236:8080/zstack/v1/api-jobs/84d99d2d663856dea44c6eb1a80f9599"} 2018-03-13 22:02:58,578 TRACE [CloudBusImpl2] {} [msg received]: {"org.zstack.header.vm.APICreateVmInstanceMsg":{"name":"vm1","instanceOfferingUuid":"aee8b43d672e4b019e76471d3767e93a","imageUuid":"e588b839d3013f4fa1490695bc5cd5fb","l3NetworkUuids":["62dc48a48f964e73b463dad1a86089df"],"dataDiskOfferingUuids":[],"description":"","strategy":"InstantStart","session":{"uuid":"5bcb2d86e1c64c8ea2568a2d311a90ed"},"timeout":-1,"systemTags":["usbRedirect::false","vmConsoleMode::vnc"],"headers":{"correlationId":"84d99d2d663856dea44c6eb1a80f9599","replyTo":"zstack.message.cloudbus.d40422d825634e3392e51e3ec488e2a3","noReply":"false","schema":{},"task-context":{}},"id":"84d99d2d663856dea44c6eb1a80f9599","serviceId":"api.portal","createdTime":1520949778545}} 2018-03-13 22:02:58,587 TRACE [CloudBusImpl2] {api=84d99d2d663856dea44c6eb1a80f9599} [msg send]: {"org.zstack.header.vm.APICreateVmInstanceMsg":{"name":"vm1","instanceOfferingUuid":"aee8b43d672e4b019e76471d3767e93a","imageUuid":"e588b839d3013f4fa1490695bc5cd5fb","l3NetworkUuids":["62dc48a48f964e73b463dad1a86089df"],"type":"UserVm","dataDiskOfferingUuids":[],"description":"","defaultL3NetworkUuid":"62dc48a48f964e73b463dad1a86089df","strategy":"InstantStart","session":{"uuid":"5bcb2d86e1c64c8ea2568a2d311a90ed","accountUuid":"36c27e8ff05c4780bf6d2fa65700f22e","userUuid":"36c27e8ff05c4780bf6d2fa65700f22e","expiredDate":"Mar 14, 2018 12:02:44 AM","createDate":"Mar 13, 2018 10:02:44 PM"},"timeout":1800000,"systemTags":["usbRedirect::false","vmConsoleMode::vnc"],"headers":{"correlationId":"84d99d2d663856dea44c6eb1a80f9599","replyTo":"zstack.message.cloudbus.d40422d825634e3392e51e3ec488e2a3","noReply":"false","schema":{},"task-context":{"task-name":"org.zstack.header.vm.APICreateVmInstanceMsg","api":"84d99d2d663856dea44c6eb1a80f9599"}},"id":"84d99d2d663856dea44c6eb1a80f9599","serviceId":"vmInstance.d40422d825634e3392e51e3ec488e2a3","createdTime":1520949778545}} 2018-03-13 22:02:58,588 TRACE [CloudBusImpl2] {} [msg received]: {"org.zstack.header.vm.APICreateVmInstanceMsg":{"name":"vm1","instanceOfferingUuid":"aee8b43d672e4b019e76471d3767e93a","imageUuid":"e588b839d3013f4fa1490695bc5cd5fb","l3NetworkUuids":["62dc48a48f964e73b463dad1a86089df"],"type":"UserVm","dataDiskOfferingUuids":[],"description":"","defaultL3NetworkUuid":"62dc48a48f964e73b463dad1a86089df","strategy":"InstantStart","session":{"uuid":"5bcb2d86e1c64c8ea2568a2d311a90ed","accountUuid":"36c27e8ff05c4780bf6d2fa65700f22e","userUuid":"36c27e8ff05c4780bf6d2fa65700f22e","expiredDate":"Mar 14, 2018 12:02:44 AM","createDate":"Mar 13, 2018 10:02:44 PM"},"timeout":1800000,"systemTags":["usbRedirect::false","vmConsoleMode::vnc"],"headers":{"correlationId":"84d99d2d663856dea44c6eb1a80f9599","replyTo":"zstack.message.cloudbus.d40422d825634e3392e51e3ec488e2a3","noReply":"false","schema":{},"task-context":{"task-name":"org.zstack.header.vm.APICreateVmInstanceMsg","api":"84d99d2d663856dea44c6eb1a80f9599"}},"id":"84d99d2d663856dea44c6eb1a80f9599","serviceId":"vmInstance.d40422d825634e3392e51e3ec488e2a3","createdTime":1520949778545}} 2018-03-13 22:02:58,609 TRACE [CloudBusImpl2] {api=84d99d2d663856dea44c6eb1a80f9599} [msg send]: {"org.zstack.header.vm.StartNewCreatedVmInstanceMsg":{"vmInstanceInventory":{"uuid":"557c0ee1abeb4cd7929675cf0a239610","name":"vm1","description":"","zoneUuid":"04d920c5dd9342f3bbf7da6a6ece3270","imageUuid":"e588b839d3013f4fa1490695bc5cd5fb","instanceOfferingUuid":"aee8b43d672e4b019e76471d3767e93a","platform":"Linux","defaultL3NetworkUuid":"62dc48a48f964e73b463dad1a86089df","type":"UserVm","memorySize":1073741824,"cpuNum":1,"cpuSpeed":0,"allocatorStrategy":"LeastVmPreferredHostAllocatorStrategy","createDate":"Mar 13, 2018 10:02:58 PM","lastOpDate":"Mar 13, 2018 10:02:58 PM","state":"Created","internalId":9,"vmNics":[],"allVolumes":[]},"l3NetworkUuids":["62dc48a48f964e73b463dad1a86089df"],"dataDiskOfferingUuids":[],"timeout":10800000,"headers":{"correlationId":"87d14852288b422cb927ea608d9407b4","replyTo":"zstack.message.cloudbus.d40422d825634e3392e51e3ec488e2a3","noReply":"false","schema":{"vmInstanceInventory":"org.zstack.header.vm.VmInstanceInventory"},"task-context":{"task-name":"org.zstack.header.vm.APICreateVmInstanceMsg","api":"84d99d2d663856dea44c6eb1a80f9599"}},"id":"87d14852288b422cb927ea608d9407b4","serviceId":"vmInstance.d40422d825634e3392e51e3ec488e2a3","createdTime":1520949778609}} 2018-03-13 22:02:58,611 TRACE [CloudBusImpl2] {} [msg received]: {"org.zstack.header.vm.StartNewCreatedVmInstanceMsg":{"vmInstanceInventory":{"uuid":"557c0ee1abeb4cd7929675cf0a239610","name":"vm1","description":"","zoneUuid":"04d920c5dd9342f3bbf7da6a6ece3270","imageUuid":"e588b839d3013f4fa1490695bc5cd5fb","instanceOfferingUuid":"aee8b43d672e4b019e76471d3767e93a","platform":"Linux","defaultL3NetworkUuid":"62dc48a48f964e73b463dad1a86089df","type":"UserVm","memorySize":1073741824,"cpuNum":1,"cpuSpeed":0,"allocatorStrategy":"LeastVmPreferredHostAllocatorStrategy","createDate":"Mar 13, 2018 10:02:58 PM","lastOpDate":"Mar 13, 2018 10:02:58 PM","state":"Created","internalId":9,"vmNics":[],"allVolumes":[]},"l3NetworkUuids":["62dc48a48f964e73b463dad1a86089df"],"dataDiskOfferingUuids":[],"timeout":10800000,"headers":{"correlationId":"87d14852288b422cb927ea608d9407b4","replyTo":"zstack.message.cloudbus.d40422d825634e3392e51e3ec488e2a3","noReply":"false","schema":{"vmInstanceInventory":"org.zstack.header.vm.VmInstanceInventory"},"task-context":{"task-name":"org.zstack.header.vm.APICreateVmInstanceMsg","api":"84d99d2d663856dea44c6eb1a80f9599"}},"id":"87d14852288b422cb927ea608d9407b4","serviceId":"vmInstance.d40422d825634e3392e51e3ec488e2a3","createdTime":1520949778609}} 2018-03-13 22:02:58,630 DEBUG [VmInstanceBase] {api=84d99d2d663856dea44c6eb1a80f9599} vm[uuid:557c0ee1abeb4cd7929675cf0a239610] changed state from Created to Starting in db 2018-03-13 22:02:58,631 TRACE [CloudBusImpl2] {api=84d99d2d663856dea44c6eb1a80f9599} [event publish]: {"org.zstack.core.cloudbus.CanonicalEvent":{"path":"/vm/state/change","content":{"vmUuid":"557c0ee1abeb4cd7929675cf0a239610","oldState":"Created","newState":"Starting","inventory":{"uuid":"557c0ee1abeb4cd7929675cf0a239610","name":"vm1","description":"","zoneUuid":"04d920c5dd9342f3bbf7da6a6ece3270","imageUuid":"e588b839d3013f4fa1490695bc5cd5fb","instanceOfferingUuid":"aee8b43d672e4b019e76471d3767e93a","platform":"Linux","defaultL3NetworkUuid":"62dc48a48f964e73b463dad1a86089df","type":"UserVm","memorySize":1073741824,"cpuNum":1,"cpuSpeed":0,"allocatorStrategy":"LeastVmPreferredHostAllocatorStrategy","createDate":"Mar 13, 2018 10:02:58 PM","state":"Starting","internalId":9,"vmNics":[],"allVolumes":[]},"date":"Mar 13, 2018 10:02:58 PM"},"managementNodeId":"d40422d825634e3392e51e3ec488e2a3","headers":{"schema":{"content":"org.zstack.header.vm.VmCanonicalEvents$VmStateChangedData","content.inventory":"org.zstack.header.vm.VmInstanceInventory"},"task-context":{"task-name":"org.zstack.header.vm.APICreateVmInstanceMsg","api":"84d99d2d663856dea44c6eb1a80f9599"}},"id":"2f47da70661040f18091964eb7a48d5b","createdTime":1520949778630}} 2018-03-13 22:02:58,632 DEBUG [SchedulerFacadeImpl] {api=84d99d2d663856dea44c6eb1a80f9599} vm [uuid:557c0ee1abeb4cd7929675cf0a239610] not set any scheduler 2018-03-13 22:02:58,633 DEBUG [SimpleFlowChain] {api=84d99d2d663856dea44c6eb1a80f9599} [FlowChain(FCID_ac2d695b): create-vm-557c0ee1abeb4cd7929675cf0a239610] starts 2018-03-13 22:02:58,633 TRACE [CloudBusImpl2] {} [event received]: {"org.zstack.core.cloudbus.CanonicalEvent":{"path":"/vm/state/change","content":{"vmUuid":"557c0ee1abeb4cd7929675cf0a239610","oldState":"Created","newState":"Starting","inventory":{"uuid":"557c0ee1abeb4cd7929675cf0a239610","name":"vm1","description":"","zoneUuid":"04d920c5dd9342f3bbf7da6a6ece3270","imageUuid":"e588b839d3013f4fa1490695bc5cd5fb","instanceOfferingUuid":"aee8b43d672e4b019e76471d3767e93a","platform":"Linux","defaultL3NetworkUuid":"62dc48a48f964e73b463dad1a86089df","type":"UserVm","memorySize":1073741824,"cpuNum":1,"cpuSpeed":0,"allocatorStrategy":"LeastVmPreferredHostAllocatorStrategy","createDate":"Mar 13, 2018 10:02:58 PM","state":"Starting","internalId":9,"vmNics":[],"allVolumes":[]},"date":"Mar 13, 2018 10:02:58 PM"},"managementNodeId":"d40422d825634e3392e51e3ec488e2a3","type":{"_name":"key.event.LOCAL.canonicalEvent"},"headers":{"schema":{"content":"org.zstack.header.vm.VmCanonicalEvents$VmStateChangedData","content.inventory":"org.zstack.header.vm.VmInstanceInventory"},"task-context":{"task-name":"org.zstack.header.vm.APICreateVmInstanceMsg","api":"84d99d2d663856dea44c6eb1a80f9599"}},"id":"2f47da70661040f18091964eb7a48d5b","createdTime":1520949778630}} 2018-03-13 22:02:58,633 TRACE [SimpleFlowChain] {api=84d99d2d663856dea44c6eb1a80f9599} execution path: 2018-03-13 22:02:58,633 DEBUG [SimpleFlowChain] {api=84d99d2d663856dea44c6eb1a80f9599} [FlowChain(FCID_ac2d695b): create-vm-557c0ee1abeb4cd7929675cf0a239610] start executing flow[VmImageSelectBackupStorageFlow.java:VmImageSelectBackupStorageFlow] 2018-03-13 22:02:58,636 DEBUG [SimpleFlowChain] {api=84d99d2d663856dea44c6eb1a80f9599} [FlowChain(FCID_ac2d695b): create-vm-557c0ee1abeb4cd7929675cf0a239610] successfully executed flow[VmImageSelectBackupStorageFlow.java:VmImageSelectBackupStorageFlow] 2018-03-13 22:02:58,636 DEBUG [SimpleFlowChain] {api=84d99d2d663856dea44c6eb1a80f9599} [FlowChain(FCID_ac2d695b): create-vm-557c0ee1abeb4cd7929675cf0a239610] start executing flow[VmAllocateHostFlow.java:VmAllocateHostFlow] 2018-03-13 22:02:58,639 TRACE [CloudBusImpl2] {api=84d99d2d663856dea44c6eb1a80f9599} [msg send]: {"org.zstack.header.allocator.DesignatedAllocateHostMsg":{"zoneUuid":"04d920c5dd9342f3bbf7da6a6ece3270","cpuCapacity":1,"memoryCapacity":1073741824,"diskSize":12682240,"allocatorStrategy":"LeastVmPreferredHostAllocatorStrategy","avoidHostUuids":[],"l3NetworkUuids":["62dc48a48f964e73b463dad1a86089df"],"vmInstance":{"uuid":"557c0ee1abeb4cd7929675cf0a239610","name":"vm1","description":"","zoneUuid":"04d920c5dd9342f3bbf7da6a6ece3270","imageUuid":"e588b839d3013f4fa1490695bc5cd5fb","instanceOfferingUuid":"aee8b43d672e4b019e76471d3767e93a","platform":"Linux","defaultL3NetworkUuid":"62dc48a48f964e73b463dad1a86089df","type":"UserVm","memorySize":1073741824,"cpuNum":1,"cpuSpeed":0,"allocatorStrategy":"LeastVmPreferredHostAllocatorStrategy","createDate":"Mar 13, 2018 10:02:58 PM","lastOpDate":"Mar 13, 2018 10:02:58 PM","state":"Created","internalId":9,"vmNics":[],"allVolumes":[]},"image":{"uuid":"e588b839d3013f4fa1490695bc5cd5fb","name":"Image-1","description":"","state":"Enabled","status":"Ready","size":12682240,"actualSize":7995392,"md5Sum":"f0fde821df71aaec63063bef1fb0a46a231e5a3fbb37ed5671eabee7563eb3f8","url":"file:///opt/zstack-dvd/zstack-image-1.4.qcow2","mediaType":"RootVolumeTemplate","type":"zstack","platform":"Linux","format":"qcow2","system":false,"createDate":"Mar 9, 2018 8:09:53 PM","lastOpDate":"Mar 9, 2018 8:09:53 PM","backupStorageRefs":[{"id":13,"imageUuid":"e588b839d3013f4fa1490695bc5cd5fb","backupStorageUuid":"c18ea1ae1df742449b8a1d5a3527e96e","installPath":"zstore://e588b839d3013f4fa1490695bc5cd5fb/07c5391ad7028e098762f9e3f4005e739576df33","status":"Ready","createDate":"Mar 9, 2018 8:09:53 PM","lastOpDate":"Mar 9, 2018 8:09:53 PM"}]},"vmOperation":"NewCreate","isDryRun":false,"diskOfferings":[],"allowNoL3Networks":false,"listAllHosts":false,"requiredBackupStorageUuid":"c18ea1ae1df742449b8a1d5a3527e96e","timeout":3600000,"headers":{"correlationId":"7150a9f7925c4ac9b11d818cc233cf98","replyTo":"zstack.message.cloudbus.d40422d825634e3392e51e3ec488e2a3","noReply":"false","schema":{"image":"org.zstack.header.image.ImageInventory","image.backupStorageRefs[0]":"org.zstack.header.image.ImageBackupStorageRefInventory","vmInstance":"org.zstack.header.vm.VmInstanceInventory"},"task-context":{"api":"84d99d2d663856dea44c6eb1a80f9599","task-name":"org.zstack.header.vm.APICreateVmInstanceMsg","progress-enabled":"true"}},"id":"7150a9f7925c4ac9b11d818cc233cf98","serviceId":"host.allocator.d40422d825634e3392e51e3ec488e2a3","createdTime":1520949778638}} 2018-03-13 22:02:58,642 TRACE [CloudBusImpl2] {} [msg received]: {"org.zstack.header.allocator.DesignatedAllocateHostMsg":{"zoneUuid":"04d920c5dd9342f3bbf7da6a6ece3270","cpuCapacity":1,"memoryCapacity":1073741824,"diskSize":12682240,"allocatorStrategy":"LeastVmPreferredHostAllocatorStrategy","avoidHostUuids":[],"l3NetworkUuids":["62dc48a48f964e73b463dad1a86089df"],"vmInstance":{"uuid":"557c0ee1abeb4cd7929675cf0a239610","name":"vm1","description":"","zoneUuid":"04d920c5dd9342f3bbf7da6a6ece3270","imageUuid":"e588b839d3013f4fa1490695bc5cd5fb","instanceOfferingUuid":"aee8b43d672e4b019e76471d3767e93a","platform":"Linux","defaultL3NetworkUuid":"62dc48a48f964e73b463dad1a86089df","type":"UserVm","memorySize":1073741824,"cpuNum":1,"cpuSpeed":0,"allocatorStrategy":"LeastVmPreferredHostAllocatorStrategy","createDate":"Mar 13, 2018 10:02:58 PM","lastOpDate":"Mar 13, 2018 10:02:58 PM","state":"Created","internalId":9,"vmNics":[],"allVolumes":[]},"image":{"uuid":"e588b839d3013f4fa1490695bc5cd5fb","name":"Image-1","description":"","state":"Enabled","status":"Ready","size":12682240,"actualSize":7995392,"md5Sum":"f0fde821df71aaec63063bef1fb0a46a231e5a3fbb37ed5671eabee7563eb3f8","url":"file:///opt/zstack-dvd/zstack-image-1.4.qcow2","mediaType":"RootVolumeTemplate","type":"zstack","platform":"Linux","format":"qcow2","system":false,"createDate":"Mar 9, 2018 8:09:53 PM","lastOpDate":"Mar 9, 2018 8:09:53 PM","backupStorageRefs":[{"id":13,"imageUuid":"e588b839d3013f4fa1490695bc5cd5fb","backupStorageUuid":"c18ea1ae1df742449b8a1d5a3527e96e","installPath":"zstore://e588b839d3013f4fa1490695bc5cd5fb/07c5391ad7028e098762f9e3f4005e739576df33","status":"Ready","createDate":"Mar 9, 2018 8:09:53 PM","lastOpDate":"Mar 9, 2018 8:09:53 PM"}]},"vmOperation":"NewCreate","isDryRun":false,"diskOfferings":[],"allowNoL3Networks":false,"listAllHosts":false,"requiredBackupStorageUuid":"c18ea1ae1df742449b8a1d5a3527e96e","timeout":3600000,"headers":{"correlationId":"7150a9f7925c4ac9b11d818cc233cf98","replyTo":"zstack.message.cloudbus.d40422d825634e3392e51e3ec488e2a3","noReply":"false","schema" 篇幅問(wèn)題,這里不再多貼相關(guān)的日志
這樣,我們就可以得知一個(gè)API到底在MN中做了什么事了。在/var/log/zstack還有agent相關(guān)的日志,有興趣的讀者可以自行搜索。
使用Test Case來(lái)定位問(wèn)題在讀本節(jié)前,希望讀者能夠讀過(guò)以下文章:
[小談自動(dòng)化測(cè)試:從ZStack Integration Test談起]()
[ZStack的IntergrationTest]()
我們先將GitHub上的ZStack Clone到自己的機(jī)器上來(lái),如圖:
并執(zhí)行mvn compile,這里理應(yīng)編譯成功:
好,我們切換到test目錄下:
[root@10-0-86-20 zstack-openresource]# cd test [root@10-0-86-20 test]# ls pom.xml src target zstack-integration-test-result [root@10-0-86-20 test]#
使用mvn test -Dtest=YOUR_TEST_CASE_NAME來(lái)跑相應(yīng)的case,如mvn test -Dtest=VmGCCase。
如果沒(méi)什么問(wèn)題,一般是成功的:
小Tips:如果你僅僅修改了groovy的case,那是不需要編譯的。但如果你修改了一行Java代碼,并想使其生效,請(qǐng)記得編譯。掛斷點(diǎn)
在掛斷點(diǎn)之前,請(qǐng)確定自己的iptables開(kāi)放了相應(yīng)的端口。
真實(shí)環(huán)境為了方便起見(jiàn),我們先在家目錄的bashrc中添加如下命令:
alias opendebug="zstack-ctl setenv CATALINA_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005 -Xnoagent -Djava.compiler=NONE"" alias closedebug="zstack-ctl unsetenv CATALINA_OPTS" alias mvndebug="mvn -Dmaven.surefire.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -Xnoagent -Djava.compiler=NONE""
然后關(guān)閉管理節(jié)點(diǎn),opendebug,再開(kāi)啟管理節(jié)點(diǎn)。這時(shí)可以使用IDE配置remote debug連上去,接下來(lái)就可以debug了。debug之后記得使用closedebug關(guān)掉。
Test Case在測(cè)試目錄下,參考以下命令:
mvn -Dmaven.surefire.debug -Dtest=YOUR_TEST_CASE test
這樣,它會(huì)等待你的斷點(diǎn)掛上去后再跑里面的測(cè)試。
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請(qǐng)注明本文地址:http://systransis.cn/yun/76712.html
摘要:但在實(shí)際的二次開(kāi)發(fā)中,這些做法未必能夠完全滿足需求。在源碼剖析之核心庫(kù)鑒賞一文中,我們了解到是的基礎(chǔ)設(shè)施之一,同時(shí)也允許通過(guò)顯示聲明的方式來(lái)聲明。同理,一些也可以使用繼承進(jìn)行擴(kuò)展。 本文首發(fā)于泊浮目的專欄:https://segmentfault.com/blog... 前言 在ZStack博文-5.通用插件系統(tǒng)中,官方提出了幾個(gè)較為經(jīng)典的擴(kuò)展方式。但在實(shí)際的二次開(kāi)發(fā)中,這些做法未必...
摘要:本文首發(fā)于泊浮目的專欄背景在上篇文章中源碼剖析之二次開(kāi)發(fā)可擴(kuò)展框架,我們簡(jiǎn)單的了解了一下核心引擎的二次開(kāi)發(fā)技巧。而在沒(méi)有足夠人力來(lái)維護(hù)開(kāi)發(fā)時(shí),我們會(huì)將目標(biāo)定為能夠及時(shí)跟上發(fā)布版本。 本文首發(fā)于泊浮目的專欄:https://segmentfault.com/blog... 背景 在上篇文章中(ZStack源碼剖析之二次開(kāi)發(fā)——可擴(kuò)展框架),我們簡(jiǎn)單的了解了一下ZStack核心引擎的二次...
摘要:但新增模塊的結(jié)構(gòu)卻還是大致相同,此即是的經(jīng)典設(shè)計(jì)模式這套模式也被開(kāi)發(fā)者稱為三駕馬車。領(lǐng)域?qū)佣x負(fù)責(zé)表達(dá)業(yè)務(wù)概念,業(yè)務(wù)狀態(tài)信息以及業(yè)務(wù)規(guī)則。 本文首發(fā)于泊浮目的專欄:https://segmentfault.com/blog... 前言 隨著ZStack的版本迭代,其可以掌管的資源也越來(lái)越多。但新增模塊的結(jié)構(gòu)卻還是大致相同,此即是ZStack的經(jīng)典設(shè)計(jì)模式——這套模式也被開(kāi)發(fā)者稱為ZS...
摘要:每個(gè)消息都會(huì)被一個(gè)線程消費(fèi),同時(shí)最大并發(fā)量為。然后提交一個(gè)任務(wù)到線程池中,這個(gè)任務(wù)的內(nèi)容是從等待隊(duì)列中取出一個(gè),如果等待隊(duì)列為空,則刪除這個(gè)等待隊(duì)列的。小結(jié)本文分析了的久經(jīng)生產(chǎn)考驗(yàn)的核心組件線程池。 本文首發(fā)于泊浮目的專欄:https://segmentfault.com/blog... 前言 在ZStack中,最基本的執(zhí)行單位不僅僅是一個(gè)函數(shù),也可以是一個(gè)任務(wù)(Task。其本質(zhì)實(shí)現(xiàn)...
摘要:因?yàn)檫@個(gè)狀態(tài)下,是交給一個(gè)線程在執(zhí)行的,見(jiàn)源碼剖析之核心庫(kù)鑒賞中的分析。并且允許等行為。上面提到過(guò),允許運(yùn)行暫停取消等行為。維護(hù)和相應(yīng)的之間的關(guān)系。則停止執(zhí)行并觸發(fā)之前的所有。 本文首發(fā)于泊浮目的專欄:https://segmentfault.com/blog... 前言 在ZStack中,當(dāng)用戶在UI上發(fā)起操作時(shí),前端會(huì)調(diào)用后端的API對(duì)實(shí)際的資源發(fā)起操作請(qǐng)求。但在一個(gè)分布式系統(tǒng)中...
閱讀 2040·2021-11-19 11:37
閱讀 729·2021-11-11 16:54
閱讀 1180·2021-11-02 14:44
閱讀 3078·2021-09-02 15:40
閱讀 2383·2019-08-30 15:44
閱讀 970·2019-08-29 11:17
閱讀 1073·2019-08-26 14:06
閱讀 1567·2019-08-26 13:47