Skip to content
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

Add servergroup policy and rules field support #1382

Merged
merged 3 commits into from Mar 14, 2023

Conversation

Tjev
Copy link
Contributor

@Tjev Tjev commented May 31, 2022

Should resolve #1143.

Addition of policy and rules fields, which replace the policies field since API microversion 2.64. Support for the fields has already been added to Gophercloud.

@nikParasyr
Copy link
Member

@Tjev Sorry for the very long delay. CI has been fixed and I rebased to run the tests etc. could you check as the servergroup tests are failing

@Tjev
Copy link
Contributor Author

Tjev commented Jul 21, 2022

Hello @nikParasyr, I fixed the linter errors and amended the changes. Could I please ask for a re-run of the CI?

@Tjev Tjev force-pushed the servergroup-v264 branch 6 times, most recently from 6a4a198 to 946c752 Compare September 22, 2022 09:43
@Tjev
Copy link
Contributor Author

Tjev commented Sep 22, 2022

Hello @nikParasyr, could I ask for some guidance please? I am not sure why the acceptance tests are failing right now.. :/

@nikParasyr
Copy link
Member

@Tjev ill try to find some time this week to have a look as there is a lot going on atm. sorry for the delay

Copy link
Member

@nikParasyr nikParasyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Tjev , I actually had some time now :)

I've added some comments in the review.

Moreover, for the tests failing I see in the logs:

2022-09-22T10:31:31.8755532Z   |   # openstack_compute_servergroup_v2.sg_1 must be replaced
2022-09-22T10:31:31.8755973Z   | -/+ resource "openstack_compute_servergroup_v2" "sg_1" {
2022-09-22T10:31:31.8756461Z   |       ~ id       = "89ac55b0-baac-46e5-b2be-306dc0851d33" -> (known after apply)
2022-09-22T10:31:31.8756913Z   |       ~ members  = [] -> (known after apply)
2022-09-22T10:31:31.8757160Z   |         name     = "sg_1"
2022-09-22T10:31:31.8757419Z   |       - policies = [
2022-09-22T10:31:31.8757693Z   |           - "affinity",
2022-09-22T10:31:31.8758004Z   |         ] -> null # forces replacement
2022-09-22T10:31:31.8758364Z   |       ~ region   = "RegionOne" -> (known after apply)
2022-09-22T10:31:31.8758664Z   |         # (1 unchanged attribute hidden)
2022-09-22T10:31:31.8758888Z   |     }

for multiple tests. This basically indicated that the Read function is not working properly.
From reading a bit the docs here it looks like policies is available till 2.63 and then from 2.64 policy and rules are available.
In the Read function you dont set Microversion which means that you could set policy/rules on the create, but will not read these proeprties as its using <=2.63 microversion and thus not set them.

So i would first try to read with 2.64 MicroVersion and if its successful set policy and rules, otherwise if i get an error i'd try to read without setting a Microversion and set policies. If i still get an error then just return the error.

I hope this makes sense.

@Tjev
Copy link
Contributor Author

Tjev commented Sep 30, 2022

Hello again @nikParasyr !
Thanks a lot for the help. I tried to reflect your feedback in the changes I made. Hopefully everything seems ok now (and the pipeline passes 😄).

Copy link
Member

@nikParasyr nikParasyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Tjev Im not sure why the ci is not running. I tried to kick it but it doesnt. In any case. I've made a couple of comments. Hopefully when you push these changes the ci will work properly. Also

gofmt -s -w .

before comitting will save you from various linting issues

openstack/resource_openstack_compute_servergroup_v2.go Outdated Show resolved Hide resolved
openstack/resource_openstack_compute_servergroup_v2.go Outdated Show resolved Hide resolved
@Tjev
Copy link
Contributor Author

Tjev commented Nov 2, 2022

Hello @nikParasyr, once again, I tried to include your feedback. Sorry for the formatting errors, I had some issues with my local go env (gofmt would not work, etc..) and I didn't have enough time on my hands to fix it properly. I was now able to format as instructed (gofmt -s -w .).

I left the singular check for presence of policy field in order to properly set the microversion used. Hopefully the changes look okay now.

@kayrus
Copy link
Collaborator

kayrus commented Mar 11, 2023

@Tjev I rebased your PR to trigger tests.

@kayrus kayrus force-pushed the servergroup-v264 branch 6 times, most recently from b84dd7e to a8b4ca4 Compare March 13, 2023 16:31
@kayrus kayrus force-pushed the servergroup-v264 branch 2 times, most recently from 59242cc to fd26060 Compare March 13, 2023 19:00
Copy link
Collaborator

@kayrus kayrus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@nikParasyr nikParasyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nikParasyr nikParasyr merged commit b790fbf into terraform-provider-openstack:main Mar 14, 2023
@Tjev
Copy link
Contributor Author

Tjev commented Mar 14, 2023

Thank you @nikParasyr & @kayrus !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RFE: Add support for "rules" in compute_servergroup_v2
3 participants