mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #84763 from hwdef/fix-staticcheck6
pkg/controller: fix staticcheck warning
This commit is contained in:
commit
06a7e9a1f3
@ -435,7 +435,7 @@ func TestDeploymentController_cleanupDeployment(t *testing.T) {
|
||||
|
||||
gotDeletions := 0
|
||||
for _, action := range fake.Actions() {
|
||||
if "delete" == action.GetVerb() {
|
||||
if action.GetVerb() == "delete" {
|
||||
gotDeletions++
|
||||
}
|
||||
}
|
||||
|
@ -714,7 +714,7 @@ func (dc *DisruptionController) buildDisruptedPodMap(pods []*v1.Pod, pdb *policy
|
||||
result := make(map[string]metav1.Time)
|
||||
var recheckTime *time.Time
|
||||
|
||||
if disruptedPods == nil || len(disruptedPods) == 0 {
|
||||
if disruptedPods == nil {
|
||||
return result, recheckTime
|
||||
}
|
||||
for _, pod := range pods {
|
||||
|
@ -69,8 +69,7 @@ func (s endpointSet) Has(item *discovery.Endpoint) bool {
|
||||
|
||||
// Returns an endpoint matching the hash if contained in the set.
|
||||
func (s endpointSet) Get(item *discovery.Endpoint) *discovery.Endpoint {
|
||||
got, _ := s[hashEndpoint(item)]
|
||||
return got
|
||||
return s[hashEndpoint(item)]
|
||||
}
|
||||
|
||||
// UnsortedList returns the slice with contents in random order.
|
||||
|
@ -66,7 +66,6 @@ type GarbageCollector struct {
|
||||
dependencyGraphBuilder *GraphBuilder
|
||||
// GC caches the owners that do not exist according to the API server.
|
||||
absentOwnerCache *UIDCache
|
||||
sharedInformers controller.InformerFactory
|
||||
|
||||
workerLock sync.RWMutex
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ func (n *node) markObserved() {
|
||||
func (n *node) isObserved() bool {
|
||||
n.virtualLock.RLock()
|
||||
defer n.virtualLock.RUnlock()
|
||||
return n.virtual == false
|
||||
return !n.virtual
|
||||
}
|
||||
|
||||
func (n *node) markDeletingDependents() {
|
||||
|
@ -138,7 +138,7 @@ func (d *namespacedResourcesDeleter) Delete(nsName string) error {
|
||||
}
|
||||
|
||||
// we have removed content, so mark it finalized by us
|
||||
namespace, err = d.retryOnConflictError(namespace, d.finalizeNamespace)
|
||||
_, err = d.retryOnConflictError(namespace, d.finalizeNamespace)
|
||||
if err != nil {
|
||||
// in normal practice, this should not be possible, but if a deployment is running
|
||||
// two controllers to do namespace deletion that share a common finalizer token it's
|
||||
@ -188,20 +188,6 @@ func (d *namespacedResourcesDeleter) initOpCache() {
|
||||
}
|
||||
}
|
||||
|
||||
// Deletes the given namespace.
|
||||
func (d *namespacedResourcesDeleter) deleteNamespace(namespace *v1.Namespace) error {
|
||||
var opts *metav1.DeleteOptions
|
||||
uid := namespace.UID
|
||||
if len(uid) > 0 {
|
||||
opts = &metav1.DeleteOptions{Preconditions: &metav1.Preconditions{UID: &uid}}
|
||||
}
|
||||
err := d.nsClient.Delete(namespace.Name, opts)
|
||||
if err != nil && !errors.IsNotFound(err) {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ResourcesRemainingError is used to inform the caller that all resources are not yet fully removed from the namespace.
|
||||
type ResourcesRemainingError struct {
|
||||
Estimate int64
|
||||
|
@ -82,7 +82,7 @@ func TestFinalizeNamespaceFunc(t *testing.T) {
|
||||
if len(finalizers) != 1 {
|
||||
t.Errorf("There should be a single finalizer remaining")
|
||||
}
|
||||
if "other" != string(finalizers[0]) {
|
||||
if string(finalizers[0]) != "other" {
|
||||
t.Errorf("Unexpected finalizer value, %v", finalizers[0])
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user