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

Add new flag to override actionset name #1625

Merged
merged 1 commit into from
Sep 7, 2022
Merged

Conversation

ihcsim
Copy link
Contributor

@ihcsim ihcsim commented Sep 7, 2022

Change Overview

This PR adds a new flag called --actionset-name to the kanctl create actionset command. The current mechanism to auto-generate the new actionset name based on the provided action name (with --action) and parent actionset name (with --from) is unreliable. The resource creation will fail if the auto-generated name doesn't comply with the K8s resource naming constraints. See #1414.

The new flag allows user to override the auto-generation mechanism to use one provided by the user.

Pull request type

Please check the type of change your PR introduces:

  • 🚧 Work in Progress
  • 🌈 Refactoring (no functional changes, no api changes)
  • 🐹 Trivial/Minor
  • 🐛 Bugfix
  • 🌻 Feature
  • 🗺️ Documentation
  • 🤖 Test

Issues

Test Plan

Deploy this blueprint where the action's name is in the camel case format:

cat <<EOF | kubectl apply -f -
apiVersion: cr.kanister.io/v1alpha1
kind: Blueprint
metadata:
  name: remote-outputs
  namespace: kanister
actions:
  echoTask:
    outputArtifacts:
      output:
        keyValue:
          bar: "{{ .Phases.echoTask.Output.bar }}"
    phases:
    - func: KubeTask
      name: echoTask
      args:
        namespace: "{{ .Namespace.Name }}"
        image: ghcr.io/kanisterio/kanister-tools:v9.99.9-dev
        command:
        - sh
        - "-c"
        - |
         kando output bar "foo"

Deploy this actionset to execute the echoTask action:

cat <<EOF | kubectl create -f -
apiVersion: cr.kanister.io/v1alpha1
kind: ActionSet
metadata:
  generateName: echo-task-
  namespace: kanister
spec:
  actions:
  - name: echoTask
    blueprint: remote-outputs
    object:
      kind: Namespace
      name: default

Use kanctl to create an actionset, using the previous actionset as its parent:

kanctl -n kanister create actionset --action echoTask --from echo-task-q552d -T default 

Expect the above command to fail:

Error: ActionSet.cr.kanister.io "echoTask-echo-task-q552d-sdkqd" is invalid: [metadata.generateName: Invalid value: "echoTask-echo-task-q552d-": a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*'), metadata.name: Invalid value: "echoTask-echo-task-q552d-sdkqd": a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')]

Re-run the command again with the -A / --actionset-name flag:

kanctl -n kanister create actionset --action echoTask --from echo-task-q552d -T default -A myactionset     

Expect the actionset to be created successfully:

kubectl -n kanister get actionset myactionset-tcrth                                                                           
NAME                AGE
myactionset-tcrth   17s

Signed-off-by: Ivan Sim <ivan.sim@kasten.io>
@github-actions
Copy link
Contributor

github-actions bot commented Sep 7, 2022

Thanks for submitting this pull request 🎉. The team will review it soon and get back to you.

If you haven't already, please take a moment to review our project contributing guideline and Code of Conduct document.

@infraq infraq added this to In Progress in Kanister Sep 7, 2022
Copy link
Contributor

@pavannd1 pavannd1 left a comment

Choose a reason for hiding this comment

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

LGTM

Kanister automation moved this from In Progress to Reviewer approved Sep 7, 2022
@ihcsim
Copy link
Contributor Author

ihcsim commented Sep 7, 2022

/ok-to-test

@ihcsim
Copy link
Contributor Author

ihcsim commented Sep 7, 2022

ok-to-test

@ihcsim ihcsim added the kueue label Sep 7, 2022
@mergify mergify bot merged commit a72c089 into master Sep 7, 2022
Kanister automation moved this from Reviewer approved to Done Sep 7, 2022
@mergify mergify bot deleted the flag-for-actionset-name branch September 7, 2022 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging this pull request may close these issues.

[BUG] kanctl failed with invalid name for ActionSet
2 participants