Is there a preferred pattern/approach for using en...
# troubleshooting
r
Is there a preferred pattern/approach for using environment variables as
args
? I have a job running on the Flink Operator and I’m attempting to do something like the following:
Copy code
env:
- name: SOME_VALUE
  value: ...
job:
 ...
 args: ["--some-key", "$SOME_VALUE"]
Is there a way to handle this out of the box? or Perhaps a different pattern that I’d need to use (if this was supported at all)?
g
In general env resolution in config and other places is not very well handled in Flink
this extends to args as well even more as these are translated into a single flink config field, so the single env based arg is part of a longer string
there is a trick that you can do :
Copy code
"kubernetes.jobmanager.entrypoint.args": " -D key=$ENV",
"kubernetes.taskmanager.entrypoint.args": " -D key=$ENV",
this is a way to override configs from env, you could leave the job args open and add similar trick to entry point args if you look up the appropriate config key for that
I know this is not great but technically possible even if its a bit hacky 🙂
r
Okay, I appreciate it @Gyula Fóra! I eventually adjusted the job and handled everything purely based on using environment variables via the
env:
instead of the more arcane params 🙂
g
Yea , that sounds like a more sensible approach 😄
r
I’ve got another quick one for you if you are around. I recently migrated an old job running on Flink 1.15 to Flink 1.18 (on the operator). I stopped the old job with a savepoint and am using that savepoint for the
initialSavepointPath
to restore the job on the operator and I’m seeing this guy:
Copy code
2024-03-13 16:45:45,938 ERROR org.apache.flink.connector.kafka.sink.KafkaCommitter         [] - Transaction (org.apache.flink.streaming.runtime.operators.sink.committables.CommitRequestImpl@24ef5b52) encountered error and data has been potentially lost.
java.lang.RuntimeException: Incompatible KafkaProducer version
	at org.apache.flink.connector.kafka.sink.FlinkKafkaInternalProducer.getField(FlinkKafkaInternalProducer.java:285) ~[blob_p-d8bf403a8a51c95305f1ab59a0ff39a6467603a6-afd009f29d87580cf4db55ed4d073f62:?]
	at org.apache.flink.connector.kafka.sink.FlinkKafkaInternalProducer.getField(FlinkKafkaInternalProducer.java:272) ~[blob_p-d8bf403a8a51c95305f1ab59a0ff39a6467603a6-afd009f29d87580cf4db55ed4d073f62:?]
	at org.apache.flink.connector.kafka.sink.FlinkKafkaInternalProducer.resumeTransaction(FlinkKafkaInternalProducer.java:310) ~[blob_p-d8bf403a8a51c95305f1ab59a0ff39a6467603a6-afd009f29d87580cf4db55ed4d073f62:?]
	at org.apache.flink.connector.kafka.sink.KafkaCommitter.getRecoveryProducer(KafkaCommitter.java:143) ~[blob_p-d8bf403a8a51c95305f1ab59a0ff39a6467603a6-afd009f29d87580cf4db55ed4d073f62:?]
	at org.apache.flink.connector.kafka.sink.KafkaCommitter.lambda$commit$0(KafkaCommitter.java:72) ~[blob_p-d8bf403a8a51c95305f1ab59a0ff39a6467603a6-afd009f29d87580cf4db55ed4d073f62:?]
	at java.util.Optional.orElseGet(Unknown Source) ~[?:?]
	at org.apache.flink.connector.kafka.sink.KafkaCommitter.commit(KafkaCommitter.java:72) ~[blob_p-d8bf403a8a51c95305f1ab59a0ff39a6467603a6-afd009f29d87580cf4db55ed4d073f62:?]
	at org.apache.flink.streaming.runtime.operators.sink.committables.CheckpointCommittableManagerImpl.commit(CheckpointCommittableManagerImpl.java:126) ~[flink-dist-1.18.1.jar:1.18.1]
	at org.apache.flink.streaming.runtime.operators.sink.CommitterOperator.commitAndEmit(CommitterOperator.java:176) ~[flink-dist-1.18.1.jar:1.18.1]
	at org.apache.flink.streaming.runtime.operators.sink.CommitterOperator.commitAndEmitCheckpoints(CommitterOperator.java:160) ~[flink-dist-1.18.1.jar:1.18.1]
	at org.apache.flink.streaming.runtime.operators.sink.CommitterOperator.initializeState(CommitterOperator.java:121) ~[flink-dist-1.18.1.jar:1.18.1]
	at org.apache.flink.streaming.api.operators.StreamOperatorStateHandler.initializeOperatorState(StreamOperatorStateHandler.java:122) ~[flink-dist-1.18.1.jar:1.18.1]
	at org.apache.flink.streaming.api.operators.AbstractStreamOperator.initializeState(AbstractStreamOperator.java:274) ~[flink-dist-1.18.1.jar:1.18.1]
	at org.apache.flink.streaming.runtime.tasks.RegularOperatorChain.initializeStateAndOpenOperators(RegularOperatorChain.java:106) ~[flink-dist-1.18.1.jar:1.18.1]
	at org.apache.flink.streaming.runtime.tasks.StreamTask.restoreGates(StreamTask.java:753) ~[flink-dist-1.18.1.jar:1.18.1]
	at org.apache.flink.streaming.runtime.tasks.StreamTaskActionExecutor$1.call(StreamTaskActionExecutor.java:55) ~[flink-dist-1.18.1.jar:1.18.1]
	at org.apache.flink.streaming.runtime.tasks.StreamTask.restoreInternal(StreamTask.java:728) ~[flink-dist-1.18.1.jar:1.18.1]
	at org.apache.flink.streaming.runtime.tasks.StreamTask.restore(StreamTask.java:693) ~[flink-dist-1.18.1.jar:1.18.1]
	at org.apache.flink.runtime.taskmanager.Task.runWithSystemExitMonitoring(Task.java:953) [flink-dist-1.18.1.jar:1.18.1]
	at org.apache.flink.runtime.taskmanager.Task.restoreAndInvoke(Task.java:922) [flink-dist-1.18.1.jar:1.18.1]
	at org.apache.flink.runtime.taskmanager.Task.doRun(Task.java:746) [flink-dist-1.18.1.jar:1.18.1]
	at org.apache.flink.runtime.taskmanager.Task.run(Task.java:562) [flink-dist-1.18.1.jar:1.18.1]
	at java.lang.Thread.run(Unknown Source) [?:?]
Caused by: java.lang.NoSuchFieldException: txnPartitionMap
	at java.lang.Class.getDeclaredField(Unknown Source) ~[?:?]
	at org.apache.flink.connector.kafka.sink.FlinkKafkaInternalProducer.getField(FlinkKafkaInternalProducer.java:281) ~[blob_p-d8bf403a8a51c95305f1ab59a0ff39a6467603a6-afd009f29d87580cf4db55ed4d073f62:?]
	... 22 more
g
did you migrate Kafka source/sink apis as well?
r
I believe so, it was:
Copy code
kafka-clients from 2.7.2 to 3.2.3
flink-kafka-connector-kafka from 1.15.2 (flink version) to 3.1.0-1.18
g
yea but the question is whether you are using a different api. Did you migrate from:
Copy code
FlinkKafkaProducer -> KafkaSink?
r
Nope, I was previously using the KafkaSink itself
g
okay, then I don’t know but seems to be some state incompatibility in the KafkaSink itself
r
Didn’t change any of the APIs around those (except for a deprecated
setDeliveryGuarantee(…)
call)
Okay, I’ll bubble it up to the larger #troubleshooting channel to see if anyone has any ideas. I appreciate it!
g
np