diff --git a/.golangci.yaml b/.golangci.yaml index c81a0e0b..fb2b3c30 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -26,7 +26,7 @@ linters: - staticcheck - revive - gosec - - exportloopref + - copyloopvar - prealloc linters-settings: gocritic: diff --git a/bidengine/pricing.go b/bidengine/pricing.go index 2323bf96..5c22704d 100644 --- a/bidengine/pricing.go +++ b/bidengine/pricing.go @@ -144,11 +144,11 @@ func (fp scalePricing) CalculatePrice(_ context.Context, req Request) (sdk.DecCo endpointTotal := decimal.NewFromInt(0) ipTotal := decimal.NewFromInt(0).Add(fp.ipScale) - ipTotal = ipTotal.Mul(decimal.NewFromInt(int64(util.GetEndpointQuantityOfResourceGroup(req.GSpec, atypes.Endpoint_LEASED_IP)))) + ipTotal = ipTotal.Mul(decimal.NewFromInt(int64(util.GetEndpointQuantityOfResourceGroup(req.GSpec, atypes.Endpoint_LEASED_IP)))) // nolint: gosec // iterate over everything & sum it up for _, group := range req.GSpec.Resources { - groupCount := decimal.NewFromInt(int64(group.Count)) // Expand uint32 to int64 + groupCount := decimal.NewFromInt(int64(group.Count)) // // nolint: gosec cpuQuantity := decimal.NewFromBigInt(group.Resources.CPU.Units.Val.BigInt(), 0) cpuQuantity = cpuQuantity.Mul(groupCount) @@ -174,7 +174,7 @@ func (fp scalePricing) CalculatePrice(_ context.Context, req Request) (sdk.DecCo total, exists := storageTotal[storageClass] if !exists { - return sdk.DecCoin{}, errors.Wrapf(errNoPriceScaleForStorageClass, storageClass) + return sdk.DecCoin{}, errors.Wrapf(errNoPriceScaleForStorageClass, "%s", storageClass) } total = total.Add(storageQuantity) @@ -250,14 +250,14 @@ func MakeRandomRangePricing() (BidPricingStrategy, error) { } func (randomRangePricing) CalculatePrice(_ context.Context, req Request) (sdk.DecCoin, error) { - min, max := calculatePriceRange(req.GSpec) - if min.IsEqual(max) { - return max, nil + minPrice, maxPrice := calculatePriceRange(req.GSpec) + if minPrice.IsEqual(maxPrice) { + return maxPrice, nil } const scale = 10000 - delta := max.Amount.Sub(min.Amount).Mul(sdk.NewDec(scale)) + delta := maxPrice.Amount.Sub(minPrice.Amount).Mul(sdk.NewDec(scale)) minbid := delta.TruncateInt64() if minbid < 1 { @@ -269,8 +269,8 @@ func (randomRangePricing) CalculatePrice(_ context.Context, req Request) (sdk.De } scaledValue := sdk.NewDecFromBigInt(val).QuoInt64(scale).QuoInt64(100) - amount := min.Amount.Add(scaledValue) - return sdk.NewDecCoinFromDec(min.Denom, amount), nil + amount := minPrice.Amount.Add(scaledValue) + return sdk.NewDecCoinFromDec(minPrice.Denom, amount), nil } func calculatePriceRange(gspec *dtypes.GroupSpec) (sdk.DecCoin, sdk.DecCoin) { diff --git a/bidengine/pricing_test.go b/bidengine/pricing_test.go index 9226a209..1882e137 100644 --- a/bidengine/pricing_test.go +++ b/bidengine/pricing_test.go @@ -186,7 +186,7 @@ func Test_ScalePricingOnMemory(t *testing.T) { price, err := pricing.CalculatePrice(context.Background(), req) require.NoError(t, err) - expectedPrice := testutil.AkashDecCoin(t, int64(memoryScale*memoryQuantity)) + expectedPrice := testutil.AkashDecCoin(t, int64(memoryScale*memoryQuantity)) // nolint: gosec require.Equal(t, expectedPrice, price) } @@ -258,7 +258,7 @@ func Test_ScalePricingOnStorage(t *testing.T) { price, err := pricing.CalculatePrice(context.Background(), req) require.NoError(t, err) - decNearly(t, price.Amount, int64(storageScale*storageQuantity)) + decNearly(t, price.Amount, int64(storageScale*storageQuantity)) // nolint: gosec } func Test_ScalePricingByCountOfResources(t *testing.T) { @@ -282,12 +282,12 @@ func Test_ScalePricingByCountOfResources(t *testing.T) { require.NoError(t, err) require.NoError(t, err) - decNearly(t, firstPrice.Amount, int64(storageScale*storageQuantity)) + decNearly(t, firstPrice.Amount, int64(storageScale*storageQuantity)) // nolint: gosec gspec.Resources[0].Count = 2 secondPrice, err := pricing.CalculatePrice(context.Background(), req) require.NoError(t, err) - decNearly(t, secondPrice.Amount, 2*int64(storageScale*storageQuantity)) + decNearly(t, secondPrice.Amount, 2*int64(storageScale*storageQuantity)) // nolint: gosec } func Test_ScalePricingForIPs(t *testing.T) { @@ -956,8 +956,6 @@ func Test_newDataForScript_GPUWildcard(t *testing.T) { } for _, c := range cases { - c := c - t.Run(c.desc, func(t *testing.T) { d := newDataForScript(c.r) assert.NotEmpty(t, d) diff --git a/bidengine/service.go b/bidengine/service.go index 66b7df09..51c39f18 100644 --- a/bidengine/service.go +++ b/bidengine/service.go @@ -228,7 +228,7 @@ loop: } case ch := <-s.statusch: ch <- &Status{ - Orders: uint32(len(s.orders)), + Orders: uint32(len(s.orders)), // nolint: gosec } case order := <-s.drainch: // child done @@ -237,7 +237,7 @@ loop: ordersCounter.WithLabelValues("stop").Inc() trySignal() case <-signalch: - bus.Pub(provider.BidEngineStatus{Orders: uint32(len(s.orders))}, []string{ptypes.PubSubTopicBidengineStatus}, tpubsub.WithRetain()) + bus.Pub(provider.BidEngineStatus{Orders: uint32(len(s.orders))}, []string{ptypes.PubSubTopicBidengineStatus}, tpubsub.WithRetain()) // nolint: gosec } s.updateOrderManagerGauge() } diff --git a/bidengine/shellscript.go b/bidengine/shellscript.go index d086b27d..af06c6b7 100644 --- a/bidengine/shellscript.go +++ b/bidengine/shellscript.go @@ -143,7 +143,7 @@ func (ssp shellScriptPricing) CalculatePrice(ctx context.Context, r Request) (sd processCtx, cancel := context.WithTimeout(ctx, ssp.runtimeLimit) defer cancel() - cmd := exec.CommandContext(processCtx, ssp.path) //nolint:gosec + cmd := exec.CommandContext(processCtx, ssp.path) // nolint: gosec cmd.Stdin = buf outputBuf := &bytes.Buffer{} cmd.Stdout = outputBuf diff --git a/cluster/client.go b/cluster/client.go index d3a99d9a..89d50fd2 100644 --- a/cluster/client.go +++ b/cluster/client.go @@ -195,8 +195,8 @@ func (c *nullClient) LeaseStatus(_ context.Context, lid mtypes.LeaseID) (map[str for _, svc := range lease.group.Services { resp[svc.Name] = &ctypes.ServiceStatus{ Name: svc.Name, - Available: int32(svc.Count), - Total: int32(svc.Count), + Available: int32(svc.Count), // nolint: gosec + Total: int32(svc.Count), // nolint: gosec } } diff --git a/cluster/inventory.go b/cluster/inventory.go index d7f6cf8c..8237f437 100644 --- a/cluster/inventory.go +++ b/cluster/inventory.go @@ -212,7 +212,7 @@ func (is *inventoryService) reserve(order mtypes.OrderID, resources dtypes.Resou } } -func (is *inventoryService) unreserve(order mtypes.OrderID) error { // nolint:golint,unparam +func (is *inventoryService) unreserve(order mtypes.OrderID) error { // nolint: golint,unparam ch := make(chan inventoryResponse, 1) req := inventoryRequest{ order: order, diff --git a/cluster/inventory_test.go b/cluster/inventory_test.go index 4047a9e3..0157d65c 100644 --- a/cluster/inventory_test.go +++ b/cluster/inventory_test.go @@ -263,7 +263,7 @@ func TestInventory_ClusterDeploymentDeployed(t *testing.T) { } // availableExternalEndpoints should be consumed because of the deployed reservation - require.Equal(t, uint(1000-countOfRandomPortService), inv.availableExternalPorts) + require.Equal(t, uint(1000-countOfRandomPortService), inv.availableExternalPorts) // nolint: gosec // Unreserving the allocated reservation should reclaim the availableExternalEndpoints err = inv.unreserve(lid.OrderID()) @@ -464,8 +464,8 @@ func TestInventory_ReserveIPUnavailableWithIPOperator(t *testing.T) { ipQty := testutil.RandRangeInt(1, 100) mockIP.On("GetIPAddressUsage", mock.Anything).Return(cip.AddressUsage{ - Available: uint(ipQty), - InUse: uint(ipQty), + Available: uint(ipQty), // nolint: gosec + InUse: uint(ipQty), // nolint: gosec }, nil) mockIP.On("Stop") @@ -520,8 +520,8 @@ func TestInventory_ReserveIPAvailableWithIPOperator(t *testing.T) { ipQty := testutil.RandRangeInt(5, 10) mockIP.On("GetIPAddressUsage", mock.Anything).Return(cip.AddressUsage{ - Available: uint(ipQty), - InUse: uint(ipQty - 1), // not all in use + Available: uint(ipQty), // nolint: gosec + InUse: uint(ipQty - 1), // nolint: gosec }, nil) ipAddrStatusCalled := make(chan struct{}, 2) @@ -717,5 +717,5 @@ func TestInventory_OverReservations(t *testing.T) { <-inv.lc.Done() // No ports used yet - require.Equal(t, uint(1000-countOfRandomPortService), inv.availableExternalPorts) + require.Equal(t, uint(1000-countOfRandomPortService), inv.availableExternalPorts) // nolint: gosec } diff --git a/cluster/kube/builder/workload.go b/cluster/kube/builder/workload.go index a8a9ec8c..34aea561 100644 --- a/cluster/kube/builder/workload.go +++ b/cluster/kube/builder/workload.go @@ -84,8 +84,8 @@ func (b *Workload) container() corev1.Container { if cpu := service.Resources.CPU; cpu != nil { requestedCPU := sdlutil.ComputeCommittedResources(b.settings.CPUCommitLevel, cpu.Units) - kcontainer.Resources.Requests[corev1.ResourceCPU] = resource.NewScaledQuantity(int64(requestedCPU.Value()), resource.Milli).DeepCopy() - kcontainer.Resources.Limits[corev1.ResourceCPU] = resource.NewScaledQuantity(int64(cpu.Units.Value()), resource.Milli).DeepCopy() + kcontainer.Resources.Requests[corev1.ResourceCPU] = resource.NewScaledQuantity(int64(requestedCPU.Value()), resource.Milli).DeepCopy() // nolint: gosec + kcontainer.Resources.Limits[corev1.ResourceCPU] = resource.NewScaledQuantity(int64(cpu.Units.Value()), resource.Milli).DeepCopy() // nolint: gosec } if gpu := service.Resources.GPU; gpu != nil && gpu.Units.Value() > 0 { @@ -105,8 +105,8 @@ func (b *Workload) container() corev1.Container { // - can specify GPU in both limits and requests but these two values must be equal. // - cannot specify GPU requests without specifying limits. requestedGPU := sdlutil.ComputeCommittedResources(b.settings.GPUCommitLevel, gpu.Units) - kcontainer.Resources.Requests[resourceName] = resource.NewQuantity(int64(requestedGPU.Value()), resource.DecimalSI).DeepCopy() - kcontainer.Resources.Limits[resourceName] = resource.NewQuantity(int64(gpu.Units.Value()), resource.DecimalSI).DeepCopy() + kcontainer.Resources.Requests[resourceName] = resource.NewQuantity(int64(requestedGPU.Value()), resource.DecimalSI).DeepCopy() // nolint: gosec + kcontainer.Resources.Limits[resourceName] = resource.NewQuantity(int64(gpu.Units.Value()), resource.DecimalSI).DeepCopy() // nolint: gosec } var requestedMem uint64 @@ -120,8 +120,8 @@ func (b *Workload) container() corev1.Container { if !persistent { if class == "" { requestedStorage := sdlutil.ComputeCommittedResources(b.settings.StorageCommitLevel, ephemeral.Quantity) - kcontainer.Resources.Requests[corev1.ResourceEphemeralStorage] = resource.NewQuantity(int64(requestedStorage.Value()), resource.DecimalSI).DeepCopy() - kcontainer.Resources.Limits[corev1.ResourceEphemeralStorage] = resource.NewQuantity(int64(ephemeral.Quantity.Value()), resource.DecimalSI).DeepCopy() + kcontainer.Resources.Requests[corev1.ResourceEphemeralStorage] = resource.NewQuantity(int64(requestedStorage.Value()), resource.DecimalSI).DeepCopy() // nolint: gosec + kcontainer.Resources.Limits[corev1.ResourceEphemeralStorage] = resource.NewQuantity(int64(ephemeral.Quantity.Value()), resource.DecimalSI).DeepCopy() // nolint: gosec } else if class == "ram" { requestedMem += ephemeral.Quantity.Value() } @@ -131,8 +131,8 @@ func (b *Workload) container() corev1.Container { // fixme: ram is never expected to be nil if mem := service.Resources.Memory; mem != nil { requestedRAM := sdlutil.ComputeCommittedResources(b.settings.MemoryCommitLevel, mem.Quantity) - kcontainer.Resources.Requests[corev1.ResourceMemory] = resource.NewQuantity(int64(requestedRAM.Value()), resource.DecimalSI).DeepCopy() - kcontainer.Resources.Limits[corev1.ResourceMemory] = resource.NewQuantity(int64(mem.Quantity.Value()+requestedMem), resource.DecimalSI).DeepCopy() + kcontainer.Resources.Requests[corev1.ResourceMemory] = resource.NewQuantity(int64(requestedRAM.Value()), resource.DecimalSI).DeepCopy() // nolint: gosec + kcontainer.Resources.Limits[corev1.ResourceMemory] = resource.NewQuantity(int64(mem.Quantity.Value()+requestedMem), resource.DecimalSI).DeepCopy() // nolint: gosec } if service.Params != nil { @@ -161,7 +161,7 @@ func (b *Workload) container() corev1.Container { for _, expose := range service.Expose { kcontainer.Ports = append(kcontainer.Ports, corev1.ContainerPort{ - ContainerPort: int32(expose.Port), + ContainerPort: int32(expose.Port), // nolint: gosec }) } @@ -232,7 +232,7 @@ func (b *Workload) persistentVolumeClaims() []corev1.PersistentVolumeClaim { }, } - pvc.Spec.Resources.Requests[corev1.ResourceStorage] = resource.NewQuantity(int64(storage.Quantity.Value()), resource.DecimalSI).DeepCopy() + pvc.Spec.Resources.Requests[corev1.ResourceStorage] = resource.NewQuantity(int64(storage.Quantity.Value()), resource.DecimalSI).DeepCopy() // nolint: gosec attr = storage.Attributes.Find(sdl.StorageAttributeClass) if class, valid := attr.AsString(); valid && class != sdl.StorageClassDefault { @@ -262,7 +262,7 @@ func (b *Workload) runtimeClass() *string { func (b *Workload) replicas() *int32 { replicas := new(int32) - *replicas = int32(b.deployment.ManifestGroup().Services[b.serviceIdx].Count) + *replicas = int32(b.deployment.ManifestGroup().Services[b.serviceIdx].Count) // nolint: gosec return replicas } diff --git a/cluster/kube/client.go b/cluster/kube/client.go index 540557a2..cabfcc6b 100644 --- a/cluster/kube/client.go +++ b/cluster/kube/client.go @@ -402,7 +402,6 @@ func newEventsFeedList(ctx context.Context, events []eventsv1.Event) ctypes.Even done: for _, evt := range events { - evt := evt if !wtch.SendEvent(&evt) { break done } @@ -552,8 +551,8 @@ func (c *client) ForwardedPortStatus(ctx context.Context, leaseID mtypes.LeaseID // Record the actual port inside the container that is exposed v := ctypes.ForwardedPortStatus{ Host: settings.ClusterPublicHostname, - Port: uint16(port.TargetPort.IntVal), - ExternalPort: uint16(nodePort), + Port: uint16(port.TargetPort.IntVal), // nolint: gosec + ExternalPort: uint16(nodePort), // nolint: gosec Name: deploymentName, } diff --git a/cluster/kube/operators/clients/inventory/client.go b/cluster/kube/operators/clients/inventory/client.go index fee996c3..6f596fe6 100644 --- a/cluster/kube/operators/clients/inventory/client.go +++ b/cluster/kube/operators/clients/inventory/client.go @@ -338,7 +338,7 @@ func newInventoryConnector(ctx context.Context, svc *corev1.Service, invch chan< return nil, err } } else { - ports = append(ports, portforward.ForwardedPort{Local: uint16(svcPort)}) + ports = append(ports, portforward.ForwardedPort{Local: uint16(svcPort)}) // nolint: gosec } endpoint = fmt.Sprintf("localhost:%d", ports[0].Local) diff --git a/cluster/kube/operators/clients/inventory/client_test.go b/cluster/kube/operators/clients/inventory/client_test.go index e69439c5..80a176bf 100644 --- a/cluster/kube/operators/clients/inventory/client_test.go +++ b/cluster/kube/operators/clients/inventory/client_test.go @@ -118,7 +118,7 @@ func (sf *inventoryScaffold) createFakeOperator(t *testing.T) { { Name: "grpc", Protocol: "tcp", - Port: int32(sf.ports[0]), + Port: int32(sf.ports[0]), // nolint: gosec TargetPort: intstr.FromString("grpc"), }, }, @@ -144,7 +144,7 @@ func (sf *inventoryScaffold) createFakeOperator(t *testing.T) { Ports: []corev1.ContainerPort{ { Name: "grpc", - ContainerPort: int32(sf.ports[0]), + ContainerPort: int32(sf.ports[0]), // nolint: gosec }, }, }, @@ -168,7 +168,7 @@ func (sf *inventoryScaffold) createFakeOperator(t *testing.T) { Ports: []corev1.ContainerPort{ { Name: "grpc", - ContainerPort: int32(sf.ports[0]), + ContainerPort: int32(sf.ports[0]), // nolint: gosec }, }, }, diff --git a/cluster/kube/operators/clients/inventory/inventory.go b/cluster/kube/operators/clients/inventory/inventory.go index 7879fdc7..2340325a 100644 --- a/cluster/kube/operators/clients/inventory/inventory.go +++ b/cluster/kube/operators/clients/inventory/inventory.go @@ -335,32 +335,32 @@ func (inv *inventory) Metrics() inventoryV1.Metrics { invNode := inventoryV1.NodeMetrics{ Name: nd.Name, Allocatable: inventoryV1.ResourcesMetric{ - CPU: uint64(nd.Resources.CPU.Quantity.Allocatable.MilliValue()), - GPU: uint64(nd.Resources.GPU.Quantity.Allocatable.Value()), - Memory: uint64(nd.Resources.Memory.Quantity.Allocatable.Value()), - StorageEphemeral: uint64(nd.Resources.EphemeralStorage.Allocatable.Value()), + CPU: uint64(nd.Resources.CPU.Quantity.Allocatable.MilliValue()), // nolint: gosec + GPU: uint64(nd.Resources.GPU.Quantity.Allocatable.Value()), // nolint: gosec + Memory: uint64(nd.Resources.Memory.Quantity.Allocatable.Value()), // nolint: gosec + StorageEphemeral: uint64(nd.Resources.EphemeralStorage.Allocatable.Value()), // nolint: gosec }, } - cpuTotal += uint64(nd.Resources.CPU.Quantity.Allocatable.MilliValue()) - gpuTotal += uint64(nd.Resources.GPU.Quantity.Allocatable.Value()) - memoryTotal += uint64(nd.Resources.Memory.Quantity.Allocatable.Value()) - storageEphemeralTotal += uint64(nd.Resources.EphemeralStorage.Allocatable.Value()) + cpuTotal += uint64(nd.Resources.CPU.Quantity.Allocatable.MilliValue()) // nolint: gosec + gpuTotal += uint64(nd.Resources.GPU.Quantity.Allocatable.Value()) // nolint: gosec + memoryTotal += uint64(nd.Resources.Memory.Quantity.Allocatable.Value()) // nolint: gosec + storageEphemeralTotal += uint64(nd.Resources.EphemeralStorage.Allocatable.Value()) // nolint: gosec avail := nd.Resources.CPU.Quantity.Available() - invNode.Available.CPU = uint64(avail.MilliValue()) + invNode.Available.CPU = uint64(avail.MilliValue()) // nolint: gosec cpuAvailable += invNode.Available.CPU avail = nd.Resources.GPU.Quantity.Available() - invNode.Available.GPU = uint64(avail.Value()) + invNode.Available.GPU = uint64(avail.Value()) // nolint: gosec gpuAvailable += invNode.Available.GPU avail = nd.Resources.Memory.Quantity.Available() - invNode.Available.Memory = uint64(avail.Value()) + invNode.Available.Memory = uint64(avail.Value()) // nolint: gosec memoryAvailable += invNode.Available.Memory avail = nd.Resources.EphemeralStorage.Available() - invNode.Available.StorageEphemeral = uint64(avail.Value()) + invNode.Available.StorageEphemeral = uint64(avail.Value()) // nolint: gosec storageEphemeralAvailable += invNode.Available.StorageEphemeral ret.Nodes = append(ret.Nodes, invNode) diff --git a/cluster/kube/operators/clients/ip/client_test.go b/cluster/kube/operators/clients/ip/client_test.go index d6df4b5b..8412996a 100644 --- a/cluster/kube/operators/clients/ip/client_test.go +++ b/cluster/kube/operators/clients/ip/client_test.go @@ -34,16 +34,16 @@ type fakeOperator struct { } func (fio *fakeOperator) setHealthStatus(status int) { - atomic.StoreUint32(&fio.healthStatus, uint32(status)) + atomic.StoreUint32(&fio.healthStatus, uint32(status)) // nolint: gosec } func (fio *fakeOperator) setIPLeaseStatusResponse(status int, body []byte) { - atomic.StoreUint32(&fio.ipLeaseStatusStatus, uint32(status)) + atomic.StoreUint32(&fio.ipLeaseStatusStatus, uint32(status)) // nolint: gosec fio.ipLeaseStatusResponse.Store(body) } func (fio *fakeOperator) setIPUsageResponse(status int, body []byte) { - atomic.StoreUint32(&fio.ipUsageStatus, uint32(status)) + atomic.StoreUint32(&fio.ipUsageStatus, uint32(status)) // nolint: gosec fio.ipUsageResponse.Store(body) } @@ -113,7 +113,7 @@ func TestIPOperatorClient(t *testing.T) { srv := net.SRV{ Target: "localhost", - Port: uint16(portNumber), + Port: uint16(portNumber), // nolint: gosec Priority: 0, Weight: 0, } diff --git a/cluster/kube/operators/clients/metallb/client.go b/cluster/kube/operators/clients/metallb/client.go index d4723996..ece35d15 100644 --- a/cluster/kube/operators/clients/metallb/client.go +++ b/cluster/kube/operators/clients/metallb/client.go @@ -297,8 +297,8 @@ func (c *client) GetIPAddressStatusForLease(ctx context.Context, leaseID mtypes. leaseID: leaseID, ip: ingress.IP, serviceName: selectedServiceName, - externalPort: uint32(port.Port), - port: uint32(port.TargetPort.IntValue()), + externalPort: uint32(port.Port), // nolint: gosec + port: uint32(port.TargetPort.IntValue()), // nolint: gosec sharingKey: service.ObjectMeta.Annotations[metalLbAllowSharedIP], protocol: proto, }) @@ -373,7 +373,7 @@ func (c *client) CreateIPPassthrough(ctx context.Context, directive cip.ClusterI port := corev1.ServicePort{ Name: portName, Protocol: proto, - Port: int32(directive.ExternalPort), + Port: int32(directive.ExternalPort), // nolint: gosec TargetPort: intstr.FromInt(int(directive.Port)), } @@ -478,7 +478,7 @@ func (c *client) GetIPPassthroughs(ctx context.Context) ([]cip.Passthrough, erro v := ipPassthrough{ lID: leaseID, serviceName: serviceName, - externalPort: uint32(port), + externalPort: uint32(port), // nolint: gosec sharingKey: sharingKey, protocol: mproto, } diff --git a/cluster/kube/resourcetypes.go b/cluster/kube/resourcetypes.go index eb3bbb6d..233929f5 100644 --- a/cluster/kube/resourcetypes.go +++ b/cluster/kube/resourcetypes.go @@ -58,7 +58,7 @@ func (rp *resourcePair) subMilliNLZ(val types.ResourceValue) bool { } allocated := rp.allocated.DeepCopy() - allocated.Add(*resource.NewMilliQuantity(int64(val.Value()), resource.DecimalSI)) + allocated.Add(*resource.NewMilliQuantity(int64(val.Value()), resource.DecimalSI)) // nolint: gosec *rp = resourcePair{ allocatable: rp.allocatable.DeepCopy(), @@ -79,7 +79,7 @@ func (rp *resourcePair) subNLZ(val types.ResourceValue) bool { } allocated := rp.allocated.DeepCopy() - allocated.Add(*resource.NewQuantity(int64(val.Value()), resource.DecimalSI)) + allocated.Add(*resource.NewQuantity(int64(val.Value()), resource.DecimalSI)) // nolint: gosec *rp = resourcePair{ allocatable: rp.allocatable.DeepCopy(), diff --git a/cluster/manager.go b/cluster/manager.go index 7ecca49a..fc4f8575 100644 --- a/cluster/manager.go +++ b/cluster/manager.go @@ -441,7 +441,7 @@ func (dm *deploymentManager) doDeploy(ctx context.Context) ([]string, []string, } for host, serviceExpose := range hosts { - externalPort := uint32(serviceExpose.GetExternalPort()) + externalPort := uint32(serviceExpose.GetExternalPort()) // nolint: gosec err = dm.client.DeclareHostname(ctx, dm.deployment.LeaseID(), host, hostToServiceName[host], externalPort) if err != nil { // TODO - counter @@ -457,7 +457,7 @@ func (dm *deploymentManager) doDeploy(ctx context.Context) ([]string, []string, externalPort := serviceExpose.expose.GetExternalPort() port := serviceExpose.expose.Port - err = dm.client.DeclareIP(ctx, dm.deployment.LeaseID(), serviceExpose.name, port, uint32(externalPort), serviceExpose.expose.Proto, sharingKey, false) + err = dm.client.DeclareIP(ctx, dm.deployment.LeaseID(), serviceExpose.name, port, uint32(externalPort), serviceExpose.expose.Proto, sharingKey, false) // nolint: gosec if err != nil { if !errors.Is(err, kubeclienterrors.ErrAlreadyExists) { dm.log.Error("failed adding IP declaration", "service", serviceExpose.name, "port", externalPort, "endpoint", serviceExpose.expose.IP, "err", err) diff --git a/cluster/monitor.go b/cluster/monitor.go index 4123babd..53e596f4 100644 --- a/cluster/monitor.go +++ b/cluster/monitor.go @@ -171,7 +171,7 @@ func (m *deploymentMonitor) doCheck(ctx context.Context) (bool, error) { for _, spec := range m.deployment.ManifestGroup().Services { service, foundService := status[spec.Name] if foundService { - if uint32(service.Available) < spec.Count { + if uint32(service.Available) < spec.Count { // nolint: gosec badsvc++ m.log.Debug("service available replicas below target", "service", spec.Name, @@ -224,7 +224,7 @@ func (m *deploymentMonitor) scheduleHealthcheck() <-chan time.Time { return m.schedule(m.config.MonitorHealthcheckPeriod, m.config.MonitorHealthcheckPeriodJitter) } -func (m *deploymentMonitor) schedule(min, jitter time.Duration) <-chan time.Time { - period := min + time.Duration(rand.Int63n(int64(jitter))) // nolint: gosec +func (m *deploymentMonitor) schedule(minTime, jitter time.Duration) <-chan time.Time { + period := minTime + time.Duration(rand.Int63n(int64(jitter))) // nolint: gosec return time.After(period) } diff --git a/cluster/service.go b/cluster/service.go index 1fdd8ef8..66c51475 100644 --- a/cluster/service.go +++ b/cluster/service.go @@ -381,10 +381,10 @@ loop: } case ch := <-s.statusch: ch <- &ctypes.Status{ - Leases: uint32(len(s.managers)), + Leases: uint32(len(s.managers)), // nolint: gosec } case ch := <-s.statusV1ch: - ch <- uint32(len(s.managers)) + ch <- uint32(len(s.managers)) // nolint: gosec case <-signalch: istatus, _ := s.inventory.statusV1(ctx) @@ -393,7 +393,7 @@ loop: } msg := provider.ClusterStatus{ - Leases: provider.Leases{Active: uint32(len(s.managers))}, + Leases: provider.Leases{Active: uint32(len(s.managers))}, // nolint: gosec Inventory: *istatus, } bus.Pub(msg, []string{ptypes.PubSubTopicClusterStatus}, tpubsub.WithRetain()) diff --git a/cluster/types/v1beta2/types.go b/cluster/types/v1beta2/types.go index c57e1e79..6a8e7b12 100644 --- a/cluster/types/v1beta2/types.go +++ b/cluster/types/v1beta2/types.go @@ -84,7 +84,7 @@ func (inv *InventoryMetricTotal) AddResources(res types.Resources) { if storageClass, found := storage.Attributes.Find(sdl.StorageAttributeClass).AsString(); !found { ephemeralStorage = ephemeralStorage.Add(storage.Quantity.Val.MulRaw(int64(res.Count))) } else { - val := sdk.NewIntFromUint64(uint64(inv.Storage[storageClass])) + val := sdk.NewIntFromUint64(uint64(inv.Storage[storageClass])) // nolint: gosec val = val.Add(storage.Quantity.Val.MulRaw(int64(res.Count))) inv.Storage[storageClass] = val.Int64() } diff --git a/cluster/types/v1beta3/clients/inventory/inventory.go b/cluster/types/v1beta3/clients/inventory/inventory.go index 9b9c1291..ca0fe784 100644 --- a/cluster/types/v1beta3/clients/inventory/inventory.go +++ b/cluster/types/v1beta3/clients/inventory/inventory.go @@ -574,32 +574,32 @@ func (inv *inventory) Metrics() inventoryV1.Metrics { invNode := inventoryV1.NodeMetrics{ Name: nd.Name, Allocatable: inventoryV1.ResourcesMetric{ - CPU: uint64(nd.Resources.CPU.Quantity.Allocatable.MilliValue()), - GPU: uint64(nd.Resources.GPU.Quantity.Allocatable.Value()), - Memory: uint64(nd.Resources.Memory.Quantity.Allocatable.Value()), - StorageEphemeral: uint64(nd.Resources.EphemeralStorage.Allocatable.Value()), + CPU: uint64(nd.Resources.CPU.Quantity.Allocatable.MilliValue()), // nolint: gosec + GPU: uint64(nd.Resources.GPU.Quantity.Allocatable.Value()), // nolint: gosec + Memory: uint64(nd.Resources.Memory.Quantity.Allocatable.Value()), // nolint: gosec + StorageEphemeral: uint64(nd.Resources.EphemeralStorage.Allocatable.Value()), // nolint: gosec }, } - cpuTotal += uint64(nd.Resources.CPU.Quantity.Allocatable.MilliValue()) - gpuTotal += uint64(nd.Resources.GPU.Quantity.Allocatable.Value()) - memoryTotal += uint64(nd.Resources.Memory.Quantity.Allocatable.Value()) - storageEphemeralTotal += uint64(nd.Resources.EphemeralStorage.Allocatable.Value()) + cpuTotal += uint64(nd.Resources.CPU.Quantity.Allocatable.MilliValue()) // nolint: gosec + gpuTotal += uint64(nd.Resources.GPU.Quantity.Allocatable.Value()) // nolint: gosec + memoryTotal += uint64(nd.Resources.Memory.Quantity.Allocatable.Value()) // nolint: gosec + storageEphemeralTotal += uint64(nd.Resources.EphemeralStorage.Allocatable.Value()) // nolint: gosec avail := nd.Resources.CPU.Quantity.Available() - invNode.Available.CPU = uint64(avail.MilliValue()) + invNode.Available.CPU = uint64(avail.MilliValue()) // nolint: gosec cpuAvailable += invNode.Available.CPU avail = nd.Resources.GPU.Quantity.Available() - invNode.Available.GPU = uint64(avail.Value()) + invNode.Available.GPU = uint64(avail.Value()) // nolint: gosec gpuAvailable += invNode.Available.GPU avail = nd.Resources.Memory.Quantity.Available() - invNode.Available.Memory = uint64(avail.Value()) + invNode.Available.Memory = uint64(avail.Value()) // nolint: gosec memoryAvailable += invNode.Available.Memory avail = nd.Resources.EphemeralStorage.Available() - invNode.Available.StorageEphemeral = uint64(avail.Value()) + invNode.Available.StorageEphemeral = uint64(avail.Value()) // nolint: gosec storageEphemeralAvailable += invNode.Available.StorageEphemeral ret.Nodes = append(ret.Nodes, invNode) diff --git a/gateway/rest/router_test.go b/gateway/rest/router_test.go index 5e9cc8f2..bba77fe5 100644 --- a/gateway/rest/router_test.go +++ b/gateway/rest/router_test.go @@ -127,7 +127,7 @@ func testCertHelper(t *testing.T, test *routerTest) { mock.AnythingOfType("v2beta2.Manifest"), ).Return(nil) - dseq := uint64(testutil.RandRangeInt(1, 1000)) + dseq := uint64(testutil.RandRangeInt(1, 1000)) // nolint: gosec uri, err := makeURI(test.host, submitManifestPath(dseq)) require.NoError(t, err) @@ -538,7 +538,7 @@ func TestRouteValidateFailsEmptyBody(t *testing.T) { func TestRoutePutManifestOK(t *testing.T) { runRouterTest(t, true, func(test *routerTest) { - dseq := uint64(testutil.RandRangeInt(1, 1000)) + dseq := uint64(testutil.RandRangeInt(1, 1000)) // nolint: gosec test.pmclient.On( "Submit", mock.Anything, @@ -580,7 +580,7 @@ func TestRoutePutManifestOK(t *testing.T) { func TestRoutePutInvalidManifest(t *testing.T) { _ = dtypes.DeploymentID{} runRouterTest(t, true, func(test *routerTest) { - dseq := uint64(testutil.RandRangeInt(1, 1000)) + dseq := uint64(testutil.RandRangeInt(1, 1000)) // nolint: gosec test.pmclient.On("Submit", mock.Anything, dtypes.DeploymentID{ @@ -787,9 +787,9 @@ func TestRouteLeaseStatusErr(t *testing.T) { func TestRouteServiceStatusOK(t *testing.T) { runRouterTest(t, true, func(test *routerTest) { - dseq := uint64(testutil.RandRangeInt(1, 1000)) - oseq := uint32(testutil.RandRangeInt(2000, 3000)) - gseq := uint32(testutil.RandRangeInt(4000, 5000)) + dseq := uint64(testutil.RandRangeInt(1, 1000)) // nolint: gosec + oseq := uint32(testutil.RandRangeInt(2000, 3000)) // nolint: gosec + gseq := uint32(testutil.RandRangeInt(4000, 5000)) // nolint: gosec status := &clustertypes.ServiceStatus{ Name: "", @@ -839,9 +839,9 @@ func TestRouteServiceStatusOK(t *testing.T) { func TestRouteServiceStatusNoDeployment(t *testing.T) { runRouterTest(t, true, func(test *routerTest) { - dseq := uint64(testutil.RandRangeInt(1, 1000)) - oseq := uint32(testutil.RandRangeInt(2000, 3000)) - gseq := uint32(testutil.RandRangeInt(4000, 5000)) + dseq := uint64(testutil.RandRangeInt(1, 1000)) // nolint: gosec + oseq := uint32(testutil.RandRangeInt(2000, 3000)) // nolint: gosec + gseq := uint32(testutil.RandRangeInt(4000, 5000)) // nolint: gosec test.pcclient.On("ServiceStatus", mock.Anything, types.LeaseID{ Owner: test.caddr.String(), @@ -879,9 +879,9 @@ func TestRouteServiceStatusNoDeployment(t *testing.T) { func TestRouteServiceStatusKubernetesNotFound(t *testing.T) { runRouterTest(t, true, func(test *routerTest) { - dseq := uint64(testutil.RandRangeInt(1, 1000)) - oseq := uint32(testutil.RandRangeInt(2000, 3000)) - gseq := uint32(testutil.RandRangeInt(4000, 5000)) + dseq := uint64(testutil.RandRangeInt(1, 1000)) // nolint: gosec + oseq := uint32(testutil.RandRangeInt(2000, 3000)) // nolint: gosec + gseq := uint32(testutil.RandRangeInt(4000, 5000)) // nolint: gosec kubeStatus := fakeKubernetesStatusError{ status: metav1.Status{ @@ -931,9 +931,9 @@ func TestRouteServiceStatusKubernetesNotFound(t *testing.T) { func TestRouteServiceStatusError(t *testing.T) { runRouterTest(t, true, func(test *routerTest) { - dseq := uint64(testutil.RandRangeInt(1, 1000)) - oseq := uint32(testutil.RandRangeInt(2000, 3000)) - gseq := uint32(testutil.RandRangeInt(4000, 5000)) + dseq := uint64(testutil.RandRangeInt(1, 1000)) // nolint: gosec + oseq := uint32(testutil.RandRangeInt(2000, 3000)) // nolint: gosec + gseq := uint32(testutil.RandRangeInt(4000, 5000)) // nolint: gosec test.pcclient.On("ServiceStatus", mock.Anything, types.LeaseID{ Owner: test.caddr.String(), diff --git a/make/init.mk b/make/init.mk index 99f90f0c..99eaa6b3 100644 --- a/make/init.mk +++ b/make/init.mk @@ -87,7 +87,7 @@ AKASHD_SRC_IS_LOCAL := $(shell $(ROOT_DIR)/script/is_local_gomod.sh "$( AKASHD_LOCAL_PATH := $(shell $(GO) list -mod=readonly -m -f '{{ .Dir }}' "$(AKASHD_MODULE)") AKASHD_VERSION := $(shell $(GO) list -mod=readonly -m -f '{{ .Version }}' $(AKASHD_MODULE) | cut -c2-) GRPC_GATEWAY_VERSION := $(shell $(GO) list -mod=readonly -m -f '{{ .Version }}' github.com/grpc-ecosystem/grpc-gateway) -GOLANGCI_LINT_VERSION ?= v1.59.1 +GOLANGCI_LINT_VERSION ?= v1.62.2 STATIK_VERSION ?= v0.1.7 GIT_CHGLOG_VERSION ?= v0.15.1 MOCKERY_PACKAGE_NAME := github.com/vektra/mockery/v2 diff --git a/manifest/service.go b/manifest/service.go index 4bb235ec..13fe5196 100644 --- a/manifest/service.go +++ b/manifest/service.go @@ -300,10 +300,10 @@ loop: trySignal() case ch := <-s.statusch: ch <- &Status{ - Deployments: uint32(len(s.managers)), + Deployments: uint32(len(s.managers)), // nolint: gosec } case <-signalch: - bus.Pub(provider.ManifestStatus{Deployments: uint32(len(s.managers))}, []string{ptypes.PubSubTopicManifestStatus}, tpubsub.WithRetain()) + bus.Pub(provider.ManifestStatus{Deployments: uint32(len(s.managers))}, []string{ptypes.PubSubTopicManifestStatus}, tpubsub.WithRetain()) // nolint: gosec case manager := <-s.managerch: s.session.Log().Info("manager done", "deployment", manager.daddr) diff --git a/operator/common/ignore_list.go b/operator/common/ignore_list.go index f0595c6d..de659d95 100644 --- a/operator/common/ignore_list.go +++ b/operator/common/ignore_list.go @@ -131,7 +131,7 @@ func (il *ignoreList) Prune() bool { deleted := false // do not let the ignore list grow unbounded, it would eventually // consume 100% of available memory otherwise - if len(il.entries) > int(il.cfg.EntryLimit) { + if len(il.entries) > int(il.cfg.EntryLimit) { // nolint: gosec var toDelete []mtypes.LeaseID for leaseID, entry := range il.entries { @@ -149,7 +149,7 @@ func (il *ignoreList) Prune() bool { // if enough entries have not been selected for deletion then just remove entries // until we get to enough removed for leaseID := range il.entries { - if len(il.entries)-len(toDelete) <= int(il.cfg.EntryLimit) { + if len(il.entries)-len(toDelete) <= int(il.cfg.EntryLimit) { // nolint: gosec break } toDelete = append(toDelete, leaseID) diff --git a/operator/common/ignore_list_test.go b/operator/common/ignore_list_test.go index 5d9d19cd..073beafc 100644 --- a/operator/common/ignore_list_test.go +++ b/operator/common/ignore_list_test.go @@ -3,11 +3,12 @@ package common import ( "bytes" "encoding/json" - "github.com/akash-network/node/testutil" - "github.com/stretchr/testify/require" "io" "testing" "time" + + "github.com/akash-network/node/testutil" + "github.com/stretchr/testify/require" ) func TestIgnoreList(t *testing.T) { @@ -48,7 +49,7 @@ func TestIgnoreList(t *testing.T) { } func TestIgnoreListFailureLimit(t *testing.T) { - failureLimit := uint(testutil.RandRangeInt(3, 10)) + failureLimit := uint(testutil.RandRangeInt(3, 10)) // nolint: gosec il := NewIgnoreList(IgnoreListConfig{ FailureLimit: failureLimit, EntryLimit: 100, diff --git a/operator/common/operator_flags.go b/operator/common/operator_flags.go index e73f2e83..3fccf3c3 100644 --- a/operator/common/operator_flags.go +++ b/operator/common/operator_flags.go @@ -86,7 +86,7 @@ func DetectPort(ctx context.Context, flags *flag.FlagSet, flag string, container if scontainer.Name == container { for _, cport := range scontainer.Ports { if cport.Name == portName { - port = uint16(cport.ContainerPort) + port = uint16(cport.ContainerPort) // nolint: gosec break loop } } diff --git a/operator/hostname/operator.go b/operator/hostname/operator.go index d299d726..c7d4e563 100644 --- a/operator/hostname/operator.go +++ b/operator/hostname/operator.go @@ -135,7 +135,7 @@ func (op *hostnameOperator) monitorUntilError() error { lastEvent: nil, presentLease: leaseID, presentServiceName: conn.GetServiceName(), - presentExternalPort: uint32(conn.GetExternalPort()), + presentExternalPort: uint32(conn.GetExternalPort()), // nolint: gosec } op.hostnames[hostname] = entry @@ -312,7 +312,7 @@ func buildDirective(ev chostname.ResourceEvent, serviceExpose crd.ManifestServic Hostname: ev.GetHostname(), LeaseID: ev.GetLeaseID(), ServiceName: ev.GetServiceName(), - ServicePort: int32(ev.GetExternalPort()), + ServicePort: int32(ev.GetExternalPort()), // nolint: gosec } /* Populate the configuration options @@ -377,7 +377,7 @@ func (op *hostnameOperator) locateServiceFromManifest(ctx context.Context, lease ExternalPort: uint32(expose.ExternalPort), } - if externalPort == uint32(mse.GetExternalPort()) { + if externalPort == uint32(mse.GetExternalPort()) { // nolint: gosec selectedExpose = expose break } diff --git a/operator/inventory/ceph.go b/operator/inventory/ceph.go index 3ef8f1e6..81d3f7fe 100644 --- a/operator/inventory/ceph.go +++ b/operator/inventory/ceph.go @@ -361,7 +361,7 @@ func (c *ceph) run(startch chan<- struct{}) error { result = append(result, inventory.Storage{ Quantity: inventory.ResourcePair{ Allocated: &allocated, - Allocatable: resource.NewQuantity(int64(pool.Stats.MaxAvail), resource.DecimalSI), + Allocatable: resource.NewQuantity(int64(pool.Stats.MaxAvail), resource.DecimalSI), // nolint: gosec }, Info: inventory.StorageInfo{ Class: class, diff --git a/operator/inventory/rancher.go b/operator/inventory/rancher.go index 71be0511..aefe6d39 100644 --- a/operator/inventory/rancher.go +++ b/operator/inventory/rancher.go @@ -154,7 +154,7 @@ func (c *rancher) run(startch chan<- struct{}) error { if _, exists = pvMap[obj.Name]; !exists { pvMap[obj.Name] = *obj - params.allocated += uint64(res.Value()) + params.allocated += uint64(res.Value()) // nolint: gosec } case watch.Deleted: res, exists := obj.Spec.Capacity[corev1.ResourceStorage] @@ -163,7 +163,7 @@ func (c *rancher) run(startch chan<- struct{}) error { } delete(pvMap, obj.Name) - scs[obj.Spec.StorageClassName].allocated -= uint64(res.Value()) + scs[obj.Spec.StorageClassName].allocated -= uint64(res.Value()) // nolint: gosec } tryScrape() @@ -223,7 +223,7 @@ func (c *rancher) run(startch chan<- struct{}) error { } params := scs[pv.Spec.StorageClassName] - params.allocated += uint64(capacity.Value()) + params.allocated += uint64(capacity.Value()) // nolint: gosec pvMap[pv.Name] = pv } @@ -248,7 +248,7 @@ func (c *rancher) run(startch chan<- struct{}) error { for class, params := range scs { if params.isRancher && params.isAkashManaged { res = append(res, inventory.Storage{ - Quantity: inventory.NewResourcePair(allocatable, int64(params.allocated), resource.DecimalSI), + Quantity: inventory.NewResourcePair(allocatable, int64(params.allocated), resource.DecimalSI), // nolint: gosec Info: inventory.StorageInfo{ Class: class, }, diff --git a/operator/ip/operator_test.go b/operator/ip/operator_test.go index 9ed662ce..bc615bc4 100644 --- a/operator/ip/operator_test.go +++ b/operator/ip/operator_test.go @@ -250,7 +250,7 @@ func TestIPOperatorGivesUpOnErrors(t *testing.T) { ExternalPort: 10001, SharingKey: "akey", Protocol: "TCP", - }).Return(fakeError).Times(int(s.ilc.FailureLimit)) + }).Return(fakeError).Times(int(s.ilc.FailureLimit)) // nolint: gosec require.Greater(t, s.ilc.FailureLimit, uint(0)) diff --git a/operator/ip/types.go b/operator/ip/types.go index 98ea1432..650aee66 100644 --- a/operator/ip/types.go +++ b/operator/ip/types.go @@ -63,8 +63,8 @@ func (b *barrier) waitUntilClear(ctx context.Context) error { for { select { case <-ticker.C: - clear := 0 == atomic.LoadInt32(&b.active) - if clear { + isClear := 0 == atomic.LoadInt32(&b.active) + if isClear { return nil } case <-ctx.Done(): diff --git a/pkg/apis/akash.network/v2beta1/types.go b/pkg/apis/akash.network/v2beta1/types.go index fcbd2910..1a9fce54 100644 --- a/pkg/apis/akash.network/v2beta1/types.go +++ b/pkg/apis/akash.network/v2beta1/types.go @@ -358,8 +358,8 @@ func (mse ManifestServiceExpose) DetermineExposedExternalPort() uint16 { func manifestServiceExposeFromAkash(amse maniv2beta1.ServiceExpose) ManifestServiceExpose { return ManifestServiceExpose{ - Port: uint16(amse.Port), - ExternalPort: uint16(amse.ExternalPort), + Port: uint16(amse.Port), // nolint: gosec + ExternalPort: uint16(amse.ExternalPort), // nolint: gosec Proto: amse.Proto.ToString(), Service: amse.Service, Global: amse.Global, @@ -425,7 +425,7 @@ func resourceUnitsFromAkash(aru types.ResourceUnits) (ResourceUnits, error) { if aru.CPU.Units.Value() > math.MaxUint32 { return ResourceUnits{}, errors.New("k8s api: cpu units value overflows uint32") } - res.CPU = uint32(aru.CPU.Units.Value()) + res.CPU = uint32(aru.CPU.Units.Value()) // nolint: gosec } if aru.Memory != nil { res.Memory = strconv.FormatUint(aru.Memory.Quantity.Value(), 10) diff --git a/pkg/apis/akash.network/v2beta2/manifest.go b/pkg/apis/akash.network/v2beta2/manifest.go index b08c6a4e..059ab56f 100644 --- a/pkg/apis/akash.network/v2beta2/manifest.go +++ b/pkg/apis/akash.network/v2beta2/manifest.go @@ -357,8 +357,8 @@ func (mse ManifestServiceExpose) DetermineExposedExternalPort() uint16 { func manifestServiceExposeFromAkash(amse mani.ServiceExpose) ManifestServiceExpose { return ManifestServiceExpose{ - Port: uint16(amse.Port), - ExternalPort: uint16(amse.ExternalPort), + Port: uint16(amse.Port), // nolint: gosec + ExternalPort: uint16(amse.ExternalPort), // nolint: gosec Proto: amse.Proto.ToString(), Service: amse.Service, Global: amse.Global, diff --git a/pkg/apis/akash.network/v2beta2/types.go b/pkg/apis/akash.network/v2beta2/types.go index 41ca22ef..7ddfeb2a 100644 --- a/pkg/apis/akash.network/v2beta2/types.go +++ b/pkg/apis/akash.network/v2beta2/types.go @@ -180,7 +180,7 @@ func resourcesFromAkash(aru types.Resources) (Resources, error) { if aru.CPU.Units.Value() > math.MaxUint32 { return Resources{}, errors.New("k8s api: cpu units value overflows uint32") } - res.CPU.Units = uint32(aru.CPU.Units.Value()) + res.CPU.Units = uint32(aru.CPU.Units.Value()) // nolint: gosec res.CPU.Attributes = aru.CPU.Attributes.Dup() } @@ -193,7 +193,7 @@ func resourcesFromAkash(aru types.Resources) (Resources, error) { if aru.GPU.Units.Value() > math.MaxUint32 { return Resources{}, errors.New("k8s api: gpu units value overflows uint32") } - res.GPU.Units = uint32(aru.GPU.Units.Value()) + res.GPU.Units = uint32(aru.GPU.Units.Value()) // nolint: gosec res.GPU.Attributes = aru.GPU.Attributes }