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

ROX-19609: add cluster name validation to infractl #980

Merged
merged 3 commits into from
Sep 12, 2023

Conversation

tommartensen
Copy link
Contributor

@tommartensen tommartensen commented Sep 8, 2023

This was a user request: https://issues.redhat.com/browse/ROX-19609.

$ bin/infractl-darwin-arm64 create gke-default this-name-is-way-too-loooooooooooooooooooooooooooooooooooooooong
NOTE: infractl no longer requires a NAME parameter when creating a cluster.
      If ommitted a name will be generated using your infra user initials, a
      short date and a counter for uniqueness. e.g. jb-10-31-1
Error: cluster name too long
$ bin/infractl-darwin-arm64 create gke-default t                                        
NOTE: infractl no longer requires a NAME parameter when creating a cluster.
      If ommitted a name will be generated using your infra user initials, a
      short date and a counter for uniqueness. e.g. jb-10-31-1
Error: cluster name too short
$ bin/infractl-darwin-arm64 create gke-default tFAISOFJAfsoi
NOTE: infractl no longer requires a NAME parameter when creating a cluster.
      If ommitted a name will be generated using your infra user initials, a
      short date and a counter for uniqueness. e.g. jb-10-31-1
Error: The name does not match the requirements. Only lowercase letters, numbers, and '-' allowed, must start with a letter and end with a letter or number.

@tommartensen tommartensen self-assigned this Sep 8, 2023
@ghost
Copy link

ghost commented Sep 8, 2023

A single node development cluster (infra-pr-980) was allocated in production infra for this PR.

CI will attempt to deploy us.gcr.io/stackrox-infra/infra-server:0.7.11-8-gcf14f7a5d0 to it.

🔌 You can connect to this cluster with:

gcloud container clusters get-credentials infra-pr-980 --zone us-central1-a --project srox-temp-dev-test

🛠️ And pull infractl from the deployed dev infra-server with:

nohup kubectl -n infra port-forward svc/infra-server-service 8443:8443 &
make pull-infractl-from-dev-server

🚲 You can then use the dev infra instance e.g.:

bin/infractl -k -e localhost:8443 whoami

⚠️ Any clusters that you start using your dev infra instance should have a lifespan shorter then the development cluster instance. Otherwise they will not be destroyed when the dev infra instance ceases to exist when the development cluster is deleted. ⚠️

Further Development

☕ If you make changes, you can commit and push and CI will take care of updating the development cluster.

🚀 If you only modify configuration (chart/infra-server/configuration) or templates (chart/infra-server/{static,templates}), you can get a faster update with:

make install-local

Logs

Logs for the development infra depending on your @stackrox.com authuser:

Or:

kubectl -n infra logs -l app=infra-server --tail=1 -f

@tommartensen tommartensen changed the title add cluster name validation to infractl ROX-19609: add cluster name validation to infractl Sep 8, 2023
@tommartensen tommartensen marked this pull request as ready for review September 8, 2023 07:48
@tommartensen tommartensen requested a review from a team as a code owner September 8, 2023 07:48
@@ -123,6 +123,24 @@ setup() {
assert_output --partial "parameter \"main-image\" was not provided"
}

@test "provided name failed validation because too short" {
Copy link
Contributor

Choose a reason for hiding this comment

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

🦇

Copy link
Contributor

@gavin-stackrox gavin-stackrox left a comment

Choose a reason for hiding this comment

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

Gets the job done. Ideally the cluster flavor should tell infra how to validate the name but that plumbing does not exist.

@tommartensen
Copy link
Contributor Author

Ideally the cluster flavor should tell infra how to validate the name but that plumbing does not exist.

Different requirements or allowed characters for different flavors might complicate the naming for users. I am in favor of keeping the current approach using the common denominator of allowed cluster names.
By the way, the validation logic is translated from the UI code at https://github.com/stackrox/infra/blob/master/ui/src/containers/LaunchClusterPage/ClusterForm.tsx#L43-L48

@tommartensen tommartensen merged commit 5128fa5 into master Sep 12, 2023
7 checks passed
@tommartensen tommartensen deleted the tm/cli-cluster-name-validation branch September 12, 2023 06:28
gavin-stackrox added a commit that referenced this pull request Sep 22, 2023
gavin-stackrox added a commit that referenced this pull request Sep 22, 2023
gavin-stackrox added a commit that referenced this pull request Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants