Uploaded image for project: 'Red Hat Advanced Cluster Security'
  1. Red Hat Advanced Cluster Security
  2. ROX-32844

Policy store has potential connection leak

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Normal Normal
    • 4.10.0, 4.9.4, 4.8.9
    • None
    • None
    • None
    • False
    • Hide

      None

      Show
      None
    • False
    • Rox Sprint 4.10H

      Policy datastore has a potential connection leak in one error case.  If findPolicyWithSameName returns an error then the transaction could be stuck forever.

      ctx, tx, err := ds.storage.Begin(ctx)
      if err != nil {
          return "", err
      }
      
      policyNameToPolicyMap := make(map[string]*storage.Policy, len(allPolicies))
      for _, policy := range allPolicies {
          policyNameToPolicyMap[policy.GetName()] = policy
      }
      
      if findPolicyWithSameName(policyNameToPolicyMap, policy.GetName()) != nil {
          return "", fmt.Errorf("Could not add policy due to name validation, policy with name %s already exists", policy.GetName())
      }
      policyutils.FillSortHelperFields(policy)
      // Any policy added after startup must be marked custom policy.
      markPoliciesAsCustom(policy)
      
      // Stash away the category names, since they need to be erased on storage. But the policy insert must happen first,
      // to get an ID, to satisfy foreign key constraints when policy category edges are added.
      policyCategories := policy.GetCategories() 

              rh-ee-dashrews David Shrewsberry
              rh-ee-dashrews David Shrewsberry
              David Shrewsberry
              ACS Core Workflows
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: