Skip to content

implement ScenarioOperation CRUD logic #416

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

YamasouA
Copy link
Contributor

@YamasouA YamasouA commented May 10, 2025

What type of PR is this?

/area scenario
/kind feature

What this PR does / why we need it:

We implement scenario controller and the webhook.
And this controller and webhook are build as container.
We also implement scenario_operation controller logic.

Which issue(s) this PR fixes:

Part of #396

Special notes for your reviewer:

/label tide/merge-method-squash

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels May 10, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: YamasouA
Once this PR has been reviewed and has the lgtm label, please assign 196ikuchil for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 10, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @YamasouA. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot requested a review from 196Ikuchil May 10, 2025 10:12
@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label May 10, 2025
@YamasouA
Copy link
Contributor Author

❯ cat valid-scenario.yaml
apiVersion: simulation.kube-scheduler-simulator.x-k8s.io/v1alpha1
kind: Scenario
metadata:
  name: valid-scenario
spec:
  foo: "valid test scenario"
  operations:
    - id: "op1"
      step: 1
      createOperation:
        object:
          apiVersion: v1
          kind: ConfigMap
          metadata:
            name: valid-configmap
          data:
            key: "value"

❯ kubectl apply -f valid-scenario.yaml
scenario.simulation.kube-scheduler-simulator.x-k8s.io/valid-scenario unchanged
❯ cat invalid-scenario.yaml
apiVersion: simulation.kube-scheduler-simulator.x-k8s.io/v1alpha1
kind: Scenario
metadata:
  name: invalid-scenario
spec:
  foo: "invalid test scenario"
  operations:
    - id: "op1"
      step: 1
      createOperation:
        object:
          apiVersion: v1
          kind: ConfigMap
          metadata:
            name: invalid-configmap
          data:
            key: "value"
      patchOperation:
        typeMeta:
          apiVersion: v1
          kind: ConfigMap
        objectMeta:
          name: invalid-configmap
        patch: '{"data":{"key":"new-value"}}'
        patchType: "StrategicMergePatch"

❯ kubectl apply -f invalid-scenario.yaml
Error from server (Forbidden): error when creating "invalid-scenario.yaml": admission webhook "vscenario-v1alpha1.kb.io" denied the request: scenario webhook ValidateCreate: validateOperation find some operations

@YamasouA YamasouA changed the title [WIP] scenario_operation Impl scenario controller and scenario_operation logic May 11, 2025
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 11, 2025
Copy link
Member

@sanposhiho sanposhiho left a comment

Choose a reason for hiding this comment

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

/ok-to-test
/cc @ordovicia @utam0k @saza-ku

@k8s-ci-robot k8s-ci-robot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label May 11, 2025
@k8s-ci-robot k8s-ci-robot requested a review from utam0k May 11, 2025 15:45
@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 11, 2025
@k8s-ci-robot
Copy link
Contributor

@sanposhiho: GitHub didn't allow me to request PR reviews from the following users: ordovicia, saza-ku.

Note that only kubernetes-sigs members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/ok-to-test
/cc @ordovicia @utam0k @saza-ku

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link
Member

@utam0k utam0k left a comment

Choose a reason for hiding this comment

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

Overall, it looks good!

count++
}
if count != 1 {
return fmt.Errorf("validateOperation find some operations")
Copy link
Member

Choose a reason for hiding this comment

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

nit

Suggested change
return fmt.Errorf("validateOperation find some operations")
return fmt.Errorf("exactly one operation type must be specified, but found %d", count)

@@ -0,0 +1,117 @@
package v1alpha1
Copy link
Member

Choose a reason for hiding this comment

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

I think we should at least add the unit tests for this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@utam0k
Thank you for your review.
I add unit test!

@YamasouA YamasouA changed the title Impl scenario controller and scenario_operation logic implement ScenarioOperation CRUD logic Jul 19, 2025
@YamasouA
Copy link
Contributor Author

/retest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants