GalleyBytes / terraform-operator

A Kubernetes CRD to handle terraform operations
http://tf.galleybytes.com
Apache License 2.0
364 stars 47 forks source link

Names longer than 63 chars crash operator completely #169

Closed lallinger-tech closed 4 months ago

lallinger-tech commented 4 months ago

Creating a terraform CR with a name longer than 63 chars results in the operator crashing hard (not even crash loop backoff but recreation and immediate crash of the pod). The issue arises as the operator uses labels to track some information, but labels are limited to 63 chars vs metadata.name length may be 253 chars: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/

The easiest way to get around this problem is to switch from labels to annotations as there the value can be almost arbitrarily long and only the key needs to follow these constraints: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/#syntax-and-character-set

isaaguilar commented 4 months ago

I do like label-selectors over annotations (via field-selectors). Since I use labels to track resources, I wouldn't want to change code. It should be safe enough to truncate label values at 63 chars, right?

lallinger-tech commented 4 months ago

truncating could lead to 2 resources having the same label, imagine the two resources only start differing from each other after char 63. Hashing would be an option, but this would make it non human readable..

isaaguilar commented 4 months ago

I'll get to making it an annotation soon. Thanks for the input! :)

lallinger-tech commented 4 months ago

thank you very much!! :)

isaaguilar commented 4 months ago

I'll get to making it an annotation soon. Thanks for the input! :)

I know I said I'd do annotations, but for simplicity and a small technical detail, I went with a hash instead of the long label value. #170

lallinger-tech commented 4 months ago

works for me, thanks for the fast implementation!