We do have this in a table:
Button is disabled until a row is selected.
I would use a link for this type of inline action, a button doesn’t seem necessary (visually). Regarding displaying the link, it is weird to just hide it in some situations (if you have situations where it IS possible to Retry), the user might think “why can’t I retry? there was an option here before…”. A solution for that would be to inform that it is not possible to retry. You could have, for example:
X Failed (not possible to retry)
UX designer @ Red Hat