#2261 Log requests from backend and distgit
Merged 2 years ago by praiskup. Opened 2 years ago by frostyx.
copr/ frostyx/copr logging-distgit-backend  into  main

@@ -66,6 +66,8 @@ 

          # """

          url = "{}/{}/".format(self.frontend_url, url_path)

          auth = self.frontend_auth if authenticate else None

+         self.log.info("Sending %s request to frontend URL - %s",

+                       method.upper(), url)

  

          try:

              request = SafeRequest(auth=auth, log=self.log,

@@ -130,7 +130,8 @@ 

          with pytest.raises(FrontendClientException):

              self.fc.post(self.data, self.url_path)

          assert mc_time.sleep.call_args_list == [mock.call(x) for x in [5, 10, 15, 20, 25]]

-         assert len(caplog.records) == 5

+         records = [x for x in caplog.records if "Retry request" in x.msg]

+         assert len(records) == 5

  

      def test_post_to_frontend_repeated_indefinitely(self,

              mask_frontend_request, caplog, mc_time):
@@ -141,7 +142,8 @@ 

          with pytest.raises(FrontendClientException):

              self.fc.post(self.data, self.url_path)

          assert mc_time.sleep.called

-         assert len(caplog.records) == 100

+         records = [x for x in caplog.records if "Retry request" in x.msg]

+         assert len(records) == 100

  

      def test_retries_on_outdated_frontend(self, mask_frontend_request, caplog):

          response = self._get_fake_response()
@@ -150,9 +152,10 @@ 

              response for _ in range(100)] + [Exception("sorry")]

          with pytest.raises(Exception):

              self.fc.try_indefinitely = True

-             self.fc.post(self.data, self.url_path)

+             self.fc.post(self.url_path, self.data)

          assert len(mask_frontend_request.call_args_list) == 101

-         assert "Copr FE/BE API is too old on Frontend" in str(caplog.records[0])

+         assert "Sending POST request to frontend" in caplog.records[0].getMessage()

+         assert "Copr FE/BE API is too old on Frontend" in caplog.records[1].msg

  

      def test_update(self):

          ptfr = MagicMock()

@@ -39,7 +39,9 @@ 

              builds = list(filter(lambda x: x["build_id"] not in exclude, r.json()))

              if not builds:

                  log.debug("No new tasks to process.")

+                 return []

  

+             log.debug("Got tasks from %s", self.get_url)

              return [ImportTask.from_dict(build) for build in builds[:limit]]

          except Exception as e:

              log.exception("Failed acquire new packages for import:" + str(e))

  • Logging from what URL distgit obtains tasks that are to be imported
  • Logging every request that is sent from backend to frontend (this way we know what frontend instance gave it build tasks, actions, etc)
  • We would like to log also requests from backend to keygen but there is a blocker - https://github.com/openSUSE/obs-sign/issues/38

Build succeeded.

Weird, this LGTM, but it breaks the backend test-suite?

Metadata Update from @praiskup:
- Pull-request tagged with: wip

2 years ago

2 new commits added

  • backend: log every request that is sent to frontend
  • distgit: log the URL that got us new tasks
2 years ago

Build succeeded.

Metadata Update from @frostyx:
- Pull-request untagged with: wip

2 years ago

rebased onto d89bc9d

2 years ago

Pull-Request has been merged by praiskup

2 years ago

Build succeeded.