Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
Migrate away from prodsec data for jira
Browse files Browse the repository at this point in the history
  • Loading branch information
jupierce committed Feb 1, 2023
1 parent 32c4c74 commit bf5fbf0
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 36 deletions.
7 changes: 3 additions & 4 deletions doozerlib/cli/__main__.py
Expand Up @@ -1097,10 +1097,9 @@ def images_print(runtime, short, show_non_release, show_base, output, label, pat
{build} - Shorthand for {component}-{version}-{release} (e.g. container-engine-v3.6.173.0.25-1)
{repository} - Shorthand for {image}:{version}-{release}
{label} - The label you want to print from the Dockerfile (Empty string if n/a)
{bz_info} - All known BZ component information for the component
{bz_product} - The BZ product, if known
{bz_component} - The BZ component, if known
{bz_subcomponent} - The BZ subcomponent, if known
{jira_info} - All known BZ component information for the component
{jira_project} - The associated Jira project for bugs, if known
{jira_component} - The associated Jira project component, if known
{upstream} - The upstream repository for the image
{upstream_public} - The public upstream repository (if different) for the image
{lf} - Line feed
Expand Down
29 changes: 16 additions & 13 deletions doozerlib/cli/images_streams.py
Expand Up @@ -677,26 +677,29 @@ def reconcile_jira_issues(runtime, pr_links: Dict[str, str], dry_run: bool):
if potential_project != project or potential_component != component:
description += f'''
Important: Product Security has recorded in their ps_modules.json data that bugs
for this component should be opened against Jira project "{potential_project}" and
Important: ART has recorded in their product data that bugs for
this component should be opened against Jira project "{potential_project}" and
component "{potential_component}". This project or component does not exist. Jira
should either be updated to include this component or an email should be sent to
prodsec-openshift@redhat.com to have them update their data. Until this is done,
ART issues against this component will be opened against OCPBUGS/Unknown --
creating unnecessary work and delay.
should either be updated to include this component or @release-artists should be
notified of the proper mapping in the #aos-art Slack channel.
Prodsec will need to know the product component name: {distgit_key} .
Component name: {image_meta.get_component_name()} .
Jira mapping: https://github.com/openshift/ocp-build-data/blob/main/product.yml
'''
elif potential_project == 'Unknown':
description += f'''
Important: Product Security maintains a mapping of OpenShift software components to
Jira components in their ps_modules.json data for OpenShift. This component does not
have a mapping in that data. Please email prodsec-openshift@redhat.com to ensure
this component is registered. Until this is done, ART issues against
this component will be opened against OCPBUGS/Unknown -- creating unnecessary work and delay.
Important: ART maintains a mapping of OpenShift software components to
Jira components. This component does not currently have an entry defined
within that data.
Contact @release-artists in the #aos-art Slack channel to inform them of
the Jira project and component to use for this image.
Prodsec will need to know the product component name: {distgit_key} .
Until this is done, ART issues against this component will be opened
against OCPBUGS/Unknown -- creating unnecessary processing work and delay.
Component name: {image_meta.get_component_name()} .
Jira mapping: https://github.com/openshift/ocp-build-data/blob/main/product.yml
'''

fields = {
Expand Down
21 changes: 17 additions & 4 deletions doozerlib/metadata.py
Expand Up @@ -775,15 +775,28 @@ def get_jira_info(self) -> Tuple[str, str]:
# Maintainer info can be defined in metadata, so try there first.
maintainer = self.config.jira.copy() or dict()

prodsec_mapping = self.runtime.get_openshift4_component_mapping()
prodsec_jira_component = prodsec_mapping.get(self.get_component_name(), 'Unknown')
product_config = self.runtime.get_product_config()
issue_project = product_config.bug_mapping.default_issue_project

component_mapping = product_config.bug_mapping.components
component_entry = component_mapping[self.get_component_name()]
if component_entry.issue_project:
issue_project = component_entry.issue_project

jira_component = component_entry.issue_component

if not issue_project:
issue_project = 'OCPBUGS'

if not jira_component:
jira_component = 'Unknown'

if self.distgit_key == 'openshift-enterprise-base':
# This is a special case image that is represented by upstream but
# no one release owns. ART should handle merges here.
prodsec_jira_component = 'Release'
jira_component = 'Release'

return maintainer.get('project', 'OCPBUGS'), maintainer.get('component', prodsec_jira_component)
return maintainer.get('project', issue_project), maintainer.get('component', jira_component)

def extract_kube_env_vars(self) -> Dict[str, str]:
"""
Expand Down
24 changes: 9 additions & 15 deletions doozerlib/runtime.py
Expand Up @@ -156,7 +156,7 @@ def __init__(self, **kwargs):
self.assembly = 'test'
self._build_status_detector = None
self.disable_gssapi = False
self._openshift4_component_mapping_cache: Dict[str, str] = None
self._build_data_product_cache: Model = None

self.stream: List[str] = [] # Click option. A list of image stream overrides from the command line.
self.stream_overrides: Dict[str, str] = {} # Dict of stream name -> pullspec from command line.
Expand Down Expand Up @@ -849,23 +849,17 @@ def get_global_arches(self):
"""
return list(self.arches)

def get_openshift4_component_mapping(self) -> Dict[str, str]:
def get_product_config(self) -> Model:
"""
Returns a mapping of component name -> Jira component in OCPBUGS for openshift-4 product.
e.g. "ose-vertical-pod-autoscaler-container" -> "Node / Cluster Autoscaler",
Returns a Model of the product.yml in ocp-build-data main branch.
"""
if self._openshift4_component_mapping_cache:
return self._openshift4_component_mapping_cache
# Product security maintains this mapping
if 'prodsec_git' not in self.hosts:
raise IOError('Update your settings.yaml to include hosts: { prodsec_git: ... }')
prodsec_git_host = self.hosts['prodsec_git']
url = f'https://{prodsec_git_host}/prodsec/product-definitions/-/raw/master/data/openshift/ps_modules.json'
if self._build_data_product_cache:
return self._build_data_product_cache
url = 'https://raw.githubusercontent.com/openshift/ocp-build-data/main/product.yml'
req = urllib.request.Request(url)
req.add_header('Accept', 'application/json')
ps_modules = json.loads(exectools.urlopen_assert(req).read())
_openshift4_component_mapping_cache = ps_modules['ps_modules']['openshift-4']['components']['override']
return _openshift4_component_mapping_cache
req.add_header('Accept', 'application/yaml')
self._build_data_product_cache = Model(yaml.safe_load(exectools.urlopen_assert(req).read()))
return self._build_data_product_cache

def filter_failed_image_trees(self, failed):
for i in self.ordered_image_metas():
Expand Down

0 comments on commit bf5fbf0

Please sign in to comment.