Skip to content

Commit

Permalink
Merge pull request #137 from googs1025/fix_typo
Browse files Browse the repository at this point in the history
fix some typo and variable name
  • Loading branch information
k8s-ci-robot committed Jul 31, 2024
2 parents 7a27bc5 + 312ff4c commit d82be73
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pkg/collector/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (l Labeler) SetLabelsForQuota(labels *LabelsValues,
l.Extension.SetLabelsForQuota(&labels.Extension, quota, rqd, namespace)
}

// SetLabelsForNamespace parses metric labels from a namespace
// SetLabelsForNamespaces parses metric labels from a namespace
func (l Labeler) SetLabelsForNamespaces(labels *LabelsValues, namespace *corev1.Namespace) {
l.BuiltIn.SetLabelsForNamespace(&labels.BuiltIn, namespace)
l.Extension.SetLabelsForNamespace(&labels.Extension, namespace)
Expand Down
24 changes: 12 additions & 12 deletions pkg/collector/utilization/sampler_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func init() {
}

type Server struct {
ResponseMutext sync.RWMutex
ResponseMutex sync.RWMutex

// Responses has the last response for each node keyed by the node name
Responses map[string]*api.ListMetricsResponse `json:"responses" yaml:"responses"`
Expand All @@ -106,7 +106,7 @@ type Server struct {
grpcServer *grpc.Server
}

func (c *Server) Collect(ch chan<- prometheus.Metric, metrics map[string]*api.ListMetricsResponse) {
func (s *Server) Collect(ch chan<- prometheus.Metric, metrics map[string]*api.ListMetricsResponse) {
responseAgeSeconds.Reset()
for _, v := range metrics {
responseAgeSeconds.WithLabelValues(v.NodeName, v.PodName, v.Reason).Set(
Expand Down Expand Up @@ -246,7 +246,7 @@ func (s *Server) Check(ctx context.Context, _ *grpc_health_v1.HealthCheckRequest
return &grpc_health_v1.HealthCheckResponse{Status: grpc_health_v1.HealthCheckResponse_SERVING}, nil
}

// Ready returns success if the service should be accepting traffic
// IsReady returns success if the service should be accepting traffic
func (s *Server) IsReady(context.Context, *grpc_health_v1.HealthCheckRequest) (*grpc_health_v1.HealthCheckResponse, error) {
if !s.IsReadyResult.Load() {
return &grpc_health_v1.HealthCheckResponse{Status: grpc_health_v1.HealthCheckResponse_NOT_SERVING}, fmt.Errorf("not-ready")
Expand Down Expand Up @@ -317,7 +317,7 @@ func (s *Server) PushMetrics(req api.MetricsCollector_PushMetricsServer) error {

// GetContainerUsageSummary maps containers to their cached metric values. metrics are passed as an argument to
// reduce lock contention.
func (c *Server) GetContainerUsageSummary(metrics map[string]*api.ListMetricsResponse) map[sampler.ContainerKey]*api.ContainerMetrics {
func (s *Server) GetContainerUsageSummary(metrics map[string]*api.ListMetricsResponse) map[sampler.ContainerKey]*api.ContainerMetrics {
// Transform map of node -> utilization to map of container -> utilization by pulling the containers
// out of each node response
var values = map[sampler.ContainerKey]*api.ContainerMetrics{}
Expand Down Expand Up @@ -373,8 +373,8 @@ func (s *Server) GetMetrics() map[string]*api.ListMetricsResponse {
func (s *Server) GetNodeNames() sets.String {
nodes := sets.NewString()
func() {
s.ResponseMutext.Lock()
defer s.ResponseMutext.Unlock()
s.ResponseMutex.Lock()
defer s.ResponseMutex.Unlock()
for k, v := range s.Responses {
if time.Since(v.Timestamp.AsTime()) > s.ttl {
continue
Expand All @@ -389,8 +389,8 @@ func (s *Server) GetNodeNames() sets.String {
func (s *Server) getMetrics(filterExpired bool) map[string]*api.ListMetricsResponse {
values := make(map[string]*api.ListMetricsResponse, len(s.Responses))
func() {
s.ResponseMutext.Lock()
defer s.ResponseMutext.Unlock()
s.ResponseMutex.Lock()
defer s.ResponseMutex.Unlock()
for k, v := range s.Responses {
values[k] = v
}
Expand All @@ -411,14 +411,14 @@ func (s *Server) getMetrics(filterExpired bool) map[string]*api.ListMetricsRespo

// ClearMetrics deletes the metrics with the given key from the cache
func (s *Server) ClearMetrics(key string) {
s.ResponseMutext.Lock()
defer s.ResponseMutext.Unlock()
s.ResponseMutex.Lock()
defer s.ResponseMutex.Unlock()
delete(s.Responses, key)
}

// CacheMetrics caches msg
func (s *Server) CacheMetrics(msg *api.ListMetricsResponse) {
s.ResponseMutext.Lock()
defer s.ResponseMutext.Unlock()
s.ResponseMutex.Lock()
defer s.ResponseMutex.Unlock()
s.Responses[msg.NodeName] = msg
}
2 changes: 1 addition & 1 deletion pkg/testutil/fakeclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func (fc FakeContainer) Info(context.Context, ...containerd.InfoOpts) (container
return fc.UnderlyingContainer, nil
}

// Task() returns the fake container task
// Task returns the fake container task
func (fc FakeContainer) Task(context.Context, cio.Attach) (containerd.Task, error) {
return &fc.FakeTask, nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/testutil/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ func (tc TestCase) GetObjects(s *runtime.Scheme) ([]client.Object, []client.Obje
return objs, objList, nil
}

// GetObjects parses the input objects from the test case
// GetObjectsFromFile parses the input objects from the test case
func (tc TestCase) GetObjectsFromFile(js *sjson.Serializer, s *runtime.Scheme, filename, data string) ([]client.Object, []client.ObjectList, error) {
var objs []client.Object
var objLists []client.ObjectList
Expand Down

0 comments on commit d82be73

Please sign in to comment.