Uploaded image for project: 'Bamboo'
  1. Bamboo
  2. BAM-20889

Programmatically removing branch from 3rd party plugin, can remove stages and jobs from master plan.

    XMLWordPrintable

Details

    Description

      Issue Summary

      If deletion service is called using immutable representation of a plan branch, the stages of the master plan are marked for deletion, which is incorrect.

      Important: This problem only happens if plan branches are removed programmatically, by a plugin. Users using built-in Bamboo functionality are not affected.

      Steps to Reproduce

      1. Install plugin that calls deletionService.deletePlan(ImmutablePlan plan). Argument must not be of type ImmutablePlanBranchImpl (must be really immutable branch). (For instance: https://github.com/mibexsoftware/plan-branch-terminator)
      2. Do whatever is required for a plugin to be triggered (in case of plan-branch-terminator, it's removing branch from Bitbucket Server)
      3. Wait for the deletion service to run.

      Expected Results

      Branch is removed. Master plan and other branches are intact.

      Actual Results

      Message like this can be seen in the logs and afterwards stages and jobs of the master plan are removed

      2020-04-06 09:03:23,076 INFO [DelayedDeletionThread] [PlanHibernateDao] 4 jobs have incorrectly set deletion flags, updating them
      

      Workaround

      • disable the plugin until the bug is fixed
      •  modify the plugin it so that it doesn't call deletionsService using 'ImmutablePlanBranch'. Use mutable object instead, like this:
      PlanManager planManager; //not cachedPlanManager!
      
      //......
      private void deleteMutableRepresentationOfBranch(final ImmutableChainBranch chainBranch) {
       final Plan mutableBranch = planManager.getPlanById(chainBranch.getId());
       if (mutableBranch != null) {
       try {
       deletionService.deletePlan(mutableBranch);
       } catch (final RuntimeException e) {
       log.warn("Unable to delete chain branch " + chainBranch.getPlanKey(), e);
       }
       }
      }

      Attachments

        Issue Links

          Activity

            People

              mgardias Marcin Gardias
              mgardias Marcin Gardias
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: