vSwitch and SecurityGroup query refactor#12
vSwitch and SecurityGroup query refactor#12openshift-merge-robot merged 2 commits intoopenshift:mainfrom
Conversation
|
@JoelSpeed I have some questions about testing this. Due to our renaming in the go.mod to |
863f125 to
422c10e
Compare
e17d0ed to
f3295ab
Compare
|
@JoelSpeed @elmiko This PR addresses the feedback left for #11. Please review and let me know if there is anything you would like me to fix. I was able to test this code and the machinesets successfully created the nodes. |
| // Filters is a set of metadata based upon ECS object tags used to identify a resource | ||
| Tags []Tag `json:"tags,omitempty"` |
There was a problem hiding this comment.
This comment doesn't match the field name, did we intend to rename the filed?
There was a problem hiding this comment.
I was going to go filters but Tags are actually used and the structure for AWS didn't align here. AWS can have a single key and multiple values. Where as here, it is 1:1 for key:value. I think Tags is appropriate.
pkg/actuators/machine/instances.go
Outdated
| if machineProviderConfig.SecurityGroups == nil { | ||
| return nil, errors.New("no security configuration provided") | ||
| } |
There was a problem hiding this comment.
There's a different between nil and an empty slice that would make this not work. Best to use len which handles both cases
| if machineProviderConfig.SecurityGroups == nil { | |
| return nil, errors.New("no security configuration provided") | |
| } | |
| if len(machineProviderConfig.SecurityGroups) == 0 { | |
| return nil, errors.New("no security configuration provided") | |
| } |
There was a problem hiding this comment.
This makes sense since we create it on the previous line. I will update.
pkg/actuators/machine/instances.go
Outdated
| if machineProviderConfig.VpcID != "" { | ||
| request.VpcId = machineProviderConfig.VpcID | ||
| } | ||
| if machineProviderConfig.ResourceGroupID != "" { | ||
| request.ResourceGroupId = machineProviderConfig.ResourceGroupID | ||
| } |
There was a problem hiding this comment.
Do these need to be behind if statements?
There was a problem hiding this comment.
I honestly do not know. I was reusing the code that was already there. Although it appears in the DescribeSecurityGroups API call that when making the request the VpcId and the ResourceGroupID looks like this:
VpcId: (string) ""
ResourceGroupId: (string) (len=18) "rg-acfnxrgr6qtm3mq",
so I think you are probably on to something. Setting them to whatever the default is on the machineProviderConfig would probably work since it is defaulting them to empty anyway.
pkg/actuators/machine/instances.go
Outdated
| if mpc.VpcID != "" { | ||
| describeVSwitchesRequest.VpcId = mpc.VpcID | ||
| } |
There was a problem hiding this comment.
Does this need to be behind an if statement?
There was a problem hiding this comment.
Will remove and test.
pkg/actuators/machine/instances.go
Outdated
| klog.Errorf("no vswitches for given tags not found") | ||
| return "", fmt.Errorf("no vswitches for given tags not found") |
There was a problem hiding this comment.
These messages are not parsing for me, what are we trying to say here?
There was a problem hiding this comment.
This was left over from the original code. I will update. Basically with the provided tags, vpcid, and regionid the query did not return any security groups.
| //This parameter is required when you create an instance of the VPC type. | ||
| //You can call the DescribeVSwitches operation to query the created vSwitches. | ||
| VSwitch *ResourceTagReference `json:"vSwitch,omitempty"` | ||
| VSwitch *AlibabaResourceReference `json:"vSwitch,omitempty"` |
There was a problem hiding this comment.
Does this need to be a pointer?
There was a problem hiding this comment.
I saw examples in the AWS where it was so I went with that. I now also see examples where it does not need to be. I'll try and remove the pointer.
f3295ab to
b73af66
Compare
|
@elmiko @JoelSpeed I have updated this PR from your comments. I have also created the corresponding installer PR here openshift/installer#5381. I have created 3 clusters using this code and all have been successful creates. This also included removing dependencies and getting updates to cluster-api-provider-{ovirt,openstack} and updates to machine-api-operator-openstack to remove older mao dependencies. Once this work is finished I will update the API #10 with the changes in this PR and being the migration to openshift/api. Please TAL |
elmiko
left a comment
There was a problem hiding this comment.
this generally looks good to me
/approve
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: elmiko, kwoodson The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
JoelSpeed
left a comment
There was a problem hiding this comment.
/lgtm
One nit, but it's not blocking, let's merge this and we can clean it up down the line if needs be
| } else { | ||
| if sg.Tags != nil { |
There was a problem hiding this comment.
Nit: Looks like this could be an else if and reduce indentation by 1 level
With the work going into #11, we wanted to tidy up the querying methods to be similar to other providers as well as prepare the API to be moved to openshift/api.
This pull request addresses the feedback given in #11 and I will work on a corresponding PR to the installer.