-
Notifications
You must be signed in to change notification settings - Fork 24
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
Joshd/sc 88868/reject requests for vm clusters with 1 nodes #326
Merged
divolgin
merged 4 commits into
main
from
joshd/sc-88868/reject-requests-for-vm-clusters-with-1-nodes
Sep 15, 2023
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ package cmd | |
|
||
import ( | ||
"fmt" | ||
"strings" | ||
"time" | ||
|
||
"github.com/moby/moby/pkg/namesgenerator" | ||
|
@@ -18,8 +17,17 @@ func (r *runners) InitClusterCreate(parent *cobra.Command) *cobra.Command { | |
cmd := &cobra.Command{ | ||
Use: "create", | ||
Short: "Create test clusters", | ||
Long: `Create test clusters`, | ||
RunE: r.createCluster, | ||
Long: `Create test clusters. | ||
|
||
This is a beta feature, with some known limitations: | ||
- K3s, Kind, kurl, helmvm and Openshift clusters only support a single node. | ||
- EKS clusters may report ready before the nodes are completely online. | ||
- kurl is the only supported distribution that can be upgraded. | ||
- Clusters cannot be resized. Create another cluster if you want to make changes, such as add another node. | ||
- On cloud clusters, only one node group per cluster is supported. | ||
- Multi-node support is available only for GKE and EKS. | ||
- There is no support for IPv6.`, | ||
RunE: r.createCluster, | ||
} | ||
parent.AddCommand(cmd) | ||
|
||
|
@@ -78,11 +86,13 @@ func (r *runners) createAndWaitForCluster(opts kotsclient.CreateClusterOpts) (*t | |
return nil, errors.Wrap(err, "create cluster") | ||
} | ||
|
||
if ve != nil && len(ve.Errors) > 0 { | ||
if len(ve.SupportedDistributions) > 0 { | ||
_ = print.ClusterVersions("table", r.w, ve.SupportedDistributions) | ||
if ve != nil && ve.Message != "" { | ||
if ve.ValidationError != nil && len(ve.ValidationError.Errors) > 0 { | ||
if len(ve.ValidationError.SupportedDistributions) > 0 { | ||
_ = print.ClusterVersions("table", r.w, ve.ValidationError.SupportedDistributions) | ||
} | ||
} | ||
return nil, fmt.Errorf("%s", errors.New(strings.Join(ve.Errors, ","))) | ||
return nil, fmt.Errorf("%s", ve.Message) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
|
||
if opts.DryRun { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
package kotsclient | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"net/http" | ||
"strings" | ||
|
||
"github.com/replicatedhq/replicated/pkg/platformclient" | ||
"github.com/replicatedhq/replicated/pkg/types" | ||
) | ||
|
||
|
@@ -40,12 +41,15 @@ func (c *VendorV3Client) doUpgradeClusterRequest(clusterID string, req UpgradeCl | |
endpoint := fmt.Sprintf("/v3/cluster/%s/upgrade", clusterID) | ||
err := c.DoJSON("POST", endpoint, http.StatusOK, req, &resp) | ||
if err != nil { | ||
if strings.Contains(err.Error(), " 400: ") { | ||
// to avoid a lot of brittle string parsing, we make the request again with | ||
// a dry-run flag and expect to get the same result back | ||
ve, _ := c.doUpgradeClusterDryRunRequest(clusterID, req) | ||
if ve != nil && len(ve.Errors) > 0 { | ||
return nil, ve, nil | ||
// if err is APIError and the status code is 400, then we have a validation error | ||
// and we can return the validation error | ||
if apiErr, ok := err.(platformclient.APIError); ok { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. errors.Cause(err).(platformclient.APIError) |
||
if apiErr.StatusCode == http.StatusBadRequest { | ||
veResp := &ClusterValidationError{} | ||
if jsonErr := json.Unmarshal(apiErr.Body, veResp); jsonErr != nil { | ||
return nil, nil, fmt.Errorf("unmarshal validation error response: %w", err) | ||
} | ||
return nil, veResp, nil | ||
} | ||
} | ||
return nil, nil, err | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 line should be a limitation of the cluster upgrade command, not cluster create
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 think it's a fair warning here so it's not a surprise later. Maybe wording can be improved.