-
Notifications
You must be signed in to change notification settings - Fork 233
MGMT-20119: Create feature gate to allow installing TNA using the API #7523
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
base: master
Are you sure you want to change the base?
Conversation
@giladravid16: This pull request references MGMT-20119 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 task to target the "4.19.0" version, but no target version was set. In response to this:
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. |
Skipping CI for Draft Pull Request. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: giladravid16 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 |
111b84d
to
c4ad2fe
Compare
0597f75
to
3375cdd
Compare
3375cdd
to
7de16eb
Compare
@giladravid16: This pull request references MGMT-20119 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 task to target the "4.19.0" version, but no target version was set. In response to this:
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. |
1 similar comment
@giladravid16: This pull request references MGMT-20119 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 task to target the "4.19.0" version, but no target version was set. In response to this:
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. |
@giladravid16: This pull request references MGMT-20119 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 task to target the "4.19.0" version, but no target version was set. In response to this:
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. |
1 similar comment
@giladravid16: This pull request references MGMT-20119 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 task to target the "4.19.0" version, but no target version was set. In response to this:
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. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7523 +/- ##
==========================================
+ Coverage 67.30% 67.37% +0.06%
==========================================
Files 334 335 +1
Lines 42293 42454 +161
==========================================
+ Hits 28465 28603 +138
- Misses 11256 11273 +17
- Partials 2572 2578 +6
🚀 New features to boost your workflow:
|
internal/bminventory/inventory.go
Outdated
if highAvailabilityMode == models.ClusterCreateParamsHighAvailabilityModeFull { | ||
var minMasterHostsNeededForInstallation int64 = common.MinMasterHostsNeededForInstallationInHaMode | ||
minVersion := common.MinimumVersionForNonStandardHAOCPControlPlane | ||
if !arbiterClustersNotSupported { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer this get reversed in some way so we don't have a double negative here. It's harder to reason about.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed it
minVersion := common.MinimumVersionForNonStandardHAOCPControlPlane | ||
if !arbiterClustersNotSupported { | ||
minMasterHostsNeededForInstallation = common.MinMasterHostsNeededForInstallationInHaArbiterMode | ||
minVersion = common.MinimumVersionForArbiterClusters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of version in this function is very confusing.
It seems like we're trying to reason about different cases for different versions, but I never see the version in a condition anywhere. Is that right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable minVersion is only for the error message (if the controlPlaneCount is not allowed). The variable minMasterHostsNeededForInstallation changes based on whether or not the version is at least 4.19 or not (either 2 or 3), and that is used to validate the controlPlaneCount.
internal/bminventory/inventory.go
Outdated
err = errors.Errorf("Cannot set role arbiter to host %s in infra-env %s, it must be bound to a cluster with openshift version %s or newer", host.ID, host.InfraEnvID, common.MinimumVersionForArbiterClusters) | ||
if cluster != nil && cluster.OpenshiftVersion != "" { | ||
arbiterClustersNotSupported, err2 := common.BaseVersionLessThan(common.MinimumVersionForArbiterClusters, cluster.OpenshiftVersion) | ||
if err2 != nil { | ||
return err2 | ||
} | ||
if !arbiterClustersNotSupported { | ||
err = nil | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic feels a bit backwards. Why create the error first just to nil it out if we hit the success case?
Can you refactor this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed it
7de16eb
to
91d052d
Compare
/retest-required |
var err error | ||
if !b.TNAClustersSupport { | ||
err = errors.Errorf("TNA clusters support is disabled, cannot set role arbiter to host %s in infra-env %s", host.ID, host.InfraEnvID) | ||
} else { | ||
if cluster != nil && cluster.OpenshiftVersion != "" { | ||
arbiterClustersSupported, err2 := common.BaseVersionGreaterOrEqual(common.MinimumVersionForArbiterClusters, cluster.OpenshiftVersion) | ||
if err2 != nil { | ||
return err2 | ||
} | ||
if !arbiterClustersSupported { | ||
err = errors.Errorf("Cannot set role arbiter to host %s in infra-env %s, it must be bound to a cluster with openshift version %s or newer", host.ID, host.InfraEnvID, common.MinimumVersionForArbiterClusters) | ||
} | ||
} else { | ||
err = errors.Errorf("Cannot set role arbiter to host %s in infra-env %s, it must be bound to a cluster with openshift version %s or newer", host.ID, host.InfraEnvID, common.MinimumVersionForArbiterClusters) | ||
} | ||
} | ||
if err != nil { | ||
log.Error(err) | ||
return common.NewApiError(http.StatusBadRequest, err) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var err error | |
if !b.TNAClustersSupport { | |
err = errors.Errorf("TNA clusters support is disabled, cannot set role arbiter to host %s in infra-env %s", host.ID, host.InfraEnvID) | |
} else { | |
if cluster != nil && cluster.OpenshiftVersion != "" { | |
arbiterClustersSupported, err2 := common.BaseVersionGreaterOrEqual(common.MinimumVersionForArbiterClusters, cluster.OpenshiftVersion) | |
if err2 != nil { | |
return err2 | |
} | |
if !arbiterClustersSupported { | |
err = errors.Errorf("Cannot set role arbiter to host %s in infra-env %s, it must be bound to a cluster with openshift version %s or newer", host.ID, host.InfraEnvID, common.MinimumVersionForArbiterClusters) | |
} | |
} else { | |
err = errors.Errorf("Cannot set role arbiter to host %s in infra-env %s, it must be bound to a cluster with openshift version %s or newer", host.ID, host.InfraEnvID, common.MinimumVersionForArbiterClusters) | |
} | |
} | |
if err != nil { | |
log.Error(err) | |
return common.NewApiError(http.StatusBadRequest, err) | |
} | |
if !b.TNAClustersSupport { | |
err := errors.Errorf("TNA clusters support is disabled, cannot set role arbiter to host %s in infra-env %s", host.ID, host.InfraEnvID) | |
log.Error(err) | |
return common.NewApiError(http.StatusBadRequest, err) | |
} | |
if cluster == nil || cluster.OpenshiftVersion == nil { | |
err := errors.Errorf("Cannot set role arbiter to host %s in infra-env %s, it must be bound to a cluster with openshift version %s or newer", host.ID, host.InfraEnvID, common.MinimumVersionForArbiterClusters) | |
log.Error(err) | |
return common.NewApiError(http.StatusBadRequest, err) | |
} | |
arbiterClustersSupported, err := common.BaseVersionGreaterOrEqual(common.MinimumVersionForArbiterClusters, cluster.OpenshiftVersion) | |
if err != nil { | |
return err | |
} | |
if !arbiterClustersSupported { | |
err := errors.Errorf("Cannot set role arbiter to host %s in infra-env %s, it must be bound to a cluster with openshift version %s or newer", host.ID, host.InfraEnvID, common.MinimumVersionForArbiterClusters) | |
log.Error(err) | |
return common.NewApiError(http.StatusBadRequest, err) | |
} |
Not super urgent, but I generally prefer guards with early returns to a lot of "else" statements. I find something like this easier to read because you don't have to consider multiple conditions at the same time when thinking about why some code is running. Additionally you don't have to worry about error shadowing here.
Also if we want to deduplicate the logging I'd suggest logging the error from the caller rather than every error case in this function.
@giladravid16: The following tests failed, say
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-sigs/prow repository. I understand the commands that are listed here. |
This is the first PR for adding support for TNA Clusters in assisted-service.
The purpose of this PR is to add the minimum required to install TNA clusters using the REST API.
The changes include:
To check this PR I used my build to install a few TNA clusters and verified that the clusters installed successfully.
List all the issues related to this PR
Closes MGMT-20119
What environments does this code impact?
How was this code tested?
Checklist
docs
, README, etc)Reviewers Checklist