Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Commit

Permalink
Added overlapping and missing metrics
Browse files Browse the repository at this point in the history
Signed-off-by: jaellio <[email protected]>
  • Loading branch information
jaellio committed Aug 10, 2021
1 parent 1379930 commit a9b24c1
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 16 deletions.
4 changes: 2 additions & 2 deletions cmd/osm-controller/log_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func StartGlobalLogLevelHandler(cfg configurator.Configurator, stop <-chan struc
log.Info().Msgf("Setting initial log level from meshconfig: %s", logLevel)
err := logger.SetLogLevel(logLevel)
if err != nil {
log.Error().Err(err).Str(errcode.Kind, errcode.ErrSettingLogLevel.String()).
log.Error().Err(err).Str(errcode.Kind, errcode.GetErrCodeWithMetric(errcode.ErrSettingLogLevel)).
Msg("Error setting initial log level from meshconfig")
} else {
currentLogLevel = logLevel
Expand All @@ -40,7 +40,7 @@ func StartGlobalLogLevelHandler(cfg configurator.Configurator, stop <-chan struc
if logLevel != currentLogLevel {
err := logger.SetLogLevel(logLevel)
if err != nil {
log.Error().Err(err).Str(errcode.Kind, errcode.ErrSettingLogLevel.String()).
log.Error().Err(err).Str(errcode.Kind, errcode.GetErrCodeWithMetric(errcode.ErrSettingLogLevel)).
Msg("Error setting log level from meshconfig")
} else {
log.Info().Msgf("Global log level changed to: %s", logLevel)
Expand Down
3 changes: 2 additions & 1 deletion cmd/osm-controller/osm-controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,8 @@ func getOSMControllerPod(kubeClient kubernetes.Interface) (*corev1.Pod, error) {

pod, err := kubeClient.CoreV1().Pods(osmNamespace).Get(context.TODO(), podName, metav1.GetOptions{})
if err != nil {
log.Error().Err(err).Str(errcode.Kind, errcode.ErrFetchingControllerPod.String()).
// TODO: Need to push metric
log.Error().Err(err).Str(errcode.Kind, errcode.GetErrCodeWithMetric(errcode.ErrFetchingControllerPod)).
Msgf("Error retrieving osm-controller pod %s", podName)
return nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/osm-injector/osm-injector.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ func getInjectorPod(kubeClient kubernetes.Interface) (*corev1.Pod, error) {

pod, err := kubeClient.CoreV1().Pods(osmNamespace).Get(context.TODO(), podName, metav1.GetOptions{})
if err != nil {
log.Error().Err(err).Str(errcode.Kind, errcode.ErrFetchingInjectorPod.String()).
// TODO: Need to push metric
log.Error().Err(err).Str(errcode.Kind, errcode.GetErrCodeWithMetric(errcode.ErrFetchingInjectorPod)).
Msgf("Error retrieving osm-injector pod %s", podName)
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/osm-injector/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func createReconciler(kubeClient *kubernetes.Clientset) error {
// mgr.Start() below will block until stopped
// See: https://github.com/kubernetes-sigs/controller-runtime/blob/release-0.6/pkg/manager/internal.go#L507-L514
if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil {
log.Error().Err(err).Str(errcode.Kind, errcode.ErrStartingReconcileManager.String()).
log.Error().Err(err).Str(errcode.Kind, errcode.GetErrCodeWithMetric(errcode.ErrStartingReconcileManager)).
Msg("Error starting controller-runtime manager for MutatingWebhookConfigurartion's reconciler")
}
}()
Expand Down
4 changes: 2 additions & 2 deletions pkg/envoy/cds/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func getMulticlusterGatewayUpstreamServiceCluster(catalog catalog.MeshCataloger,

ports, err := catalog.GetTargetPortToProtocolMappingForService(upstreamSvc)
if err != nil {
log.Error().Err(err).Str(errcode.Kind, errcode.ErrGettingServicePorts.String()).
log.Error().Err(err).Str(errcode.Kind, errcode.GetErrCodeWithMetric(errcode.ErrGettingServicePorts)).
Msgf("Failed to get ports for service %s", upstreamSvc)
return nil, err
}
Expand Down Expand Up @@ -209,7 +209,7 @@ func getLocalServiceCluster(catalog catalog.MeshCataloger, proxyServiceName serv

ports, err := catalog.GetTargetPortToProtocolMappingForService(proxyServiceName)
if err != nil {
log.Error().Err(err).Str(errcode.Kind, errcode.ErrGettingServicePorts.String()).
log.Error().Err(err).Str(errcode.Kind, errcode.GetErrCodeWithMetric(errcode.ErrGettingServicePorts)).
Msgf("Failed to get ports for service %s", proxyServiceName)
return nil, err
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/envoy/lds/inmesh.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (lb *listenerBuilder) getInboundMeshFilterChains(proxyService service.MeshS

protocolToPortMap, err := lb.meshCatalog.GetTargetPortToProtocolMappingForService(proxyService)
if err != nil {
log.Error().Err(err).Str(errcode.Kind, errcode.ErrGettingServicePorts.String()).
log.Error().Err(err).Str(errcode.Kind, errcode.GetErrCodeWithMetric(errcode.ErrGettingServicePorts)).
Msgf("Error retrieving port to protocol mapping for service %s", proxyService)
return filterChains
}
Expand Down Expand Up @@ -299,14 +299,14 @@ func (lb *listenerBuilder) getOutboundFilterChainMatchForService(dstSvc service.

endpoints, err := lb.meshCatalog.GetResolvableServiceEndpoints(dstSvc)
if err != nil {
log.Error().Err(err).Str(errcode.Kind, errcode.ErrGettingResolvableServiceEndpoints.String()).
log.Error().Err(err).Str(errcode.Kind, errcode.GetErrCodeWithMetric(errcode.ErrGettingResolvableServiceEndpoints)).
Msgf("Error getting GetResolvableServiceEndpoints for %q", dstSvc)
return nil, err
}

if len(endpoints) == 0 {
err := errors.Errorf("Endpoints not found for service %q", dstSvc)
log.Error().Err(err).Str(errcode.Kind, errcode.ErrEndpointsNotFound.String()).
log.Error().Err(err).Str(errcode.Kind, errcode.GetErrCodeWithMetric(errcode.ErrEndpointsNotFound)).
Msgf("Error constructing HTTP filter chain match for service %q", dstSvc)
return nil, err
}
Expand Down Expand Up @@ -436,7 +436,7 @@ func (lb *listenerBuilder) getOutboundFilterChainPerUpstream() []*xds_listener.F
log.Trace().Msgf("Building outbound filter chain for upstream service %s for proxy with identity %s", upstreamSvc, lb.serviceIdentity)
protocolToPortMap, err := lb.meshCatalog.GetPortToProtocolMappingForService(upstreamSvc)
if err != nil {
log.Error().Err(err).Str(errcode.Kind, errcode.ErrGettingServicePorts.String()).
log.Error().Err(err).Str(errcode.Kind, errcode.GetErrCodeWithMetric(errcode.ErrGettingServicePorts)).
Msgf("Error retrieving port to protocol mapping for upstream service %s", upstreamSvc)
continue
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/envoy/lds/rbac.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (lb *listenerBuilder) buildInboundRBACPolicies() (*xds_network_rbac.RBAC, e
proxyIdentity := identity.ServiceIdentity(lb.serviceIdentity.String())
trafficTargets, err := lb.meshCatalog.ListInboundTrafficTargetsWithRoutes(lb.serviceIdentity)
if err != nil {
log.Error().Err(err).Str(errcode.Kind, errcode.ErrGettingInboundTrafficTargets.String()).
log.Error().Err(err).Str(errcode.Kind, errcode.GetErrCodeWithMetric(errcode.ErrGettingInboundTrafficTargets)).
Msgf("Error listing allowed inbound traffic targets for proxy identity %s", proxyIdentity)
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/injector/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func makePatches(req *admissionv1.AdmissionRequest, pod *corev1.Pod) []jsonpatch
original := req.Object.Raw
current, err := json.Marshal(pod)
if err != nil {
log.Error().Err(err).Str(errcode.Kind, errcode.ErrMarshallingKubernetesResource.String()).
log.Error().Err(err).Str(errcode.Kind, errcode.GetErrCodeWithMetric(errcode.ErrMarshallingKubernetesResource)).
Msgf("Error marshaling Pod with UID=%s", pod.ObjectMeta.UID)
}
admissionResponse := admission.PatchResponseFromRaw(original, current)
Expand Down
4 changes: 2 additions & 2 deletions pkg/injector/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func (wh *mutatingWebhook) podCreationHandler(w http.ResponseWriter, req *http.R
resp, err := json.Marshal(&admissionResp)
if err != nil {
http.Error(w, fmt.Sprintf("Error marshalling admission response: %s", err), http.StatusInternalServerError)
log.Error().Err(err).Str(errcode.Kind, errcode.ErrMarshallingKubernetesResource.String()).
log.Error().Err(err).Str(errcode.Kind, errcode.GetErrCodeWithMetric(errcode.ErrMarshallingKubernetesResource)).
Msgf("Error marshalling admission response; Responded to admission request for pod with UUID %s in namespace %s with HTTP %v", proxyUUID, requestForNamespace, http.StatusInternalServerError)
return
}
Expand All @@ -235,7 +235,7 @@ func (wh *mutatingWebhook) mutate(req *admissionv1.AdmissionRequest, proxyUUID u
// Decode the Pod spec from the request
var pod corev1.Pod
if err := json.Unmarshal(req.Object.Raw, &pod); err != nil {
log.Error().Err(err).Str(errcode.Kind, errcode.ErrUnmarshallingKubernetesResource.String()).
log.Error().Err(err).Str(errcode.Kind, errcode.GetErrCodeWithMetric(errcode.ErrUnmarshallingKubernetesResource)).
Msgf("Error unmarshaling request to pod with UUID %s in namespace %s", proxyUUID, req.Namespace)
return webhook.AdmissionError(err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/validator/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func (s *ValidatingWebhookServer) doValidation(w http.ResponseWriter, req *http.
resp, err := json.Marshal(&admissionResp)
if err != nil {
http.Error(w, fmt.Sprintf("Error marshalling admission response: %s", err), http.StatusInternalServerError)
log.Error().Err(err).Str(errcode.Kind, errcode.ErrMarshallingKubernetesResource.String()).
log.Error().Err(err).Str(errcode.Kind, errcode.GetErrCodeWithMetric(errcode.ErrMarshallingKubernetesResource)).
Msgf("Error marshalling admission response; Responded to admission request in namespace %s with HTTP %v", requestForNamespace, http.StatusInternalServerError)
return
}
Expand Down

0 comments on commit a9b24c1

Please sign in to comment.