Make state.orchestrate retcode aware

Fix #18413