You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/04/07 10:43:08 UTC

[GitHub] [airflow] kostiantyn-lab opened a new issue, #22810: JiraTicketSensor duplicates TaskId

kostiantyn-lab opened a new issue, #22810:
URL: https://github.com/apache/airflow/issues/22810

   ### Apache Airflow Provider(s)
   
   jira
   
   ### Versions of Apache Airflow Providers
   
   apache-airflow-providers-jira==2.0.1
   
   ### Apache Airflow version
   
   2.2.2
   
   ### Operating System
   
   Amazon Linux 2
   
   ### Deployment
   
   MWAA
   
   ### Deployment details
   
   _No response_
   
   ### What happened
   
   I've been trying to use the Jira Operator to create a Ticket from Airflow and use the JiraTicketSensor to check if the ticket was resolved. Creating the task works fine, but I can't get the Sensor to work.
   
   If I don't provide the method_name I get an error that it is required, if I provide it as None, I get an error saying the Task id has already been added to the DAG.
   
   ```text
   Broken DAG: [/usr/local/airflow/dags/jira_ticket_sensor.py] Traceback (most recent call last):
     File "/usr/local/lib/python3.7/site-packages/airflow/models/baseoperator.py", line 553, in __init__
       task_group.add(self)
     File "/usr/local/lib/python3.7/site-packages/airflow/utils/task_group.py", line 175, in add
       raise DuplicateTaskIdFound(f"Task id '{key}' has already been added to the DAG")
   airflow.exceptions.DuplicateTaskIdFound: Task id 'jira_sensor' has already been added to the DAG
   ```
   
   ### What you think should happen instead
   
   _No response_
   
   ### How to reproduce
   
   use this dag
   
   ```python
   from datetime import datetime
   
   from airflow import DAG
   from airflow.providers.jira.sensors.jira import JiraTicketSensor
   
   with DAG(
       dag_id='jira_ticket_sensor',
       schedule_interval=None,
       start_date=datetime(2021, 1, 1),
       catchup=False
   ) as dag:
       jira_sensor = JiraTicketSensor(
           task_id='jira_sensor',
           jira_conn_id='jira_default',
           ticket_id='TEST-1',
           field='status',
           expected_value='Completed',
           method_name='issue',
           poke_interval=600
       )
   ```
   
   ### Anything else
   
   This error occurs every time
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] kianelbo commented on issue #22810: JiraTicketSensor duplicates TaskId

Posted by GitBox <gi...@apache.org>.
kianelbo commented on issue #22810:
URL: https://github.com/apache/airflow/issues/22810#issuecomment-1100293860

   I opened a PR according to what @potiuk explained. This is my first ever contribution and I would really appreciate it if you take a look at it and give your feedbacks.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] kianelbo commented on issue #22810: JiraTicketSensor duplicates TaskId

Posted by GitBox <gi...@apache.org>.
kianelbo commented on issue #22810:
URL: https://github.com/apache/airflow/issues/22810#issuecomment-1113009813

   I'm embarrassed... I hope https://github.com/apache/airflow/pull/23352 does the trick.
   
   > I see two ways to fix it
   
   I decided to go with the second solution since github sensor and arangodb operator are written in a similar way.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] kostiantyn-lab commented on issue #22810: JiraTicketSensor duplicates TaskId

Posted by GitBox <gi...@apache.org>.
kostiantyn-lab commented on issue #22810:
URL: https://github.com/apache/airflow/issues/22810#issuecomment-1112394200

   > I opened a PR according to what @potiuk explained. This is my first ever contribution and I would really appreciate it if you take a look at it and give your feedbacks.
   
   @kianelbo I've found error in your patch
   ```
     File "/usr/local/lib/python3.7/site-packages/airflow/sensors/base.py", line 234, in execute
       while not self.poke(context):
     File "/usr/local/airflow/.local/lib/python3.7/site-packages/airflow_contrib/sensors/jira.py", line 110, in poke
       return JiraSensor.poke(self, context=context)
     File "/usr/local/airflow/.local/lib/python3.7/site-packages/airflow/providers/jira/sensors/jira.py", line 64, in poke
       return self.result_processor(context, jira_result)
   TypeError: issue_field_checker() takes 2 positional arguments but 3 were given
   ```
   
   I see two ways to fix it
   1. Add `context: Dict` as parameter to `def issue_field_checker(self, issue: Issue) -> Optional[bool]`
   2. Remove `context` parameter from the `return self.result_processor(context, jira_result)`
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] potiuk commented on issue #22810: JiraTicketSensor duplicates TaskId

Posted by GitBox <gi...@apache.org>.
potiuk commented on issue #22810:
URL: https://github.com/apache/airflow/issues/22810#issuecomment-1097322156

   Indeed, it's reproducible.
   
   It seems that the rason is that the sensor has a serious bug. It tries to create an operator with the same task id - which makes no sense:
   
   ```
   class JiraSensor(BaseSensorOperator):
       """
       Monitors a jira ticket for any change.
   
       :param jira_conn_id: reference to a pre-defined Jira Connection
       :param method_name: method name from jira-python-sdk to be execute
       :param method_params: parameters for the method method_name
       :param result_processor: function that return boolean and act as a sensor response
       """
       def __init__(
           self,
           *,
           method_name: str,
           jira_conn_id: str = 'jira_default',
           method_params: Optional[dict] = None,
           result_processor: Optional[Callable] = None,
           **kwargs,
       ) -> None:
           super().__init__(**kwargs)
           self.jira_conn_id = jira_conn_id
           self.result_processor = None
           if result_processor is not None:
               self.result_processor = result_processor
           self.method_name = method_name
           self.method_params = method_params
           self.jira_operator = JiraOperator(.     <-- This is wrong
               task_id=self.task_id,
               jira_conn_id=self.jira_conn_id,
               jira_method=self.method_name,
               jira_method_args=self.method_params,
               result_processor=self.result_processor,
           )
   ```
   
   It should not create operator - it should use Jira Hook instead.
   
   Hopefully someone using Jira could fix it (maybe you could attempt it @kostiantyn-lab ).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] potiuk closed issue #22810: JiraTicketSensor duplicates TaskId

Posted by GitBox <gi...@apache.org>.
potiuk closed issue #22810: JiraTicketSensor duplicates TaskId
URL: https://github.com/apache/airflow/issues/22810


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] boring-cyborg[bot] commented on issue #22810: JiraTicketSensor duplicates TaskId

Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on issue #22810:
URL: https://github.com/apache/airflow/issues/22810#issuecomment-1091559727

   Thanks for opening your first issue here! Be sure to follow the issue template!
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org