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

Revert "Revert "[ART-7056] deprecate placeholder bug"" #204

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
9 changes: 1 addition & 8 deletions elliott/elliottlib/bzutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,10 +391,7 @@ def creation_time_parsed(self):
return datetime.strptime(str(self.bug.fields.created), '%Y-%m-%dT%H:%M:%S.%f%z')

def is_ocp_bug(self):
return self.bug.fields.project.key == "OCPBUGS" and not self.is_placeholder_bug()

def is_placeholder_bug(self):
return ('Placeholder' in self.summary) and (self.component == 'Release') and ('Automation' in self.keywords)
return self.bug.fields.project.key == "OCPBUGS"

def _get_blocks(self):
# link "blocks"
Expand Down Expand Up @@ -478,10 +475,6 @@ def advisory_bug_ids(advisory_obj):
def id_convert(id_string):
raise NotImplementedError

def create_placeholder(self, kind, noop=False):
title = f"Placeholder bug for OCP {self.config.get('target_release')[0]} {kind} release"
return self.create_bug(title, title, "VERIFIED", ["Automation"], noop)

def create_textonly(self, bug_title, bug_description, noop=False):
return self.create_bug(bug_title, bug_description, "VERIFIED", [], noop)

Expand Down
2 changes: 0 additions & 2 deletions elliott/elliottlib/cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
from elliottlib.cli.find_bugs_sweep_cli import find_bugs_sweep_cli
from elliottlib.cli.create_cli import create_cli
from elliottlib.cli.add_metadata_cli import add_metadata_cli
from elliottlib.cli.create_placeholder_cli import create_placeholder_cli
from elliottlib.cli.change_state_cli import change_state_cli
from elliottlib.cli.puddle_advisories_cli import puddle_advisories_cli
from elliottlib.cli.rpmdiff_cli import rpmdiff_cli
Expand Down Expand Up @@ -456,7 +455,6 @@ def poll_signed(runtime, minutes, advisory, default_advisory_type, noop):
cli.add_command(add_metadata_cli)
cli.add_command(advisory_images_cli)
cli.add_command(advisory_impetus_cli)
cli.add_command(create_placeholder_cli)
cli.add_command(create_cli)
cli.add_command(change_state_cli)
cli.add_command(find_bugs_sweep_cli)
Expand Down
10 changes: 1 addition & 9 deletions elliott/elliottlib/cli/create_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from elliottlib.bzutil import BugzillaBugTracker
from elliottlib.cli.common import cli
from elliottlib.cli.add_metadata_cli import add_metadata_cli
from elliottlib.cli.create_placeholder_cli import create_placeholder_cli
from elliottlib.exectools import cmd_assert
from elliottlib.exceptions import ElliottFatalError
from elliottlib.util import YMD, validate_release_date, \
Expand Down Expand Up @@ -43,9 +42,6 @@
envvar="ELLIOTT_PACKAGE_OWNER_EMAIL",
callback=validate_email_address,
help="The email address of the person responsible managing the advisory.")
@click.option('--with-placeholder', is_flag=True,
default=False, type=bool,
help="Create a placeholder bug and attach it to the advisory. Only valid if also using --yes.")
@click.option('--with-liveid', is_flag=True,
default=True, type=bool,
help="Request a Live ID for the advisory. Only valid if also using --yes.")
Expand All @@ -56,7 +52,7 @@
help="Bug IDs for attaching to the advisory on creation. Required for creating a security advisory.")
@click.pass_obj
@click.pass_context
def create_cli(ctx, runtime, errata_type, kind, impetus, art_advisory_key, date, assigned_to, manager, package_owner, with_placeholder, with_liveid, yes, bugs):
def create_cli(ctx, runtime, errata_type, kind, impetus, art_advisory_key, date, assigned_to, manager, package_owner, with_liveid, yes, bugs):
"""Create a new advisory. The kind of advisory must be specified with
'--kind'. Valid choices are 'rpm' and 'image'.

Expand Down Expand Up @@ -151,10 +147,6 @@ def create_cli(ctx, runtime, errata_type, kind, impetus, art_advisory_key, date,
ctx.invoke(add_metadata_cli, kind=kind, impetus=impetus, advisory=erratum.errata_id)
click.echo(str(erratum))

if with_placeholder:
click.echo("Creating and attaching placeholder bug...")
ctx.invoke(create_placeholder_cli, kind=kind, advisory=erratum.errata_id)

if with_liveid:
click.echo("Requesting Live ID...")
base_url = "https://errata.devel.redhat.com/errata/set_live_advisory_name"
Expand Down
67 changes: 0 additions & 67 deletions elliott/elliottlib/cli/create_placeholder_cli.py

This file was deleted.

4 changes: 0 additions & 4 deletions elliott/elliottlib/cli/create_textonly_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,6 @@ def create_textonly(runtime, errata_type, date, assigned_to, manager, package_ow
erratum.commit()
green_prefix("Created new text only advisory: ")
click.echo(str(erratum))
bug = bug_tracker.create_textonly(bug_title, bug_description)
click.echo(f"Created placeholder bug: {bug.id} {bug.webur}")
click.echo("Attaching placeholder bug...")
bug_tracker.attach_bugs([bug.id], advisory_obj=erratum)
else:
green_prefix("Would have created advisory: ")
click.echo("")
Expand Down
26 changes: 8 additions & 18 deletions elliott/elliottlib/cli/repair_bugs_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,13 @@
@click.option("--comment", "comment",
required=False,
help="Add comment to bug")
@click.option("--close-placeholder", "close_placeholder",
required=False,
default=False, is_flag=True,
help="When checking bug state, close the bug if it's a placehoder bug.")
@click.option("--noop", "--dry-run",
required=False,
default=False, is_flag=True,
help="Check bugs attached, print what would change, but don't change anything")
@use_default_advisory_option
@click.pass_obj
def repair_bugs_cli(runtime, advisory_id, auto, id, original_state, new_state, comment, close_placeholder, noop,
def repair_bugs_cli(runtime, advisory_id, auto, id, original_state, new_state, comment, noop,
default_advisory_type):
"""Move bugs attached to the advisory from one state to another
state. This is useful if the bugs have changed states *after* they
Expand Down Expand Up @@ -113,14 +109,14 @@ def repair_bugs_cli(runtime, advisory_id, auto, id, original_state, new_state, c
jira_ids, bz_ids = get_jira_bz_bug_ids(id)

if jira_ids:
repair_bugs(jira_ids, original_state, new_state, comment, close_placeholder, noop,
repair_bugs(jira_ids, original_state, new_state, comment, noop,
runtime.get_bug_tracker('jira'))
if bz_ids:
repair_bugs(bz_ids, original_state, new_state, comment, close_placeholder, noop,
repair_bugs(bz_ids, original_state, new_state, comment, noop,
runtime.get_bug_tracker('bugzilla'))


def repair_bugs(bug_ids, original_state, new_state, comment, close_placeholder, noop, bug_tracker: BugTracker):
def repair_bugs(bug_ids, original_state, new_state, comment, noop, bug_tracker: BugTracker):
changed_bug_count = 0

# Fetch bugs in parallel because it can be really slow doing it
Expand All @@ -140,16 +136,10 @@ def repair_bugs(bug_ids, original_state, new_state, comment, close_placeholder,
click.echo(']')

for bug in attached_bugs:
if close_placeholder and "Placeholder" in bug.summary:
# if set close placeholder, ignore bug state
bug_tracker.update_bug_status(bug, "CLOSED")
if bug.status in original_state:
bug_tracker.update_bug_status(bug, new_state)
if comment and not noop:
bug_tracker.add_comment(bug, comment, private=False)
changed_bug_count += 1
else:
if bug.status in original_state:
bug_tracker.update_bug_status(bug, new_state)
# only add comments for non-placeholder bug
if comment and not noop:
bug_tracker.add_comment(bug, comment, private=False)
changed_bug_count += 1

green_print("{} bugs successfully modified (or would have been)".format(changed_bug_count))
3 changes: 1 addition & 2 deletions elliott/elliottlib/cli/verify_attached_bugs_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ async def verify_attached_bugs(runtime: Runtime, verify_bug_status: bool, adviso
advisory_bug_map = validator.get_attached_bugs(list(advisory_id_map.values()))
bugs = {b for bugs in advisory_bug_map.values() for b in bugs}

# bug.is_ocp_bug() filters by product/project, so we don't get flaw bugs or bugs of other products or
# placeholder
# bug.is_ocp_bug() filters by product/project, so we don't get flaw bugs or bugs of other products
non_flaw_bugs = [b for b in bugs if b.is_ocp_bug()]

validator.validate(non_flaw_bugs, verify_bug_status, no_verify_blocking_bugs)
Expand Down
1 change: 0 additions & 1 deletion elliott/functional_tests/test_verify_attached_bugs.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ def test_get_and_verify_blocking_bugs(self):
self.assertTrue(any(bug.id == 1875259 for bug in bbf(1875258)), "1875259 blocks 1875258")
self.assertTrue(bbf(1878798), "regular bug with blocking bug")
self.assertTrue(any(bug.id == 1872337 for bug in bbf(1878798)), "1872337 blocks 1878798")
self.assertFalse(bbf(1881212), "placeholder bug w/o blocking")
self.assertTrue(bbf(1869790), "bug with several blocking bugs, one DUPLICATE")
self.assertTrue(any(bug.id == 1868735 for bug in bbf(1869790)), "DUPLICATE 1868735 blocks 1869790")
self.assertTrue(all(bug.id != 1868158 for bug in bbf(1869790)), "4.6 1868158 blocks 1869790")
Expand Down
20 changes: 0 additions & 20 deletions elliott/tests/test_bzutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,31 +111,11 @@ def test_depends_on(self):
flexmock(JIRABug).should_receive("blocked_by_bz").and_return('bar')
self.assertEqual(JIRABug(bug).depends_on, ['foo', 'bar'])

def test_is_placeholder_bug(self):
bug1 = flexmock(key='OCPBUGS-1',
fields=flexmock(
summary='Placeholder',
components=[flexmock(name='Release')],
labels=['Automation']))
self.assertEqual(JIRABug(bug1).is_placeholder_bug(), True)

bug2 = flexmock(key='OCPBUGS-2',
fields=flexmock(
summary='Placeholder',
components=[flexmock(name='Foo')],
labels=['Bar']))
self.assertEqual(JIRABug(bug2).is_placeholder_bug(), False)

def test_is_ocp_bug(self):
bug1 = flexmock(key='OCPBUGS-1', fields=flexmock(project=flexmock(key='foo')))
self.assertEqual(JIRABug(bug1).is_ocp_bug(), False)

bug2 = flexmock(key='OCPBUGS-1', fields=flexmock(project=flexmock(key='OCPBUGS')))
flexmock(JIRABug).should_receive("is_placeholder_bug").and_return(True)
self.assertEqual(JIRABug(bug2).is_ocp_bug(), False)

bug2 = flexmock(key='OCPBUGS-1', fields=flexmock(project=flexmock(key='OCPBUGS')))
flexmock(JIRABug).should_receive("is_placeholder_bug").and_return(False)
self.assertEqual(JIRABug(bug2).is_ocp_bug(), True)

def test_is_tracker_bug(self):
Expand Down
17 changes: 0 additions & 17 deletions elliott/tests/test_repair_bugs_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,6 @@ def test_repair_bugs(self):
'ON_QA', '-a', '99999'])
self.assertEqual(result.exit_code, 0)

def test_repair_placeholder_jira_bug(self):
runner = CliRunner()
bug = flexmock(id="OCPBUGS-1", status="MODIFIED", summary="Placeholder")
flexmock(Runtime).should_receive("initialize")
flexmock(JIRABugTracker).should_receive("get_config").and_return({'target_release': ['4.6.z']})
flexmock(JIRABugTracker).should_receive("login")
flexmock(JIRABugTracker).should_receive("get_bug").with_args("OCPBUGS-1").and_return(bug)
flexmock(JIRABugTracker).should_receive("update_bug_status").once()
result = runner.invoke(cli, ['-g', 'openshift-4.6', 'repair-bugs', '--close-placeholder', '--id', 'OCPBUGS-1',
'--to', 'ON_QA', '-a', '99999'])
if result.exit_code != 0:
exc_type, exc_value, exc_traceback = result.exc_info
t = "\n".join(traceback.format_exception(exc_type, exc_value, exc_traceback))
self.fail(t)
self.assertIn("1 bugs successfully modified", result.output)
self.assertEqual(result.exit_code, 0)

def test_repair_bugzilla_bug_with_comment(self):
runner = CliRunner()
bug = flexmock(id=1, status="MODIFIED", summary="")
Expand Down
1 change: 0 additions & 1 deletion pyartcd/pyartcd/pipelines/advisory_drop.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ async def advisory_drop(runtime: Runtime, group: str, advisory: str, comment: st
'--advisory', advisory,
'--auto',
'--comment', comment,
'--close-placeholder',
'--from', 'RELEASE_PENDING',
'--to', 'VERIFIED',
]
Expand Down