From f1ad46546b2e232790b160727f00d0b69801c58d Mon Sep 17 00:00:00 2001 From: Meng Ding Date: Tue, 19 Feb 2019 09:49:25 -0500 Subject: [PATCH 1/4] Fix logging errors --- .../remote_mediation_client.go | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pkg/mediationcontainer/remote_mediation_client.go b/pkg/mediationcontainer/remote_mediation_client.go index c95feb4..6adc9d9 100644 --- a/pkg/mediationcontainer/remote_mediation_client.go +++ b/pkg/mediationcontainer/remote_mediation_client.go @@ -39,7 +39,7 @@ func CreateRemoteMediationClient(allProbes map[string]*ProbeProperties, stopMediationClientCh: make(chan struct{}), } - glog.V(4).Infof("Created channels : probeResponseChan %s, stopMediationClientCh %s\n", + glog.V(4).Infof("Created channels : probeResponseChan %+v, stopMediationClientCh %+v", remoteMediationClient.probeResponseChan, remoteMediationClient.stopMediationClientCh) // Create message handlers @@ -94,7 +94,7 @@ func (remoteMediationClient *remoteMediationClient) Init(probeRegisteredMsgCh ch status := <-sdkProtocolDoneCh - glog.V(4).Infof("Sdk client protocol complete, status = ", status) + glog.V(4).Infof("Sdk client protocol completed with status %v", status) if !status { glog.Errorf("Registration with server failed") probeRegisteredMsgCh <- status @@ -119,7 +119,7 @@ func (remoteMediationClient *remoteMediationClient) Init(probeRegisteredMsgCh ch err := transport.Connect() // handle WebSocket creation errors if err != nil { //transport.ws == nil { - glog.Errorf("[Reconnect] Initialization of remote mediation client failed, null transport") + glog.Errorf("[Reconnect] Initialization of remote mediation client failed: %v", err) remoteMediationClient.Stop() break } @@ -147,7 +147,7 @@ func (remoteMediationClient *remoteMediationClient) Init(probeRegisteredMsgCh ch // Send registration status to the upper layer defer close(sdkProtocolDoneCh) probeRegisteredMsgCh <- status - glog.V(3).Infof("Sent registration status on channel %s\n", probeRegisteredMsgCh) + glog.V(3).Infof("Sent registration status on channel %v", probeRegisteredMsgCh) glog.V(3).Infof("Remote mediation initialization complete") // --------- Wait for exit notification @@ -327,7 +327,7 @@ func (discReqHandler *DiscoveryRequestHandler) HandleMessage(serverRequest proto t := time.NewTimer(time.Second * 10) select { case <-stopCh: - glog.V(4).Infof("Cancel keep alive for msgID ", msgID) + glog.V(4).Infof("Cancel keep alive for msgID %d", msgID) return case <-t.C: } @@ -382,10 +382,10 @@ func (valReqHandler *ValidationRequestHandler) HandleMessage(serverRequest proto probeType := request.ProbeType probeProps, exist := valReqHandler.probes[*probeType] if !exist { - glog.Errorf("Received: validation request for unknown probe type : %s", *probeType) + glog.Errorf("Received: validation request for unknown probe type: %s", *probeType) return } - glog.V(3).Infof("Received: validation for probe type: %s\n ", *probeType) + glog.V(3).Infof("Received: validation for probe type: %s", *probeType) turboProbe := probeProps.Probe var validationResponse *proto.ValidationResponse @@ -409,15 +409,15 @@ type ActionMessageHandler struct { func (actionReqHandler *ActionMessageHandler) HandleMessage(serverRequest proto.MediationServerMessage, probeMsgChan chan *proto.MediationClientMessage) { - glog.V(4).Infof("[ActionMessageHandler] Received: action %s request", serverRequest) + glog.V(4).Infof("[ActionMessageHandler] Received: action request %s", &serverRequest) request := serverRequest.GetActionRequest() probeType := request.ProbeType if actionReqHandler.probes[*probeType] == nil { - glog.Errorf("Received: Action request for unknown probe type : %s", *probeType) + glog.Errorf("Received: action request for unknown probe type : %s", *probeType) return } - glog.V(3).Infof("Received: action %s request for probe type: %s\n ", + glog.V(3).Infof("Received: action request %s for probe type: %s", request.ActionExecutionDTO.ActionType, *probeType) probeProps := actionReqHandler.probes[*probeType] turboProbe := probeProps.Probe @@ -449,7 +449,7 @@ func NewActionResponseWorker(msgId int32, turboProbe *probe.TurboProbe, accountValues: accountValues, probeMsgChan: probeMsgChan, } - glog.V(4).Infof("New ActionResponseProtocolWorker for %s %s %s", msgId, turboProbe, + glog.V(4).Infof("New ActionResponseProtocolWorker for %d %+v %s", msgId, turboProbe, actionExecutionDto.ActionType) return worker } @@ -494,5 +494,5 @@ func (intMsgHandler *InterruptMessageHandler) HandleMessage(serverRequest proto. probeMsgChan chan *proto.MediationClientMessage) { msgID := serverRequest.GetMessageID() - glog.V(3).Infof("Received: Interrupt Message for message ID: %d, %s\n ", msgID, serverRequest) + glog.V(3).Infof("Received: Interrupt Message for message ID: %d, %s", msgID, &serverRequest) } From acd9ed7068fed03509559171f76b90d1d3b25b1e Mon Sep 17 00:00:00 2001 From: Meng Ding Date: Tue, 19 Feb 2019 12:06:55 -0500 Subject: [PATCH 2/4] Fix fmt check --- pkg/builder/entity_dto_builder_test.go | 8 +- pkg/proto/CommonDTO.pb.go | 88 ++++++++++---------- pkg/supplychain/supply_chain_builder_test.go | 2 +- 3 files changed, 49 insertions(+), 49 deletions(-) diff --git a/pkg/builder/entity_dto_builder_test.go b/pkg/builder/entity_dto_builder_test.go index 022e4cd..59cbc21 100644 --- a/pkg/builder/entity_dto_builder_test.go +++ b/pkg/builder/entity_dto_builder_test.go @@ -69,10 +69,10 @@ func TestCreate(t *testing.T) { } for _, item := range table { builder := &EntityDTOBuilder{ - entityType: &item.eType, - id: &item.id, - powerState: &item.powerState, - origin: &item.origin, + entityType: &item.eType, + id: &item.id, + powerState: &item.powerState, + origin: &item.origin, commoditiesBoughtProviderMap: item.commoditiesBoughtProviderMap, commoditiesSold: item.commoditiesSold, err: item.err, diff --git a/pkg/proto/CommonDTO.pb.go b/pkg/proto/CommonDTO.pb.go index a206246..4616ab8 100644 --- a/pkg/proto/CommonDTO.pb.go +++ b/pkg/proto/CommonDTO.pb.go @@ -192,45 +192,45 @@ var EntityDTO_EntityType_name = map[int32]string{ 2047: "UNKNOWN", } var EntityDTO_EntityType_value = map[string]int32{ - "SWITCH": 0, - "VIRTUAL_DATACENTER": 1, - "STORAGE": 2, - "SERVICE": 3, - "DATABASE_SERVER": 4, - "SAVINGS": 5, - "OPERATOR": 6, - "WEB_SERVER": 7, - "RIGHT_SIZER": 8, - "THREE_TIER_APPLICATION": 9, - "VIRTUAL_MACHINE": 10, - "DISK_ARRAY": 11, - "DATACENTER": 12, - "INFRASTRUCTURE": 13, - "PHYSICAL_MACHINE": 14, - "CHASSIS": 15, - "LICENSING_SERVICE": 16, - "BUSINESS_USER": 17, - "STORAGE_CONTROLLER": 18, - "HYPERVISOR": 19, - "BUSINESS_ENTITY": 20, - "IO_MODULE": 21, - "ACTION_MANAGER": 22, - "VLAN": 23, - "APPLICATION_SERVER": 24, - "BUSINESS": 25, - "VIRTUAL_APPLICATION": 26, - "NETWORKING_ENDPOINT": 27, - "BUSINESS_ACCOUNT": 28, - "IP": 29, - "SERVICE_ENTITY_TEMPLATE": 30, - "PORT": 31, - "NETWORK": 32, - "APPLICATION": 33, - "THIS_ENTITY": 34, - "COMPUTE_RESOURCE": 35, - "MAC": 36, - "INTERNET": 37, - "MOVER": 38, + "SWITCH": 0, + "VIRTUAL_DATACENTER": 1, + "STORAGE": 2, + "SERVICE": 3, + "DATABASE_SERVER": 4, + "SAVINGS": 5, + "OPERATOR": 6, + "WEB_SERVER": 7, + "RIGHT_SIZER": 8, + "THREE_TIER_APPLICATION": 9, + "VIRTUAL_MACHINE": 10, + "DISK_ARRAY": 11, + "DATACENTER": 12, + "INFRASTRUCTURE": 13, + "PHYSICAL_MACHINE": 14, + "CHASSIS": 15, + "LICENSING_SERVICE": 16, + "BUSINESS_USER": 17, + "STORAGE_CONTROLLER": 18, + "HYPERVISOR": 19, + "BUSINESS_ENTITY": 20, + "IO_MODULE": 21, + "ACTION_MANAGER": 22, + "VLAN": 23, + "APPLICATION_SERVER": 24, + "BUSINESS": 25, + "VIRTUAL_APPLICATION": 26, + "NETWORKING_ENDPOINT": 27, + "BUSINESS_ACCOUNT": 28, + "IP": 29, + "SERVICE_ENTITY_TEMPLATE": 30, + "PORT": 31, + "NETWORK": 32, + "APPLICATION": 33, + "THIS_ENTITY": 34, + "COMPUTE_RESOURCE": 35, + "MAC": 36, + "INTERNET": 37, + "MOVER": 38, "DISTRIBUTED_VIRTUAL_PORTGROUP": 39, "CONTAINER": 40, "CONTAINER_POD": 41, @@ -354,11 +354,11 @@ var EntityDTO_StorageType_value = map[string]int32{ "FCOE": 4, "OBJECT": 5, "GENERIC_FILE_SYSTEM": 6, - "NFS": 7, - "CIFS_SMB": 8, - "LOCAL": 9, - "OTHER": 10, - "VMFS": 11, + "NFS": 7, + "CIFS_SMB": 8, + "LOCAL": 9, + "OTHER": 10, + "VMFS": 11, } func (x EntityDTO_StorageType) Enum() *EntityDTO_StorageType { diff --git a/pkg/supplychain/supply_chain_builder_test.go b/pkg/supplychain/supply_chain_builder_test.go index 7ba3055..41a297f 100644 --- a/pkg/supplychain/supply_chain_builder_test.go +++ b/pkg/supplychain/supply_chain_builder_test.go @@ -111,7 +111,7 @@ func TestSupplyChainBuilder_Entity(t *testing.T) { { newNodes: []*proto.TemplateDTO{randomSupplyChainNode()}, existingSupplyChainNodes: []*proto.TemplateDTO{}, - newErr: fmt.Errorf("Must set top supply chain node first."), + newErr: fmt.Errorf("Must set top supply chain node first."), }, { newNodes: []*proto.TemplateDTO{ From 8fc71c8f711df0298f53c1c4a696dc9fd9bf4698 Mon Sep 17 00:00:00 2001 From: Meng Ding Date: Tue, 19 Feb 2019 13:30:20 -0500 Subject: [PATCH 3/4] Fix build errors --- pkg/mediationcontainer/client_websocket_transport.go | 2 +- pkg/mediationcontainer/sdk_client_protocol.go | 5 +++-- pkg/probe/probe_registration.go | 2 +- pkg/probe/turbo_probe.go | 3 ++- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/mediationcontainer/client_websocket_transport.go b/pkg/mediationcontainer/client_websocket_transport.go index 23fb162..dcde27c 100644 --- a/pkg/mediationcontainer/client_websocket_transport.go +++ b/pkg/mediationcontainer/client_websocket_transport.go @@ -294,7 +294,7 @@ func (clientTransport *ClientWebSocketTransport) performWebSocketConnection() er return nil } } - glog.V(4).Infof("[performWebSocketConnection] exit connect routine, close = %s ", clientTransport.closeRequested) + glog.V(4).Infof("[performWebSocketConnection] exit connect routine, close = %v ", clientTransport.closeRequested) return errors.New("Abort client socket connect, transport is closed") } diff --git a/pkg/mediationcontainer/sdk_client_protocol.go b/pkg/mediationcontainer/sdk_client_protocol.go index 0d2d307..63f9195 100644 --- a/pkg/mediationcontainer/sdk_client_protocol.go +++ b/pkg/mediationcontainer/sdk_client_protocol.go @@ -5,8 +5,9 @@ import ( "github.com/turbonomic/turbo-go-sdk/pkg/version" "fmt" - "github.com/golang/glog" "time" + + "github.com/golang/glog" ) const ( @@ -158,7 +159,7 @@ func (clientProtocol *SdkClientProtocol) MakeContainerInfo() (*proto.ContainerIn var probes []*proto.ProbeInfo for k, v := range clientProtocol.allProbes { - glog.V(2).Infof("SdkClientProtocol] Creating Probe Info for", k) + glog.V(2).Infof("SdkClientProtocol] Creating Probe Info for %s", k) turboProbe := v.Probe var probeInfo *proto.ProbeInfo var err error diff --git a/pkg/probe/probe_registration.go b/pkg/probe/probe_registration.go index 4722295..b5300ca 100644 --- a/pkg/probe/probe_registration.go +++ b/pkg/probe/probe_registration.go @@ -124,7 +124,7 @@ func checkSecondaryDiscoveryInterval(secondaryDiscoverySec int32, discoveryType if secondaryDiscoverySec < pkg.DEFAULT_MIN_DISCOVERY_IN_SECS { glog.Warningf("%s discovery interval value of %d is below minimum value allowed."+ - " Setting %s discovery interval to minimum allowed value of %d seconds.", + " Setting discovery interval to minimum allowed value of %d seconds.", discoveryType, secondaryDiscoverySec, pkg.DEFAULT_MIN_DISCOVERY_IN_SECS) return pkg.DEFAULT_MIN_DISCOVERY_IN_SECS } diff --git a/pkg/probe/turbo_probe.go b/pkg/probe/turbo_probe.go index c0a00b4..a25ad91 100644 --- a/pkg/probe/turbo_probe.go +++ b/pkg/probe/turbo_probe.go @@ -2,6 +2,7 @@ package probe import ( "fmt" + "github.com/turbonomic/turbo-go-sdk/pkg/builder" "github.com/turbonomic/turbo-go-sdk/pkg/proto" @@ -73,7 +74,7 @@ func newTurboProbe(probeConf *ProbeConfig) (*TurboProbe, error) { RegistrationClient: NewProbeRegistrator(), } - glog.V(2).Infof("[NewTurboProbe] Created TurboProbe: %s", myProbe) + glog.V(2).Infof("[NewTurboProbe] Created TurboProbe: %v", myProbe) return myProbe, nil } From 0051f1dd0350b7202711b04ab90ee323c8a48bc6 Mon Sep 17 00:00:00 2001 From: Meng Ding Date: Tue, 19 Feb 2019 17:06:37 -0500 Subject: [PATCH 4/4] Change go version to 1.11 in travis configuration --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c477ce9..7da24ef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: go go: - - 1.9 + - 1.11 - tip go_import_path: github.com/turbonomic/turbo-go-sdk