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

interface: improve ClusterStagedUpdateRun APIs #1008

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jwtty
Copy link
Contributor

@jwtty jwtty commented Jan 6, 2025

Description of your changes

  1. Add additionalPrinterColumns for clusterStagedUpdateRun and clusterApprovalRequest objects.
  2. Add validations in updateRun name length and stageName to ensure ApprovalRequest name valid .
  3. Update the examples to use the v1beta1 APIs.

The get command outputs now look like:

kubectl get clusterstagedupdaterun
NAME          PLACEMENT           RESOURCE-SNAPSHOT               POLICY-SNAPSHOT        INITIALIZED   SUCCEEDED   AGE
example-run   example-placement   example-placement-0-snapshot   example-placement-7   True          True        13m

kubectl get clsuterstagedupdaterun -owide
NAME          PLACEMENT           RESOURCE-SNAPSHOT               STRATEGY           POLICY-SNAPSHOT        INITIALIZED   SUCCEEDED   AGE
example-run   example-placement   example-placement-0-snapshot   example-strategy   example-placement-7   True          True        3m47s

kubectl get clusterapprovalrequests
NAME                     UPDATE-RUN     STAGE        APPROVED   AGE
example-run-canary       example-run   canary       True       12m
example-run-production   example-run   production   True       11m

Fixes #

I have:

  • Run make reviewable to ensure this PR is ready for review.

How has this code been tested

Special notes for your reviewer

@jwtty jwtty force-pushed the stagerun-apiexample branch 2 times, most recently from e0058dc to e4822b7 Compare January 9, 2025 02:57
@jwtty jwtty changed the title chore: improve clusterStageUpdateRun UI and examples interface: add more stagedUpdateRun additionalPrintColumns Jan 9, 2025
@@ -17,6 +17,13 @@ import (
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster,categories={fleet,fleet-placement},shortName=crsur
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:printcolumn:JSONPath=`.spec.placementName`,name="Placement",type=string
// +kubebuilder:printcolumn:JSONPath=`.spec.resourceSnapshotIndex`,name="ResourceSnapshot",type=string
Copy link
Contributor

Choose a reason for hiding this comment

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

have a question about this field.

we want an index or a name? from the example you provided, it's a name.

The resources could be divided to multiple snapshots.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's the name. And we have a validation that only the master snapshot name should be provided.

Copy link
Contributor

Choose a reason for hiding this comment

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

Then we need to rename the spec field as discussed

apis/placement/v1alpha1/stagedupdate_types.go Outdated Show resolved Hide resolved
apis/placement/v1alpha1/stagedupdate_types.go Outdated Show resolved Hide resolved
@jwtty jwtty force-pushed the stagerun-apiexample branch from b5d3d56 to 5e0e36d Compare January 14, 2025 08:37
@jwtty jwtty changed the title interface: add more stagedUpdateRun additionalPrintColumns interface: improve ClusterStagedUpdateRun APIs Jan 14, 2025
// +kubebuilder:printcolumn:JSONPath=`.status.conditions[?(@.type=="Succeeded")].status`,name="Succeeded",type=string
// +kubebuilder:printcolumn:JSONPath=`.metadata.creationTimestamp`,name="Age",type=date
// +kubebuilder:printcolumn:JSONPath=`.spec.stagedRolloutStrategyName`,name="Strategy",priority=1,type=string
// +kubebuilder:validation:XValidation:rule="size(self.metadata.name) < 128",message="metadata.name max length is 127"
Copy link
Contributor

Choose a reason for hiding this comment

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

we need a test for this, similiar to test/apis/placement/v1beta1/api_validation_integration_test.go

@@ -102,7 +110,7 @@ type ClusterStagedUpdateStrategyList struct {
type StageConfig struct {
// The name of the stage. This MUST be unique within the same StagedUpdateStrategy.
// +kubebuilder:validation:MaxLength=63
// +kubebuilder:validation:Pattern="[A-Za-z0-9]+$"
// +kubebuilder:validation:Pattern="^[a-z0-9]+$"
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder why we only allow lower case for stage name?

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.

3 participants