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

RepositoryServer CR update validation #2080

Merged
merged 7 commits into from
Jun 5, 2023
Merged

Conversation

r4rajat
Copy link
Contributor

@r4rajat r4rajat commented May 31, 2023

Change Overview

Following fields in RepositoryServer CRD need to be made immutable to control the CR update event.

  • .spec.storage.secretRef
  • .spec.repository.rootPath
  • .spec.server.adminSecretRef
  • .spec.server.tlsSecretRef

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

  • fixes #issue-number

Test Plan

  • 💪 Manual
  • ⚡ Unit test
  • 💚 E2E

Manual Testing Steps

1) Install Kanister using Helm

helm install kanister ./helm/kanister-operator \
--namespace kanister \
--set image.repository=r4rajat/controller \
--set image.tag=v5 \
--set repositoryServerControllerImage.registry=r4rajat \
--set repositoryServerControllerImage.name=repo-server-controller \
--set repositoryServerControllerImage.tag=v5 \
--set controller.parallelism=10 \
--set repositoryServerController.enabled=true \
--create-namespace

2) Creating RepositoryServer CR

kubectl apply -f - <<EOF
---
apiVersion: cr.kanister.io/v1alpha1
kind: RepositoryServer
metadata:
  labels:
    app.kubernetes.io/name: repositoryserver
    app.kubernetes.io/instance: repositoryserver-sample
    app.kubernetes.io/part-of: kanister
    app.kuberentes.io/managed-by: kustomize
    app.kubernetes.io/created-by: kanister
  name: kopia-repo-server-1
  # namespace: kanister
spec:
  storage:
    secretRef:
      name: s3-location
      namespace: kanister
    credentialSecretRef:
      name: s3-creds
      namespace: kanister
  repository:
    rootPath: /repo-controller/
    passwordSecretRef:
      name: repo-pass 
      namespace: kanister
    username: kanisteradmin
    hostname: time-log.app
  server:
    adminSecretRef:
      name: repository-admin-user
      namespace: kanister
    tlsSecretRef:
      name: repository-server-tls-cert
      namespace: kanister
    userAccess:
      userAccessSecretRef:
        name: repository-server-user-access
        namespace: kanister
      username: kanisteruser
EOF

repositoryserver.cr.kanister.io/kopia-repo-server-1 created

3) Try to update rootPath

kubectl apply -f - <<EOF
---
apiVersion: cr.kanister.io/v1alpha1
kind: RepositoryServer
metadata:
  labels:
    app.kubernetes.io/name: repositoryserver
    app.kubernetes.io/instance: repositoryserver-sample
    app.kubernetes.io/part-of: kanister
    app.kuberentes.io/managed-by: kustomize
    app.kubernetes.io/created-by: kanister
  name: kopia-repo-server-1
  # namespace: kanister
spec:
  storage:
    secretRef:
      name: s3-location
      namespace: kanister
    credentialSecretRef:
      name: s3-creds
      namespace: kanister
  repository:
    rootPath: /repo-controller/update-test/
    passwordSecretRef:
      name: repo-pass 
      namespace: kanister
    username: kanisteradmin
    hostname: time-log.app
  server:
    adminSecretRef:
      name: repository-admin-user
      namespace: kanister
    tlsSecretRef:
      name: repository-server-tls-cert
      namespace: kanister
    userAccess:
      userAccessSecretRef:
        name: repository-server-user-access
        namespace: kanister
      username: kanisteruser
EOF

The RepositoryServer "kopia-repo-server-1" is invalid: spec.repository.rootPath: Invalid value: "string": Value is immutable

Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com>
@github-actions
Copy link
Contributor

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 May 31, 2023
@kale-amruta
Copy link
Contributor

can we add a unit test for this? @r4rajat

Copy link
Contributor

@PrasadG193 PrasadG193 left a comment

Choose a reason for hiding this comment

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

LGTM

Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com>
@r4rajat
Copy link
Contributor Author

r4rajat commented Jun 1, 2023

can we add a unit test for this? @r4rajat

Done @kale-amruta

r4rajat and others added 2 commits June 2, 2023 18:47
Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com>
Copy link
Contributor

@kale-amruta kale-amruta 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 Jun 5, 2023
@r4rajat r4rajat added the kueue label Jun 5, 2023
@mergify mergify bot merged commit a76c23f into master Jun 5, 2023
14 checks passed
Kanister automation moved this from Reviewer approved to Done Jun 5, 2023
@mergify mergify bot deleted the reposerver-update-validation branch June 5, 2023 06:24
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.

None yet

4 participants