#180 Adjust for changes to Werkzeug's changes to ProxyFix
Merged 2 years ago by frantisekz. Opened 2 years ago by tflink.
fedora-qa/ tflink/blockerbugs feature/fix-proxy-handling-new-flask  into  develop

file modified
+19 -11
@@ -1,14 +1,22 @@ 

- *.pyc

- *.pyo

+ # editors

+ /.idea/

+ /.ropeproject/

  *.swp

- env_blockerbugs/*

- *__pycache__*

- *.ropeproject/

- conf/settings.py

- .sass-cache/

- .idea

- docs/_build/*

- blockerbugs_db.sqlite

+ 

+ # cache files

  /.cache/

- /*.tar.gz

+ /.pytest_cache/

+ .sass-cache/

+ *__pycache__*

+ 

+ # compile artifacts

+ /docs/_build/

  /*.src.rpm

+ /*.tar.gz

+ *.pyc

+ *.pyo

+ 

+ # local config

+ /blockerbugs_db.sqlite

+ /conf/settings.py

+ /env_blockerbugs/

file modified
+13 -1
@@ -1,7 +1,7 @@ 

  Name:           blockerbugs

  # NOTE: if you update version, *make sure* to also update

  # `blockerbugs/__init__.py` and `docs/source/conf.py`

- Version:        1.2.1

+ Version:        1.3.0

  Release:        1%{?dist}

  Summary:        Fedora QA Blocker Tracking Application

  
@@ -105,6 +105,18 @@ 

  

  

  %changelog

+ * Wed May 05 2021 Frantisek Zatloukal <fzatlouk@redhat.com> - 1.3.0-1

+ - blocker_list.html: make it more readable, don't wrap status icons

+ - pytest: ignore a DeprecationWarning from the openid package

+ - show review vote counts only for Proposed bugs

+ - discussions: add component to the ticket title, reshuffle

+ - blocker_list: prevent wrapping votes in the middle

+ - allow the dev to log in as any user, always in admin group

+ - init_db.sh: update to F35 release

+ - requirements: work around idna dependency error

+ - .gitignore: re-shuffle into sections

+ - .gitignore: add /.pytest_cache/

+ 

  * Fri Apr 09 2021 Frantisek Zatloukal <fzatlouk@redhat.com> - 1.2.1-1

  - Fix the migration from 72031671860e

  

file modified
+3 -3
@@ -8,7 +8,7 @@ 

  from . import config

  

  # the version as used in setup.py and docs

- __version__ = "1.2.1"

+ __version__ = "1.3.0"

  

  # Flask App

  app = Flask(__name__)
@@ -108,8 +108,8 @@ 

  # "Hotfix" for proxy handling on current deployment, my guess is that the proxy

  # server is set differently than it was, but what do I know...

  if app.config["BEHIND_PROXY"]:

-     from werkzeug.contrib.fixers import ProxyFix

-     app.wsgi_app = ProxyFix(app.wsgi_app, num_proxies=1)

+     from werkzeug.middleware.proxy_fix import ProxyFix

+     app.wsgi_app = ProxyFix(app.wsgi_app, x_host=1)

  

  

  # === Flask views and stuff ===

file modified
+1 -1
@@ -58,7 +58,7 @@ 

      PAGURE_BOT_USERNAME = 'blockerbot'

      PAGURE_BOT_ENABLED = True

      PAGURE_BOT_LOOP_THRESHOLD = 2

-     PAGURE_DISCUSSION_TITLE = "rhbz#$bugid $summary"

+     PAGURE_DISCUSSION_TITLE = "[$component] $summary | rhbz#$bugid"

      PAGURE_DISCUSSION_CONTENT = '''\

  Bug details: ** $bug_url **

  Information from [BlockerBugs App]({}):

@@ -58,6 +58,6 @@ 

      if app.config['FAS_ADMIN_GROUP'] in g.fas_user.groups:

          return None

  

-     app.logger.info('Failed admin access to %s by %s' % (

-         request.url, g.fas_user.username))

+     app.logger.info('Failed admin access to {url} by {user} (not in group "{admin}")'.format(

+         url=request.url, user=g.fas_user.username, admin=app.config['FAS_ADMIN_GROUP']))

      abort(401)

@@ -51,12 +51,13 @@ 

  

  

  {% block body %}

- 

+ {% set buglist_names = ['Proposed Blockers','Accepted Blockers', 'Accepted 0-day Blockers', 'Accepted Previous Release Blockers',

+                         'Proposed Freeze Exceptions', 'Accepted Freeze Exceptions', 'Prioritized Bugs'] %}

  

  <div class="row">

      <div class="col-md-12" id="blockertables">

-         {% for buglist in ['Proposed Blockers','Accepted Blockers', 'Accepted 0-day Blockers', 'Accepted Previous Release Blockers', 'Proposed Freeze Exceptions', 'Accepted Freeze Exceptions', 'Prioritized Bugs'] %}

-         {% if buglists[buglist] %}<h2>{{ buglists[buglist] | length }} {% if (buglists[buglist] | length) == 1 %}{{ buglist[:-1]}}{% else %}{{ buglist }}{% endif %}</h2>

+         {% for buglist in buglist_names if buglists[buglist] %}  {# for non-empty buglists #}

+         <h2>{{ buglists[buglist] | length }} {% if (buglists[buglist] | length) == 1 %}{{ buglist[:-1]}}{% else %}{{ buglist }}{% endif %}</h2>

          <table id="{{ buglist | tagify }}" cellspacing="1" class="table table-striped">

              <thead class="thead-light">

                  <tr>
@@ -72,32 +73,38 @@ 

              <tbody>

                  {% for bug in buglists[buglist] %}

                      <tr>

-                         <td>{% if bug.bugid in recent %}<span class="foundicon-idea yellow" title="modified recently"></span>{% endif %} {% if bug.needinfo %}<span class="needinfo" title="NEEDINFO{% if bug.needinfo_requestee %} from {{ bug.needinfo_requestee }}{% else %}{% endif %}">?</span>{% endif %}{% if bug.bugid in wb_change %}<span class="foundicon-refresh green" title="blocker/fe status changed recently"></span>{% endif %}</td>

+                         <td class="text-nowrap">

+                             {% if bug.bugid in recent %}<span class="foundicon-idea yellow" title="modified recently"></span>{% endif -%}

+                             {% if bug.needinfo %}<span class="needinfo" title="NEEDINFO{% if bug.needinfo_requestee %} from {{ bug.needinfo_requestee }}{% else %}{% endif %}">?</span>{% endif -%}

+                             {% if bug.bugid in wb_change %}<span class="foundicon-refresh green" title="blocker/fe status changed recently"></span>{% endif %}

+                         </td>

                          <td class='bugid'><a href='{{ bug.url }}' target="_blank" rel="noopener noreferrer">{{ bug.bugid }}</a></td>

                          <td>{{ bug.component }}</td>

                          <td>{{ bug.status }}</td>

                          <td>{{ bug.summary }}</td>

                          <td class="text-center">

-                             {% if vote_info[bug.bugid][buglist] %}

-                             <span class="{{'text-success' if  vote_info[bug.bugid][buglist][0] > 0 else ''}}">+{{ vote_info[bug.bugid][buglist][0] }}</span>,

-                             <span>{{ vote_info[bug.bugid][buglist][1] }}</span>,

-                             <span class="{{'text-danger' if  vote_info[bug.bugid][buglist][2] > 0 else ''}}">-{{ vote_info[bug.bugid][buglist][2] }}</span>

-                             <br />

+                             {% if buglist.startswith('Proposed') and vote_info[bug.bugid][buglist] %}

+                                 <span class="text-nowrap">

+                                     <span class="{{'text-success' if  vote_info[bug.bugid][buglist][0] > 0 else ''}}">+{{ vote_info[bug.bugid][buglist][0] }}</span>,

+                                     <span>{{ vote_info[bug.bugid][buglist][1] }}</span>,

+                                     <span class="{{'text-danger' if  vote_info[bug.bugid][buglist][2] > 0 else ''}}">-{{ vote_info[bug.bugid][buglist][2] }}</span>

+                                 </span>

+                                 <br />

                              {% endif %}

                              {% if bug.discussion_link %}

-                             <a href='{{ bug.discussion_link }}' target="_blank" rel="noopener noreferrer">

-                                 {% if buglist.startswith('Accepted') %}

-                                     Discuss

-                                 {% elif vote_info[bug.bugid]['user_voted'] %}

-                                     <span class="text-success">Voted</span>

-                                 {% else %}

-                                     Vote!

-                                 {% endif %}

-                             </a>

+                                 <a href='{{ bug.discussion_link }}' target="_blank" rel="noopener noreferrer">

+                                     {% if buglist.startswith('Accepted') %}

+                                         Discuss

+                                     {% elif vote_info[bug.bugid]['user_voted'] %}

+                                         <span class="text-success">Voted</span>

+                                     {% else %}

+                                         Vote!

+                                     {% endif %}

+                                 </a>

                              {% elif buglist.startswith('Prioritized') %}

-                             <!-- Nothing here, go on...-->

+                                 {# Nothing here, go on... #}

                              {% else %}

-                             TBD

+                                 TBD

                              {% endif %}

                          </td>

                          <td class="popupification">
@@ -107,7 +114,7 @@ 

                                  {{ bug | updatelabel | safe}}</a>

                          </td>

                      </tr>

-                     {% else %}

+                 {% else %}

                      <tr>

                          <td></td>

                          <td></td>
@@ -117,13 +124,13 @@ 

                          <td></td>

                          <td></td>

                      </tr>

-                     {% endfor %}

+                 {% endfor %}

              </tbody>

-         </table>{% endif %}

+         </table>

          {% endfor %}

-         {% for buglist in ['Proposed Blockers','Accepted Blockers', 'Accepted 0-day Blockers', 'Accepted Previous Release Blockers', 'Proposed Freeze Exceptions', 'Accepted Freeze Exceptions', 'Prioritized Bugs'] %}

-             {% if not buglists[buglist] %}<h4>No {{ buglist }}</h4>{% endif %}

+         {% for buglist in buglist_names if not buglists[buglist] %}  {# for empty buglists #}

+             <h4>No {{ buglist }}</h4>

          {% endfor %}

-     </div> <!-- end of 12 columns -->

- </div> <!-- end of row -->

+     </div>  {# end of 12 columns #}

+ </div>  {# end of row #}

  {% endblock %}

@@ -21,7 +21,9 @@ 

  #link {{ bug.discussion_link }}

  {% endif -%}

  #info {{ buglist | replace("Blockers", "Blocker") }}, {{ bug.component }}, {{ bug.status }}

+ {% if buglist.startswith('Proposed') -%}

  {{ vote_info[bug.bugid] }}

+ {% endif -%}

  

  

  {% endfor -%} {# end of bug iteration #}

file modified
+3 -3
@@ -46,9 +46,9 @@ 

  

  

  class FakeFAS(object):

-     fake_user_groups = ['qa-admin']

-     fake_user = munch.Munch(username='developer',

-                             groups=fake_user_groups)

+     fake_user = munch.Munch(

+         username=app.config['FAS_USER'] or 'developer',

+         groups=[app.config['FAS_ADMIN_GROUP']])

  

      def __init__(self, app):

          app.before_request(self._set_fas_user)

@@ -10,16 +10,8 @@ 

  

  

  def create_bug_discussion(bug):

-     title = Template(app.config['PAGURE_DISCUSSION_TITLE']).safe_substitute(

-         bugid=bug.bugid,

-         summary=bug.summary)

-     content = Template(app.config['PAGURE_DISCUSSION_CONTENT']).safe_substitute(

-         bugid=bug.bugid,

-         bug_img=app.config['BLOCKERBUGS_API'] + "bugimg/%s" % bug.bugid,

-         bug_url=bug.url,

-         vote_summary='Nobody voted yet.',

-         pagure_url=app.config['PAGURE_URL'],

-         pagure_repo=app.config['PAGURE_REPO'],)

+     title = render_discussion_template(app.config['PAGURE_DISCUSSION_TITLE'], bug)

+     content = render_discussion_template(app.config['PAGURE_DISCUSSION_CONTENT'], bug)

  

      return create_issue(title, content)

  
@@ -33,17 +25,9 @@ 

      update_issue_url = app.config['PAGURE_API'] + app.config['PAGURE_REPO'] + '/issue/%s' % issue_id

      bug = issue_to_bug(issue_id)

  

-     bug_url = app.config['BUGZILLA_URL'] + "show_bug.cgi?id=%s" % bug.bugid

-     title = Template(app.config['PAGURE_DISCUSSION_TITLE']).safe_substitute(

-         bugid=bug.bugid,

-         summary=bug.summary)

-     content = Template(app.config['PAGURE_DISCUSSION_CONTENT']).safe_substitute(

-         bugid=bug.bugid,

-         bug_img=app.config['BLOCKERBUGS_API'] + "bugimg/%s" % bug.bugid,

-         bug_url=bug_url,

-         vote_summary=vote_summary,

-         pagure_url=app.config['PAGURE_URL'],

-         pagure_repo=app.config['PAGURE_REPO'],)

+     title = render_discussion_template(app.config['PAGURE_DISCUSSION_TITLE'], bug)

+     content = render_discussion_template(app.config['PAGURE_DISCUSSION_CONTENT'],

+                                          bug, vote_summary)

      data = {

          'title': title,

          'issue_content': content,
@@ -159,3 +143,17 @@ 

              'response text:\n%s' % (resp.status_code, resp.text))

  

      return resp.json()

+ 

+ 

+ def render_discussion_template(template, bug, vote_summary='Nobody voted yet.'):

+     rendered = Template(template).substitute(

+         bug_img=f"{app.config['BLOCKERBUGS_API']}bugimg/{bug.bugid}",

+         bug_url=bug.url,

+         bugid=bug.bugid,

+         component=bug.component,

+         pagure_url=app.config['PAGURE_URL'],

+         pagure_repo=app.config['PAGURE_REPO'],

+         summary=bug.summary,

+         vote_summary=vote_summary,

+     )

+     return rendered

file modified
+2 -2
@@ -48,9 +48,9 @@ 

  # built documents.

  #

  # The short X.Y version.

- version = '1.2'

+ version = '1.3'

  # The full version, including alpha/beta/rc tags.

- release = '1.2.1'

+ release = '1.3.0'

  

  # The language for content autogenerated by Sphinx. Refer to documentation

  # for a list of supported languages.

file modified
+5 -8
@@ -8,15 +8,12 @@ 

  python3 run_cli.py init_db

  

  # add releases

- python3 run_cli.py add_release -r 33

- python3 run_cli.py add_release -r 34

+ python3 run_cli.py add_release -r 35

  

  # add milestones

- python3 run_cli.py add_milestone -r 33 -m beta -b 1766775 -a 1766776

- python3 run_cli.py add_milestone -r 33 -m final -b 1766777 -a 1766778

- python3 run_cli.py add_milestone -r 34 -m beta -b 1829022 -a 1829023

- python3 run_cli.py add_milestone -r 34 -m final -b 1829024 -a 1829025

+ python3 run_cli.py add_milestone -r 35 -m beta -b 1891953 -a 1891954

+ python3 run_cli.py add_milestone -r 35 -m final -b 1891955 -a 1891956

  

  # partner-bugzilla alternative numbers:

- #python3 run_cli.py add_milestone -r 32 -m beta -b 1729402 -a 1729404

- #python3 run_cli.py add_milestone -r 32 -m final -b 1729403 -a 1729405

+ #python3 run_cli.py add_milestone -r 35 -m beta -b 1732917 -a 1732918

+ #python3 run_cli.py add_milestone -r 35 -m final -b 1732919 -a 1732920

file modified
+1
@@ -5,3 +5,4 @@ 

  testpaths = testing

  filterwarnings =

      ignore:the imp module is deprecated in favour of importlib:DeprecationWarning:koji

+     ignore:defusedxml.cElementTree is deprecated, import from defusedxml.ElementTree instead:DeprecationWarning:openid

file modified
+5 -2
@@ -1,6 +1,6 @@ 

  # the flask and werkzeug freeze is to reflect the state on production

- Flask == 1.1.1

- Werkzeug == 0.16.0

+ Flask == 1.1.2

+ Werkzeug == 1.0.1

  

  alembic

  bodhi-client
@@ -25,3 +25,6 @@ 

  python3-openid

  SQLAlchemy

  WTForms

+ 

+ # this is not a direct dependency, but a workaround for https://github.com/psf/requests/issues/5710

+ idna == 2.10

When we tried deploying to a new stg instance running F33, it has a newer version of Werkzeug and there have been changes to the ProxyFix module.

This PR updates the Flask, Werkzeug versions to reflect what will be used in production once that's deployed and adjusts the ProxyFix import/usage for these new versions

Build succeeded.

It's deployed on stg and works there well, thanks!

rebased onto 90d67d6

2 years ago

Build succeeded.

rebased onto 8924bf7

2 years ago

Pull-Request has been merged by frantisekz

2 years ago

Build succeeded.