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

MULTIARCH-4096: PowerVS: Generate the cluster assets #8116

Merged
merged 8 commits into from Mar 26, 2024

Conversation

hamzy
Copy link
Contributor

@hamzy hamzy commented Mar 7, 2024

Generate the cluster assets for the PowerVS CAPI provider.

This has no included code written over two weeks.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Mar 7, 2024
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Mar 7, 2024

@hamzy: This pull request references MULTIARCH-4096 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the sub-task to target the "4.16.0" version, but no target version was set.

In response to this:

Generate the cluster assets for the PowerVS CAPI provider.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot requested review from r4f4 and sadasu March 7, 2024 13:07
@hamzy hamzy force-pushed the PowerVS-MULTIARCH-4096 branch 5 times, most recently from 3ffb4ce to ad5f3ac Compare March 13, 2024 19:59
@hamzy hamzy force-pushed the PowerVS-MULTIARCH-4096 branch 5 times, most recently from 5f81298 to 014741f Compare March 18, 2024 20:43
@hamzy
Copy link
Contributor Author

hamzy commented Mar 19, 2024

/retest-required

@hamzy hamzy force-pushed the PowerVS-MULTIARCH-4096 branch 3 times, most recently from ba9e604 to b3b23a0 Compare March 20, 2024 21:55
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Mar 20, 2024

@hamzy: This pull request references MULTIARCH-4096 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the sub-task to target the "4.16.0" version, but no target version was set.

In response to this:

Generate the cluster assets for the PowerVS CAPI provider.

This has no included code written over two weeks.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

pkg/asset/manifests/clusterapi/cluster.go Outdated Show resolved Hide resolved
if installConfig.Config.Platform.PowerVS.PowerVSResourceGroup != "" {
// @TODO is it a name or id?
resourceGroupName = installConfig.Config.Platform.PowerVS.PowerVSResourceGroup
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if installConfig.Config.Platform.PowerVS.PowerVSResourceGroup != "" {
// @TODO is it a name or id?
resourceGroupName = installConfig.Config.Platform.PowerVS.PowerVSResourceGroup
}

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 TODO means future work/investigation. I am trying to get this PR in so I don't have to juggle code for a month.

pkg/asset/manifests/powervs/cluster.go Outdated Show resolved Hide resolved
Comment on lines 96 to 97
default:
return nil, fmt.Errorf("GenerateClusterAssets: Region is empty")
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm guessing this is here just for completeness and you're already validating the region during the installconfig validation stage?

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, for completeness and to stop someone else from asking why no default.

ServiceInstance: &service,
Zone: &installConfig.Config.Platform.PowerVS.Zone,
ResourceGroup: &capibm.IBMPowerVSResourceReference{
Name: &resourceGroupName,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Name: &resourceGroupName,
Name: &installConfig.Config.Platform.PowerVS.PowerVSResourceGroup,

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 is part of the future TODO

pkg/asset/manifests/powervs/cluster.go Outdated Show resolved Hide resolved
pkg/asset/manifests/powervs/cluster.go Outdated Show resolved Hide resolved
pkg/asset/installconfig/gcp/mock/usertags_mock.go Outdated Show resolved Hide resolved
pkg/asset/manifests/cloudproviderconfig.go Show resolved Hide resolved
pkg/asset/manifests/powervs/cluster.go Outdated Show resolved Hide resolved
@mjturek
Copy link
Contributor

mjturek commented Mar 23, 2024

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Mar 23, 2024
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Mar 23, 2024
@hamzy hamzy force-pushed the PowerVS-MULTIARCH-4096 branch 3 times, most recently from 0e224a7 to 6479343 Compare March 25, 2024 10:57
@mjturek
Copy link
Contributor

mjturek commented Mar 25, 2024

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Mar 25, 2024
@mjturek
Copy link
Contributor

mjturek commented Mar 25, 2024

/remove-lgtm

@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Mar 25, 2024
@mjturek
Copy link
Contributor

mjturek commented Mar 25, 2024

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Mar 25, 2024
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Mar 25, 2024
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 25, 2024
This adds a controller to run for the PowerVS provider.
Generate the cluster assets for the PowerVS CAPI provider.
Fix machine manifest generation and add a bootstrap machine.
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 25, 2024
When the CAPI infrastructure is ready,
1) Create the DNS entries
2) Add security group rules for necessary ports
The PowerVS CAPI controller creates three networks for each of the
endpoints.  Therefore, account for this change.
// Avoid empty manifest elements
logrus.Debugf("GenerateClusterAssets: len(VPCSubnets) = %d", len(installConfig.Config.Platform.PowerVS.VPCSubnets))
if len(installConfig.Config.Platform.PowerVS.VPCSubnets) > 0 {
powerVSCluster.Spec.VPCSubnets = make([]capibm.Subnet, 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: can preallocate the array here

Suggested change
powerVSCluster.Spec.VPCSubnets = make([]capibm.Subnet, 0)
powerVSCluster.Spec.VPCSubnets = make([]capibm.Subnet, 0, len(installConfig.Config.Platform.PowerVS.VPCSubnets)

Comment on lines +155 to +161
for i := range installConfig.Config.Platform.PowerVS.VPCSubnets {
// We cannot get the string in the loop and add it as it appears duplicated in the generated file
powerVSCluster.Spec.VPCSubnets = append(powerVSCluster.Spec.VPCSubnets,
capibm.Subnet{
ID: &installConfig.Config.Platform.PowerVS.VPCSubnets[i],
})
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: not that it matters, but you can get the string if you do:

Suggested change
for i := range installConfig.Config.Platform.PowerVS.VPCSubnets {
// We cannot get the string in the loop and add it as it appears duplicated in the generated file
powerVSCluster.Spec.VPCSubnets = append(powerVSCluster.Spec.VPCSubnets,
capibm.Subnet{
ID: &installConfig.Config.Platform.PowerVS.VPCSubnets[i],
})
}
for _, subnet := range installConfig.Config.Platform.PowerVS.VPCSubnets {
subnet := subnet
powerVSCluster.Spec.VPCSubnets = append(powerVSCluster.Spec.VPCSubnets,
capibm.Subnet{
ID: &subnet,
})
}

Comment on lines +129 to +135
logrus.Debugf("in.InfraID = %s", in.InfraID)
idx = strings.LastIndex(in.InfraID, "-")
logrus.Debugf("idx = %d", idx)
substr = in.InfraID[idx:]
logrus.Debugf("substr = %s", substr)
infraID = strings.ReplaceAll(in.InfraID, substr, "")
logrus.Debugf("infraID = %s", infraID)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
logrus.Debugf("in.InfraID = %s", in.InfraID)
idx = strings.LastIndex(in.InfraID, "-")
logrus.Debugf("idx = %d", idx)
substr = in.InfraID[idx:]
logrus.Debugf("substr = %s", substr)
infraID = strings.ReplaceAll(in.InfraID, substr, "")
logrus.Debugf("infraID = %s", infraID)
logrus.Debugf("in.InfraID = %s", in.InfraID)
infraID := in.InfraID[:strings.LastIndex(in.InfraID, "-")]
logrus.Debugf("infraID = %s", infraID)

Comment on lines +330 to +389
switch {
case refServiceInstance.ID != nil:
logrus.Debugf("PostProvision: CreateSSHKey: si id = %s, key = %s",
*refServiceInstance.ID,
in.InstallConfig.Config.SSHKey)

backoff := wait.Backoff{
Duration: 15 * time.Second,
Factor: 1.1,
Cap: leftInContext(ctx),
Steps: math.MaxInt32}
err = wait.ExponentialBackoffWithContext(ctx, backoff, func(context.Context) (bool, error) {
err2 := client.CreateSSHKey(ctx,
*refServiceInstance.ID,
*powerVSMachine.Status.Zone,
sshKeyName,
in.InstallConfig.Config.SSHKey)
if err2 == nil {
return true, nil
}
return false, err2
})
if err != nil {
return fmt.Errorf("failed to add SSH key for the workers(ID): %w", err)
}
case refServiceInstance.Name != nil:
logrus.Debugf("PostProvision: CreateSSHKey: si name = %s, key = %s",
*refServiceInstance.Name,
in.InstallConfig.Config.SSHKey)

vpc, err := client.GetVPCByName(ctx, *refServiceInstance.Name)
if err != nil {
return fmt.Errorf("failed to find id for VPC name %s: %w",
*refServiceInstance.Name,
err)
}

backoff := wait.Backoff{
Duration: 15 * time.Second,
Factor: 1.1,
Cap: leftInContext(ctx),
Steps: math.MaxInt32}
err = wait.ExponentialBackoffWithContext(ctx, backoff, func(context.Context) (bool, error) {
err2 := client.CreateSSHKey(ctx,
*vpc.ID,
*powerVSMachine.Status.Zone,
sshKeyName,
in.InstallConfig.Config.SSHKey)
if err2 == nil {
return true, nil
}
return false, err2
})
if err != nil {
return fmt.Errorf("failed to add SSH key for the workers(Name): %w", err)
}
default:
return fmt.Errorf("could not handle powerVSMachine.Spec.ServiceInstance")
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Nit:

Suggested change
switch {
case refServiceInstance.ID != nil:
logrus.Debugf("PostProvision: CreateSSHKey: si id = %s, key = %s",
*refServiceInstance.ID,
in.InstallConfig.Config.SSHKey)
backoff := wait.Backoff{
Duration: 15 * time.Second,
Factor: 1.1,
Cap: leftInContext(ctx),
Steps: math.MaxInt32}
err = wait.ExponentialBackoffWithContext(ctx, backoff, func(context.Context) (bool, error) {
err2 := client.CreateSSHKey(ctx,
*refServiceInstance.ID,
*powerVSMachine.Status.Zone,
sshKeyName,
in.InstallConfig.Config.SSHKey)
if err2 == nil {
return true, nil
}
return false, err2
})
if err != nil {
return fmt.Errorf("failed to add SSH key for the workers(ID): %w", err)
}
case refServiceInstance.Name != nil:
logrus.Debugf("PostProvision: CreateSSHKey: si name = %s, key = %s",
*refServiceInstance.Name,
in.InstallConfig.Config.SSHKey)
vpc, err := client.GetVPCByName(ctx, *refServiceInstance.Name)
if err != nil {
return fmt.Errorf("failed to find id for VPC name %s: %w",
*refServiceInstance.Name,
err)
}
backoff := wait.Backoff{
Duration: 15 * time.Second,
Factor: 1.1,
Cap: leftInContext(ctx),
Steps: math.MaxInt32}
err = wait.ExponentialBackoffWithContext(ctx, backoff, func(context.Context) (bool, error) {
err2 := client.CreateSSHKey(ctx,
*vpc.ID,
*powerVSMachine.Status.Zone,
sshKeyName,
in.InstallConfig.Config.SSHKey)
if err2 == nil {
return true, nil
}
return false, err2
})
if err != nil {
return fmt.Errorf("failed to add SSH key for the workers(Name): %w", err)
}
default:
return fmt.Errorf("could not handle powerVSMachine.Spec.ServiceInstance")
}
var instanceID *string
var fieldType string
switch {
case refServiceInstance.ID != nil:
logrus.Debugf("PostProvision: CreateSSHKey: si id = %s, key = %s",
*refServiceInstance.ID,
in.InstallConfig.Config.SSHKey)
instanceID = refServiceInstance.ID
fieldType = "ID"
case refServiceInstance.Name != nil:
logrus.Debugf("PostProvision: CreateSSHKey: si name = %s, key = %s",
*refServiceInstance.Name,
in.InstallConfig.Config.SSHKey)
vpc, err := client.GetVPCByName(ctx, *refServiceInstance.Name)
if err != nil {
return fmt.Errorf("failed to find id for VPC name %s: %w",
*refServiceInstance.Name,
err)
}
instanceID = vpc.ID
fieldType = "Name"
default:
return fmt.Errorf("could not handle powerVSMachine.Spec.ServiceInstance")
}
backoff := wait.Backoff{
Duration: 15 * time.Second,
Factor: 1.1,
Cap: leftInContext(ctx),
Steps: math.MaxInt32,
}
err = wait.ExponentialBackoffWithContext(ctx, backoff, func(context.Context) (bool, error) {
err2 := client.CreateSSHKey(ctx, *instanceID, *powerVSMachine.Status.Zone, sshKeyName, in.InstallConfig.Config.SSHKey)
if err2 == nil {
return true, nil
}
return false, err2
})
if err != nil {
return fmt.Errorf("failed to add SSH key for the workers(%s): %w", fieldType, err)
}

@mjturek
Copy link
Contributor

mjturek commented Mar 26, 2024

@r4f4 can we address these in a follow up patch? We have other work that is based on this that we do not want to break.

@mjturek
Copy link
Contributor

mjturek commented Mar 26, 2024

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Mar 26, 2024
@r4f4
Copy link
Contributor

r4f4 commented Mar 26, 2024

/approve

Copy link
Contributor

openshift-ci bot commented Mar 26, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: r4f4

The full list of commands accepted by this bot can be found here.

The pull request process is described here

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 Mar 26, 2024
Copy link
Contributor

openshift-ci bot commented Mar 26, 2024

@hamzy: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-ibmcloud-ovn fe29e84 link false /test e2e-ibmcloud-ovn
ci/prow/okd-e2e-aws-ovn-upgrade fe29e84 link false /test okd-e2e-aws-ovn-upgrade

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@openshift-merge-bot openshift-merge-bot bot merged commit 0645657 into openshift:master Mar 26, 2024
25 of 27 checks passed
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. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants