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 satellite features and add support to the user can direct which security groups are added to their workers #4953

Merged
merged 1 commit into from
Jan 16, 2024

Conversation

Blintmester
Copy link
Contributor

@Blintmester Blintmester commented Nov 27, 2023

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Relates OR Closes #0000

Output from acceptance testing:

$ make testacc TEST=./ibm/service/satellite TESTARGS='-run=TestAccSatelliteLocation_PodAndServiceSubnet'

--- PASS: TestAccSatelliteLocation_PodAndServiceSubnet (1187.34s)
PASS
ok      command-line-arguments  1187.409s

@Blintmester Blintmester marked this pull request as ready for review December 14, 2023 14:20
@Blintmester Blintmester force-pushed the satellite-features branch 2 times, most recently from dcae8af to 6ebdc51 Compare December 14, 2023 14:48
go.mod Outdated
@@ -237,8 +237,12 @@ replace github.com/dgrijalva/jwt-go v3.2.0+incompatible => github.com/golang-jwt

replace github.com/portworx/sched-ops v0.0.0-20200831185134-3e8010dc7056 => github.com/portworx/sched-ops v0.20.4-openstorage-rc3 // required by rook v1.7

replace github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20231106114255-c50117860a3c => github.com/Blintmester/container-services-go-sdk v0.0.0-20231116135145-fae5e6201d4c // for development only
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe these can go, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, my mistake, fixed it

@Blintmester Blintmester force-pushed the satellite-features branch 2 times, most recently from cfc7b9e to b0beebd Compare December 15, 2023 07:23
@dawall1mn
Copy link

I see the update to allow security groups on vpc create cluster. It was not obvious this PR also includes support to specify security groups on vpc worker pool create. Is that included?

@@ -322,6 +322,14 @@ func ResourceIBMContainerVpcCluster() *schema.Resource {
RequiredWith: []string{"kms_instance_id", "crk"},
},

"cluster_security_groups": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we rename this argument security_groups because the resource already indicates its a cluster

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, I renamed it

@@ -138,6 +138,18 @@ func DataSourceIBMSatelliteLocation() *schema.Resource {
},
},
},
"service_subnet": {
Type: schema.TypeString,
Copy link
Collaborator

Choose a reason for hiding this comment

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

In datasource these should be computed only remove optional and forceNew.
Same for pod_subnet also

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed it

@hkantare
Copy link
Collaborator

hkantare commented Dec 18, 2023

Fix conflicts in go.mod and go.sum files
Update the respective docs files for new argumets added
security_groups were added only for vpc_cluster should we added for worker_pool resource also

@Blintmester
Copy link
Contributor Author

Fix conflicts in go.mod and go.sum files Update the respective docs files for new argumets added security_groups were added only for vpc_cluster should we added for worker_pool resource also

If I can fix everything, go.mod and go.sum files will be fixed.

Currently I try to add security_groups to worker_pool resource, will check in if its done!

@Blintmester
Copy link
Contributor Author

If everything is fine, I'll fix the go.mod conflicts too.

@Blintmester Blintmester force-pushed the satellite-features branch 3 times, most recently from 936af91 to 1c72212 Compare January 10, 2024 13:54
@Blintmester
Copy link
Contributor Author

@hkantare I pushed the docs files too, please can you review it?

@Blintmester Blintmester force-pushed the satellite-features branch 2 times, most recently from db74ef3 to e007250 Compare January 10, 2024 14:08
Comment on lines 255 to 260
elems := make([]string, 0)
for _, elem := range set.List() {
elems = append(elems, elem.(string))
}
return elems
Copy link
Contributor

Choose a reason for hiding this comment

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

this can be optimised a bit. if you set the capacity of the slice in the make, you can minimise the memory allocations during the appends ( https://stackoverflow.com/questions/57100525/how-does-go-slice-capacity-change-on-append )

ps: you can achieve similar results by setting the length as in FlattenZonesv2

Suggested change
elems := make([]string, 0)
for _, elem := range set.List() {
elems = append(elems, elem.(string))
}
return elems
setList := set.List()
elems := make([]string, 0, len(setList))
for _, elem := range setList {
elems = append(elems, elem.(string))
}
return elems

@@ -322,6 +322,14 @@ func ResourceIBMContainerVpcCluster() *schema.Resource {
RequiredWith: []string{"kms_instance_id", "crk"},
},

"security_groups": {
Copy link
Contributor

Choose a reason for hiding this comment

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

it looks like this parameter can only be set at create
you can use DiffSuppressFunc: flex.ApplyOnce to ignore any changes to the parameter

or

it can be marked with forcenew to recreate the cluster if this param is changed. this means the original cluster will be deleted, so this should be handled with extra care

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should go with ApplyOnce rather than ForceNew.

At the moment, these values can not be changed in the API. If the ability to change the security groups was added in the future and customers update the security groups outside of TF, TF would replace the cluster.

If we go with ApplyOnce, the changes would be ignored until the TF provider supported that functionality at which point we could provide guidance to customers on importing the updated changes and avoid cluster deletion.

@@ -42,7 +44,7 @@ func ResourceIBMContainerWorkerPool() *schema.Resource {
"cluster"),
},

"machine_type": {
"flavor": {
Copy link
Contributor

Choose a reason for hiding this comment

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

please don't convert this resource to vpc, there is already a vpc_worker_pool one

Elem: &schema.Schema{Type: schema.TypeString},
Set: flex.ResourceIBMVPCHash,
},

Copy link
Contributor

Choose a reason for hiding this comment

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

it looks like it is missing from the API, but...
should we be able to set SecurityGroupIDs to the default workerpool too?


zones {
name = "us-south-1"
subnet_id = "0716-2389b003-7968-41b1-833c-4d63d7165899"
Copy link
Contributor

Choose a reason for hiding this comment

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

please remove the real ids from the example. you can add variables instead

Optional: true,
ForceNew: true,
Description: "Custom subnet CIDR to provide private IP addresses for services",
//Computed: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

if it is not needed, please remove it

// flattenHostLabels ..
func FlattenHostLabels(hostLabels []interface{}) map[string]string {
// flatten the provided key-value pairs
func FlattenKeyValues(keyValues []interface{}) map[string]string {
Copy link
Contributor

Choose a reason for hiding this comment

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

why did you rename this function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

previously it was used only for flatten Host Labels, but I renamed it and we can use it for everything when we should flatten key-values (map[string]string), and I used it too (and it was not host labels)

@@ -280,6 +280,12 @@ func ResourceIBMSatelliteCluster() *schema.Resource {
Sensitive: true,
Description: "The IBM Cloud Identity and Access Management (IAM) service CRN token for the service that creates the cluster.",
},
"calico_ip_autodetection": {
Copy link
Contributor

Choose a reason for hiding this comment

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

is it only for create too? maybe ApplyOnce or forcenew?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, it is only for create, so I'll add ApplyOnce

@Blintmester Blintmester force-pushed the satellite-features branch 2 times, most recently from 3798d04 to 2348b4c Compare January 12, 2024 14:13
@@ -212,6 +212,14 @@ func ResourceIBMContainerVpcWorkerPool() *schema.Resource {
Computed: true,
Description: "Autoscaling is enabled on the workerpool",
},

"security_groups": {
Copy link
Contributor

Choose a reason for hiding this comment

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

can you please add the ApplyOnce diff suppress here too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, will do

resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
Providers: acc.TestAccProviders,
// CheckDestroy: testAccCheckIBMContainerVpcClusterDestroy,
Copy link
Contributor

Choose a reason for hiding this comment

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

why is it commented out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the CheckDestroy function fails on every run, because it doesn't wait enough, or something else, I don't really know, but the resource (after a failed run) was destroyed successfully

@@ -212,6 +212,14 @@ func ResourceIBMContainerVpcWorkerPool() *schema.Resource {
Computed: true,
Description: "Autoscaling is enabled on the workerpool",
},

"security_groups": {
Copy link
Contributor

Choose a reason for hiding this comment

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

can you please add a test for this too?

zones = var.location_zones
managed_from = var.managed_from
resource_group_id = data.ibm_resource_group.group.id
pod_subnet = var.pod_subnet // "10.42.0.0/16"
Copy link
Contributor

Choose a reason for hiding this comment

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

can you please fix the formatting in the example?

@Blintmester Blintmester force-pushed the satellite-features branch 2 times, most recently from 7a9e876 to 5a1368e Compare January 15, 2024 09:58
@hkantare hkantare merged commit 7fc2c5a into IBM-Cloud:master Jan 16, 2024
1 check passed
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.

5 participants