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

Using clientset to read the Custom Resource #1992

Merged
merged 1 commit into from
Feb 29, 2024

Conversation

cniackz
Copy link
Contributor

@cniackz cniackz commented Feb 21, 2024

Objective:

To be able to read the Job Resource

Next Steps:

  • Launch a Job
  • Get STS Access
  • Make bucket(s) as requested
  • Add other operations and tests truly

How to test:

apiVersion: job.min.io/v1alpha1
kind: MinIOJob
metadata:
  name: myminio
  namespace: tenant-lite
spec:
  serviceAccountName: tenant-lite
  tenant:
    name: my-tenant
    namespace: default
  execution: parallel # Sequential
  # disableWaitForReady: true
  commands:
    - op: ready
    - op: make-bucket
      args:
        name: memes
    - name: add-my-user-1
      op: admin/user/add
      args:
        user: daniel
        password: daniel123
    - name: add-my-policy
      op: admin/policy/add
      args:
        name: memes-access
        policy: |
          {
              "Version": "2012-10-17",
              "Statement": [
                  {
                      "Effect": "Allow",
                      "Action": [
                          "s3:*"
                      ],
                      "Resource": [
                          "arn:aws:s3:::memes",
                          "arn:aws:s3:::memes/*"
                      ]
                  }
              ]
          }
    - op: admin/policy/attach
      dependsOn:
        - add-my-user-1
        - add-my-policy
      args:
        policy: memes-access
status:
  phase: Failed # Completed, Pending, Waiting, Running
  commands:
    - name: wait-ready
      result: success
    - result: succes
    - result: failure
      message: this and that

Additional information:

This is not a new client, as initially thought, but rather the same client we have had since before. The difference is that the Job controller was implemented on top of it in PR: link to PR. You can examine the interface in operator/pkg/client/clientset/versioned/clientset.go:

type Interface interface {
	Discovery() discovery.DiscoveryInterface
	JobV1alpha1() jobv1alpha1.JobV1alpha1Interface
	MinioV2() miniov2.MinioV2Interface
	StsV1alpha1() stsv1alpha1.StsV1alpha1Interface
} 

This interface allows us to share different resources over the same clientset: MinIO tenants, STS, and now Job.

Hope this helps clarify a bit.

@cniackz cniackz self-assigned this Feb 21, 2024
@cniackz
Copy link
Contributor Author

cniackz commented Feb 21, 2024

Currently having a panic while reading the resource, need to investigate why and how to fix it

@cniackz
Copy link
Contributor Author

cniackz commented Feb 21, 2024

Ok, finally I can read the CRD from within the controller loop; solved the panic by properly adding the clientset took me forever to figure this out, but finally understood the panic haha.
Ok, next step is to clean this code, pass tests and then I can review with you guys, so at least we can take this one further step from where we start and read the Custom Resource Definition to then add the logic to make buckets.

@cniackz cniackz force-pushed the make-bucket-declarative branch 2 times, most recently from b1fc330 to 6028f3c Compare February 22, 2024 17:35
@cniackz cniackz changed the title [WIP] - adding clientset to read the resource Adding clientset to read the Custom Resource Feb 22, 2024
@cniackz
Copy link
Contributor Author

cniackz commented Feb 22, 2024

Okay, this pull request is ready for review; we're just waiting for the tests to pass.

pkg/controller/job-controller.go Outdated Show resolved Hide resolved
pkg/controller/job-controller.go Outdated Show resolved Hide resolved
pkg/controller/job-controller.go Outdated Show resolved Hide resolved
pkg/controller/job-controller.go Outdated Show resolved Hide resolved
@cniackz
Copy link
Contributor Author

cniackz commented Feb 23, 2024

Thank you, Pedro and Jiuker, for the review. Log lines have been removed. Now, we await the test results to pass!

pjuarezd
pjuarezd previously approved these changes Feb 23, 2024
@cniackz
Copy link
Contributor Author

cniackz commented Feb 28, 2024

Ok team, this is ready to review! 👍

@cniackz cniackz changed the title Adding clientset to read the Custom Resource Using clientset to read the Custom Resource Feb 28, 2024
@cniackz cniackz merged commit 4b5381b into minio:master Feb 29, 2024
26 checks passed
@cniackz cniackz deleted the make-bucket-declarative branch February 29, 2024 00:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants