Skip to content
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

[chore]: enable whitespace linter (part 1) #36117

Merged
merged 2 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion receiver/aerospikereceiver/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ func nodeGetterFactory(cfg *clientConfig, policy *as.ClientPolicy, authEnabled b
authEnabled,
)
return cluster, err

}

// newASClient creates a new defaultASClient connected to the given host and port
Expand Down
1 change: 0 additions & 1 deletion receiver/aerospikereceiver/cluster/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ func TestNode_NewConnNode(t *testing.T) {
_, err = _newConnNode(cPolicy, host, authEnabled, factoryFuncNegLogin)
connFactoryNegLogin.AssertExpectations(t)
require.ErrorContains(t, err, "ResultCode: NOT_AUTHENTICATED")

}

func TestNode_RequestInfo(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion receiver/aerospikereceiver/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,6 @@ func (r *aerospikeReceiver) emitNamespace(info map[string]string, now pcommon.Ti
addPartialIfError(errs, r.mb.RecordAerospikeNamespaceTransactionCountDataPoint(now, v, metadata.AttributeTransactionTypeWrite, metadata.AttributeTransactionResultSuccess))
case "client_write_timeout":
addPartialIfError(errs, r.mb.RecordAerospikeNamespaceTransactionCountDataPoint(now, v, metadata.AttributeTransactionTypeWrite, metadata.AttributeTransactionResultTimeout))

}
}

Expand Down
1 change: 0 additions & 1 deletion receiver/apachereceiver/scraper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ func TestScraperFailedStart(t *testing.T) {
}

func TestParseScoreboard(t *testing.T) {

t.Run("test freq count", func(t *testing.T) {
scoreboard := `S_DD_L_GGG_____W__IIII_C________________W__________________________________.........................____WR______W____W________________________C______________________________________W_W____W______________R_________R________C_________WK_W________K_____W__C__________W___R______.............................................................................................................................`
results := parseScoreboard(scoreboard)
Expand Down
1 change: 0 additions & 1 deletion receiver/awscontainerinsightreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ func createMetricsReceiver(
baseCfg component.Config,
consumer consumer.Metrics,
) (receiver.Metrics, error) {

rCfg := baseCfg.(*Config)
return newAWSContainerInsightReceiver(params.TelemetrySettings, rCfg, consumer)
}
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ func (c *Cadvisor) addEbsVolumeInfo(tags map[string]string, ebsVolumeIDsUsedAsPV
}

func (c *Cadvisor) addECSMetrics(cadvisormetrics []*extractors.CAdvisorMetric) {

if len(cadvisormetrics) == 0 {
c.logger.Warn("cadvisor can't collect any metrics!")
}
Expand Down Expand Up @@ -300,15 +299,13 @@ func (c *Cadvisor) decorateMetrics(cadvisormetrics []*extractors.CAdvisorMetric)

// add tags for EKS
if c.containerOrchestrator == ci.EKS {

tags[ci.ClusterNameKey] = c.hostInfo.GetClusterName()

out := c.k8sDecorator.Decorate(m)
if out != nil {
result = append(result, out)
}
}

}

return result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
)

func TestDiskIOStats(t *testing.T) {

result := testutils.LoadContainerInfo(t, "./testdata/PreInfoContainer.json")
result2 := testutils.LoadContainerInfo(t, "./testdata/CurInfoContainer.json")
// for eks node-level metrics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ func AssertContainsTaggedField(
expectedFields map[string]any,
expectedTags map[string]string,
) {

actualFields := cadvisorMetric.GetFields()
actualTags := cadvisorMetric.GetTags()
if !reflect.DeepEqual(expectedTags, actualTags) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,4 @@ func TestMergeMetrics(t *testing.T) {
require.Len(t, mergedMetrics, 1)
assert.Equal(t, expected.GetTags(), mergedMetrics[0].GetTags())
assert.Equal(t, expected.GetFields(), mergedMetrics[0].GetFields())

}
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,4 @@ func TestFSStatsWithAllowList(t *testing.T) {
assert.Equal(t, "tmpfs", cMetrics[0].tags["device"])
assert.Equal(t, "/dev/xvda1", cMetrics[1].tags["device"])
assert.Equal(t, "overlay", cMetrics[2].tags["device"])

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ func (n *NetMetricExtractor) HasValue(info *cinfo.ContainerInfo) bool {
}

func (n *NetMetricExtractor) GetValue(info *cinfo.ContainerInfo, _ CPUMemInfoProvider, containerType string) []*CAdvisorMetric {

// Just a protection here, there is no Container level Net metrics
if containerType == ci.TypePod || containerType == ci.TypeContainer {
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ func newCGroupScanner(ctx context.Context, mountConfigPath string, logger *zap.L
}

func (c *cgroupScanner) refresh() {

if c.ecsTaskInfoProvider == nil {
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func TestGetCGroupPathForTask(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {

got, err := getCGroupPathForTask(cgroupMount, controller, tt.input, clusterName)

if tt.err != nil {
Expand Down Expand Up @@ -96,7 +95,6 @@ func TestGetCGroupPathFromARN(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {

got, err := getTaskCgroupPathFromARN(tt.input)

if tt.err != nil {
Expand All @@ -110,7 +108,6 @@ func TestGetCGroupPathFromARN(t *testing.T) {
}

func TestGetCGroupMountPoint(t *testing.T) {

tests := []struct {
name string
input string
Expand Down Expand Up @@ -149,7 +146,6 @@ func TestGetCGroupMountPoint(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {

got, err := getCGroupMountPoint(tt.input)

if tt.err != nil {
Expand All @@ -160,7 +156,6 @@ func TestGetCGroupMountPoint(t *testing.T) {
}
})
}

}

func TestGetCPUReservedInTask(t *testing.T) {
Expand Down Expand Up @@ -217,7 +212,6 @@ func TestGetCPUReservedInTask(t *testing.T) {
assert.Equal(t, tt.expectRes, got)
})
}

}

func TestGetMEMReservedInTask(t *testing.T) {
Expand Down Expand Up @@ -337,5 +331,4 @@ func TestGetCPUReservedAndMemReserved(t *testing.T) {
assert.Equal(t, int64(0), cgroup.getCPUReserved())

assert.Equal(t, int64(0), cgroup.getMemReserved())

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ func (mi *MockHostInfo) GetInstanceIPReadyC() chan bool {
}

func TestECSInstanceInfo(t *testing.T) {

var ctx, cancel = context.WithCancel(context.Background())
defer cancel()
instanceReadyC := make(chan bool)
Expand Down Expand Up @@ -81,5 +80,4 @@ func TestECSInstanceInfo(t *testing.T) {

assert.Equal(t, "", ecsinstanceinfo.GetClusterName())
assert.Equal(t, "", ecsinstanceinfo.GetContainerInstanceID())

}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ func (ti *taskInfo) getTasksInfo(ctx context.Context) (ecsTasksInfo *ECSTasksInf
}

func (ti *taskInfo) refresh(ctx context.Context) {

ecsTasksInfo := ti.getTasksInfo(ctx)
runningTaskCount := int64(0)
var tasks []ECSTask
Expand All @@ -100,7 +99,6 @@ func (ti *taskInfo) refresh(ctx context.Context) {
if len(ti.runningTasksInfo) != 0 && ti.runningTaskCount != 0 && !isClosed(ti.readyC) {
close(ti.readyC)
}

}

func (ti *taskInfo) getRunningTaskCount() int64 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
)

func TestECSTaskInfoSuccess(t *testing.T) {

ctx := context.Background()

taskReadyC := make(chan bool)
Expand Down Expand Up @@ -48,7 +47,6 @@ func TestECSTaskInfoSuccess(t *testing.T) {
assert.Equal(t, int64(1), ecsTaskinfo.getRunningTaskCount())

assert.NotEmpty(t, ecsTaskinfo.getRunningTasksInfo())

}

func TestECSTaskInfoFail(t *testing.T) {
Expand Down Expand Up @@ -88,5 +86,4 @@ func TestECSTaskInfoFail(t *testing.T) {
assert.NotNil(t, ecsTaskinfo)
assert.Equal(t, int64(0), ecsTaskinfo.getRunningTaskCount())
assert.Empty(t, ecsTaskinfo.getRunningTasksInfo())

}
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ func NewECSInfo(refreshInterval time.Duration, hostIPProvider hostIPProvider, ho
}

func (e *EcsInfo) initContainerInfo(ctx context.Context) {

<-e.hostIPProvider.GetInstanceIPReadyC()

e.logger.Info("instance ip is ready and begin initializing ecs container info")
Expand All @@ -133,7 +132,6 @@ func (e *EcsInfo) initContainerInfo(ctx context.Context) {
}

func (e *EcsInfo) initTaskInfo(ctx context.Context) {

<-e.hostIPProvider.GetInstanceIPReadyC()

e.logger.Info("instance ip is ready and begin initializing ecs task info")
Expand All @@ -144,7 +142,6 @@ func (e *EcsInfo) initTaskInfo(ctx context.Context) {
}

func (e *EcsInfo) initCgroupScanner(ctx context.Context) {

<-e.isContainerInfoReadyC
<-e.isTaskInfoReadyC

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ func (ii *MockTaskInfo) getRunningTaskCount() int64 {
return ii.runningTaskCount
}
func (ii *MockTaskInfo) getRunningTasksInfo() []ECSTask {

return ii.tasks
}

Expand Down Expand Up @@ -76,7 +75,6 @@ func (c *MockCgroupScanner) getMEMReservedInTask(_ string, _ string, _ []ECSCont
func TestNewECSInfo(t *testing.T) {
// test the case when containerInstanceInfor fails to initialize
containerInstanceInfoCreatorOpt := func(ei *EcsInfo) {

ei.containerInstanceInfoCreator = func(context.Context, hostIPProvider, time.Duration, *zap.Logger, doer, chan bool) containerInstanceInfoProvider {
return &MockInstanceInfo{
clusterName: "Cluster-name",
Expand Down Expand Up @@ -131,5 +129,4 @@ func TestNewECSInfo(t *testing.T) {

assert.Equal(t, int64(1024), ecsinfo.GetCPUReserved())
assert.Equal(t, int64(1024), ecsinfo.GetMemReserved())

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func GetContainerInstanceIDFromArn(arn string) (containerInstanceID string, err
}
err = errors.New("Can't get ecs container instance id from ContainerInstance arn: " + arn)
return

}

// Check the channel is closed or not.
Expand Down Expand Up @@ -94,7 +93,6 @@ func request(ctx context.Context, endpoint string, client doer) ([]byte, error)
return nil, fmt.Errorf("response from %s, execeeds the maximum length: %v", endpoint, maxHTTPResponseLength)
}
return body, nil

}

func clientGet(ctx context.Context, url string, client doer) (resp *http.Response, err error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ func (m *mockHTTPClient) Do(_ *http.Request) (*http.Response, error) {
}

func TestGetContainerInstanceIDFromArn(t *testing.T) {

oldFormatARN := "arn:aws:ecs:region:aws_account_id:task/task-id"
result, _ := GetContainerInstanceIDFromArn(oldFormatARN)
assert.Equal(t, "task-id", result, "Expected to be equal")
Expand All @@ -39,19 +38,16 @@ func TestGetContainerInstanceIDFromArn(t *testing.T) {
}

func TestIsClosed(t *testing.T) {

channel := make(chan bool)

assert.False(t, isClosed(channel))

close(channel)

assert.True(t, isClosed(channel))

}

func TestRequestSuccessWithKnownLength(t *testing.T) {

respBody := "body"
response := &http.Response{
StatusCode: http.StatusOK,
Expand All @@ -72,11 +68,9 @@ func TestRequestSuccessWithKnownLength(t *testing.T) {
assert.NoError(t, err)

assert.NotNil(t, body)

}

func TestRequestSuccessWithUnknownLength(t *testing.T) {

respBody := "body"
response := &http.Response{
StatusCode: http.StatusOK,
Expand All @@ -97,11 +91,9 @@ func TestRequestSuccessWithUnknownLength(t *testing.T) {
assert.NoError(t, err)

assert.NotNil(t, body)

}

func TestRequestWithFailedStatus(t *testing.T) {

respBody := "body"
response := &http.Response{
Status: "Bad Request",
Expand All @@ -123,11 +115,9 @@ func TestRequestWithFailedStatus(t *testing.T) {
assert.Nil(t, body)

assert.Error(t, err)

}

func TestRequestWithLargeContentLength(t *testing.T) {

respBody := "body"
response := &http.Response{
StatusCode: http.StatusOK,
Expand All @@ -148,5 +138,4 @@ func TestRequestWithLargeContentLength(t *testing.T) {
assert.Nil(t, body)

assert.Error(t, err)

}
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ func (k *K8sAPIServer) Shutdown() error {
}

func (k *K8sAPIServer) startLeaderElection(ctx context.Context, lock resourcelock.Interface) {

for {
leaderelection.RunOrDie(ctx, leaderelection.LeaderElectionConfig{
Lock: lock,
Expand Down
3 changes: 0 additions & 3 deletions receiver/awscontainerinsightreceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ func newAWSContainerInsightReceiver(
settings component.TelemetrySettings,
config *Config,
nextConsumer consumer.Metrics) (receiver.Metrics, error) {

r := &awsContainerInsightReceiver{
settings: settings,
nextConsumer: nextConsumer,
Expand Down Expand Up @@ -79,7 +78,6 @@ func (acir *awsContainerInsightReceiver) Start(ctx context.Context, host compone
}
}
if acir.config.ContainerOrchestrator == ci.ECS {

ecsInfo, err := ecsinfo.NewECSInfo(acir.config.CollectionInterval, hostinfo, host, acir.settings)
if err != nil {
return err
Expand Down Expand Up @@ -134,7 +132,6 @@ func (acir *awsContainerInsightReceiver) Shutdown(context.Context) error {
}

return errs

}

// collectData collects container stats from cAdvisor and k8s api server (if it is an elected leader)
Expand Down
Loading