-
Notifications
You must be signed in to change notification settings - Fork 9.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cloud: Allows object tag schema for selecting key/value tagged workspaces #35907
Conversation
When key-value tags are enabled and used in the workspace, users may define the tags attribute as a map of strings in the cloud block in order to more precicely match workspaces using those tags.
05d8a3e
to
e87335a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From smoke testing I'm seeing a couple problems
In using the old single value tags:
Cloud Block:
cloud {
hostname = "app.staging.terraform.io"
organization = "markdecrane"
workspaces {
tags = ["app", "test"]
}
}
Besides the fact that this is occuring, it seems odd to me that the errors Error: failed to create backend alias to target "". The hostname is not in the correct format.
and Error: Invalid workspaces configuration
are given when an incorrect type for tags
is given. Saw nearly the same diags on the console when giving tags
the value of a single string.
![Screenshot 2024-10-28 at 5 40 43 PM](https://private-user-images.githubusercontent.com/72527044/380902272-acd6fc98-b919-473c-b4d5-76a6e479bbed.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk4NjM0NTQsIm5iZiI6MTczOTg2MzE1NCwicGF0aCI6Ii83MjUyNzA0NC8zODA5MDIyNzItYWNkNmZjOTgtYjkxOS00NzNjLWI0ZDUtNzZhNmU0NzliYmVkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE4VDA3MTkxNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWQ2ODYxZTIwMTU4Yzc1ZDJiYjllNjU4NzU3ZWE0ODE5YWE1NTQ1MGUyZDEzNGNlN2FiZWJlNmUyYWZjMzI2ZmEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.SxU6N2IIlg4ORpUha64F7WAKgL7J34_hg9qWsYI0F4Q)
Nil panics when the value of of tag is not a string
I'm also seeing a need for some more error handling as I get nil panics when the value of of tag is not a string:
![Screenshot 2024-10-28 at 5 55 15 PM](https://private-user-images.githubusercontent.com/72527044/380905258-8745e6ec-5f09-4341-b812-2878a522ac03.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk4NjM0NTQsIm5iZiI6MTczOTg2MzE1NCwicGF0aCI6Ii83MjUyNzA0NC8zODA5MDUyNTgtODc0NWU2ZWMtNWYwOS00MzQxLWI4MTItMjg3OGE1MjJhYzAzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE4VDA3MTkxNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWYwNzVlODU4ODlkZDA3OWFlNTM1ZjYyYTlhMDJmZDE3MjI2MDlmNWI3MWY0ZWIxZGExYzcyODRkZTJlNWJiOGYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.ie_vJy1xEP8fCZT6oeXFRMOhQjtH5B-ouogjGZxlZPM)
Weirdly not a problem when the key itself is not a string
workspaces {
tags = {
1 = "foo"
2 = "bar"
}
}
![Screenshot 2024-10-28 at 5 56 32 PM](https://private-user-images.githubusercontent.com/72527044/380905518-872851c7-e242-478a-9cc9-8a0ef21b16ab.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk4NjM0NTQsIm5iZiI6MTczOTg2MzE1NCwicGF0aCI6Ii83MjUyNzA0NC8zODA5MDU1MTgtODcyODUxYzctZTI0Mi00NzhhLTljYzktOGEwZWYyMWIxNmFiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE4VDA3MTkxNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWY4Yzk2NGZkNjRmYjk1OTM5NDVmOWRjNjk2MTk4YmYzZDQxYjE4ZTk5NTY2MzVlNjk0N2IwMzEwZTYxZjgxNDgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.xQ0VOPv_3FQvKJnHw_eDWoc-QgLUVfMzPxXeePskCVY)
Looks as though it's somehow treated as a string considering it doesn't break things at any point in the workflow, despite this error message I came across when specifying the key as a set, dictating that the key must be a string:
![Screenshot 2024-10-28 at 6 02 29 PM](https://private-user-images.githubusercontent.com/72527044/380906557-a8141f32-a7bb-437a-aca3-432823630b3a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk4NjM0NTQsIm5iZiI6MTczOTg2MzE1NCwicGF0aCI6Ii83MjUyNzA0NC8zODA5MDY1NTctYTgxNDFmMzItYTdiYi00MzdhLWFjYTMtNDMyODIzNjMwYjNhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE4VDA3MTkxNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWJiNTFiOTJjYzVkYzJiZDk0NzRjZmM5OTk3NGI3YWMwZDYxYTY5MTcwM2M4YWMxNzg1ZDc2YTUxZDNmMmQ4YTcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.ZxIecCdGcBwd_q-Kk5HJc1cArvs2CY-aPaQ_x4DpEbo)
@Maed223 thanks for the thorough testing! There was an interesting mismatch between the existing tests and the actual type that happens when you write config (Set vs Tuple) which broke the legacy use cases! Glad we caught that. I also detected and fixed the case when element types were not strings. In the case of keys not being strings, that's built into the syntax of the language (all object/map keys are strings). For instance, you can define an object like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple more behavioral oddities I detected, one of which might be on the atlas API side of things but I'll note here.
Single-Value-Tag/ KV-Tag matching
Saw that choosing a workspace when single value tags (in config) are matched to the key values of KV tags (on the workspace) there's a duplication of the tags– in that the KV tags that are being matched to are persisted and additional single value legacy tags are created on the workspace.
For example:
workspaces {
tags = ["app", "test"]
}
![Screenshot 2024-10-29 at 11 31 14 AM](https://private-user-images.githubusercontent.com/72527044/381197497-cd6ebc16-deb5-4394-bc8c-6c2b6372ffc2.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk4NjM0NTQsIm5iZiI6MTczOTg2MzE1NCwicGF0aCI6Ii83MjUyNzA0NC8zODExOTc0OTctY2Q2ZWJjMTYtZGViNS00Mzk0LWJjOGMtNmMyYjYzNzJmZmMyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE4VDA3MTkxNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPThiNWExMDg1OTEyMTlkZGQ2NzQwZmZiYTYzZDE4ZTc4ZDFmODc1MmQ4M2NkNGE2Y2ExYjg3ZjY2ZWMxZjQ4OTkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.DtCmAcZFA9Q_P07fzNv8YRQabYh4ZXuiu6oebPIvNTc)
![Screenshot 2024-10-29 at 11 31 29 AM](https://private-user-images.githubusercontent.com/72527044/381197602-0a92eee2-8f19-4d87-8a75-28126af2f953.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk4NjM0NTQsIm5iZiI6MTczOTg2MzE1NCwicGF0aCI6Ii83MjUyNzA0NC8zODExOTc2MDItMGE5MmVlZTItOGYxOS00ZDg3LThhNzUtMjgxMjZhZjJmOTUzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE4VDA3MTkxNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTE1NTAxZGI1YTM5MzZmMDhlZDIzYzU2Y2NhMDQwMjk4OGU4NDljMDc4ZjU1NjA4MmVlMmQ1NjAwZGQwNGE5ZDAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.HxE1ckp1RVKMSQGojqvsdX2cOdeC96O2f5sNdyY2bZQ)
Also saw that the inverse of this occurs as well. As in KV tags in config matching to single value tags on a workspace persists the single value tags, while adding the new KV tags.
Wondering what the intention is for the behavior here. I can see the value in adding the KV tags when the workspace only has the single value tags considering the KV tags hold more info (but should the original legacy tags persist?), but less so for the inverse case. No strong opinion here, just saw that this aspect wasn't specifically discussed in the RFC.
Extraneous error message when giving incorrect type to value of KV tag
Less than before, but still seeing the error related to the hostname when giving a non-string value as a KV tag's value. Not breaking, but feels less than ideal.
@Maed223 These are interesting questions and yes, a mismatch between how workspaces are found vs how "workspaceTagsRequireUpdate" detects. I do think I want to refine the behavior, but since the beta is getting cut tomorrow, do you mind if we merge it in this state and refine it during the beta period? I'll look into the alias error as well, but I think that is unrelated to the change. |
Reminder for the merging maintainer: if this is a user-visible change, please update the changelog on the appropriate release branch. |
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. |
When key-value tags are enabled and used in the workspace, users may define the tags attribute as a map of strings in the cloud block in order to more precisely match workspaces using those tags.
Target Release
1.10.x
Draft CHANGELOG entry
ENHANCEMENTS
Example output: init cloud block with kv tags