티스토리 뷰

반응형

Airflow 에서 "hive_cli_default" Connection 을 설정할때, Extra 옵션에 {"use_beeline": true} 를 추가하면, beeline 을 통해 쿼리를 실행한다. 근데, 기본적으로 -hiveconf 옵션에 airflow.ctx.* 패턴의 값이 추가되면서 아래와 같은 오류가 발생될 때가 존재한다.

java.lang.IllegalArgumentException: Cannot modify airflow.ctx.dag_id at runtime. It is not in list of params that are allowed to be modified at runtime

이 오류를 재현하는 방법은  beeline 을 실행할때 -hiveconf airflow.ctx.dag_id=my_dag 와 같은 인자를 추가후 실행해보면 쉽게 테스트가 가능하다. (airflow 의 로그에 beeline 명령어 구조가 안보인다면, airflow.cfg 의 로그레벨을 변경해주자)

$ beeline -u "jdbc:hive2://my-host.com:10000/default;auth=ldap" -n 아이디 -p 암호 -hiveconf airflow.ctx.dag_id=my_dag -e "select count(*) from test limit 4"
Connecting to jdbc:hive2://my-host.com:10000/default;auth=ldap
22/07/25 10:01:40 [main]: WARN jdbc.HiveConnection: Failed to connect to my-host.com:10000
Error: Could not open client transport with JDBC Uri: jdbc:hive2://my-host.com:10000/default;auth=ldap: Failed to open new session: java.lang.IllegalArgumentException: Cannot modify airflow.ctx.dag_id at runtime. It is not in list of params that are allowed to be modified at runtime (state=08S01,code=0)

 

원인과 해결방법

해당 오류메시지가 있는 코드를 찾아보면, 다음과 같이 HiveConf.java 에서 해당 조건에 만족하지 않을때 발생되는에러였다. 쉽게 생각하면 tez.queue.name 과 같이 실제 hive 에서 허용가능한 설정이 아닌경우 에러처리가 되고 있던것이다.

이것을 허용하려면 어떻게 해야할까?

 

https://github.com/apache/hive/blob/rel/release-4.0.0-alpha-1/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java#L5978-L5984

해결방법

특정패턴의 hiveconf 가 적용될 수 있도록 허용해주면 된다. 참고로 airflow에서 기본으로 만들어내는 hiveconf 의 key 는 아래와 같으므로 두가지 패턴을 허용하도록 추가해주면 된다.

  • airflow.ctx.dag_id
  • airflow.ctx.task_id
  • airflow.ctx.execution_date
  • airflow.ctx.try_number
  • airflow.ctx.dag_run_id
  • airflow.ctx.dag_owner
  • airflow.ctx.dag_email
  • mapred.job.name

hive-site.xml 에 에 추가해주면 된다. (ambari 를 쓴다면 Hive 의 Custom hive-site 메뉴에 설정추가)

<property>
    <name>hive.security.authorization.sqlstd.confwhitelist.append</name>
    <value>airflow\.ctx.*|mapred\.job\.name</value>
</property>

https://cwiki.apache.org/confluence/display/hive/configuration+properties#ConfigurationProperties-hive.security.authorization.sqlstd.confwhitelist.append 

 

그러면, airflow 에서 자동으로 만들어 내는 hiveconf 값이 허용되면서 오류 없이 실행이 가능할것이다. 끝.

반응형
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함