Skip to content

vSwitch and SecurityGroup query refactor#12

Merged
openshift-merge-robot merged 2 commits intoopenshift:mainfrom
kwoodson:gh_comments
Nov 17, 2021
Merged

vSwitch and SecurityGroup query refactor#12
openshift-merge-robot merged 2 commits intoopenshift:mainfrom
kwoodson:gh_comments

Conversation

@kwoodson
Copy link
Contributor

@kwoodson kwoodson commented Nov 9, 2021

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.

@kwoodson
Copy link
Contributor Author

kwoodson commented Nov 9, 2021

@JoelSpeed I have some questions about testing this. Due to our renaming in the go.mod to module github.com/openshift/... the installer repository does not like the replace directive as we are renaming. I can get around this but I have to refactor code to make the libraries match which backtracks a bit of the work in this PR. If you have a few minutes to spare tomorrow that would be great.

@kwoodson kwoodson force-pushed the gh_comments branch 3 times, most recently from e17d0ed to f3295ab Compare November 12, 2021 03:09
@kwoodson
Copy link
Contributor Author

@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.

NAME                                 STATUS   ROLES    AGE     VERSION
test-6m9rh-master-0                  Ready	master   137m    v1.22.1+f773b8b
test-6m9rh-master-1                  Ready	master   136m    v1.22.1+f773b8b
test-6m9rh-master-2                  Ready	master   138m    v1.22.1+f773b8b
test-6m9rh-worker-us-east-1a-v2wn5   Ready	worker   28m     v1.22.1+f773b8b
test-6m9rh-worker-us-east-1b-8dlqd   Ready    worker   81s     v1.22.1+f773b8b
test-6m9rh-worker-us-east-1b-xwzhd   Ready    worker   3m40s   v1.22.1+f773b8b
NAME                                 PHASE     TYPE            REGION	   ZONE         AGE
test-6m9rh-master-0                  Running   ecs.g6.xlarge   us-east-1   us-east-1b   139m
test-6m9rh-master-1                  Running   ecs.g6.xlarge   us-east-1   us-east-1a   139m
test-6m9rh-master-2                  Running   ecs.g6.xlarge   us-east-1   us-east-1b   139m
test-6m9rh-worker-us-east-1a-v2wn5   Running   ecs.g6.large    us-east-1   us-east-1a   32m
test-6m9rh-worker-us-east-1b-8dlqd   Running   ecs.g6.large    us-east-1   us-east-1b   6m
test-6m9rh-worker-us-east-1b-xwzhd   Running   ecs.g6.large    us-east-1   us-east-1b   7m40s

Comment on lines 226 to 227
// Filters is a set of metadata based upon ECS object tags used to identify a resource
Tags []Tag `json:"tags,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment doesn't match the field name, did we intend to rename the filed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will rename.

Comment on lines 380 to 382
if machineProviderConfig.SecurityGroups == nil {
return nil, errors.New("no security configuration provided")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a different between nil and an empty slice that would make this not work. Best to use len which handles both cases

Suggested change
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")
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This makes sense since we create it on the previous line. I will update.

Comment on lines 405 to 410
if machineProviderConfig.VpcID != "" {
request.VpcId = machineProviderConfig.VpcID
}
if machineProviderConfig.ResourceGroupID != "" {
request.ResourceGroupId = machineProviderConfig.ResourceGroupID
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Do these need to be behind if statements?

Copy link
Contributor Author

@kwoodson kwoodson Nov 12, 2021

Choose a reason for hiding this comment

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

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.

Comment on lines 482 to 484
if mpc.VpcID != "" {
describeVSwitchesRequest.VpcId = mpc.VpcID
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need to be behind an if statement?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will remove and test.

Comment on lines 497 to 498
klog.Errorf("no vswitches for given tags not found")
return "", fmt.Errorf("no vswitches for given tags not found")
Copy link
Contributor

Choose a reason for hiding this comment

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

These messages are not parsing for me, what are we trying to say here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need to be a pointer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

@kwoodson
Copy link
Contributor Author

kwoodson commented Nov 12, 2021

@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

Copy link
Contributor

@elmiko elmiko left a comment

Choose a reason for hiding this comment

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

this generally looks good to me
/approve

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 16, 2021

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 16, 2021
Copy link
Contributor

@JoelSpeed JoelSpeed left a comment

Choose a reason for hiding this comment

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

/lgtm

One nit, but it's not blocking, let's merge this and we can clean it up down the line if needs be

Comment on lines +387 to +388
} else {
if sg.Tags != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Looks like this could be an else if and reduce indentation by 1 level

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments