aws-account-operator icon indicating copy to clipboard operation
aws-account-operator copied to clipboard

[Draft] Add CRUD-Mock aws client for local testing

Open mrWinston opened this issue 1 year ago • 4 comments

What is being added?

This Pr adds a mock aws client that supports basic crud (Create, Read, Update, Destroy) operations. This makes it possible to run the Operator without any interactions with an AWS account.

The client itself is implemented here: https://github.com/mrWinston/go-aws-crud-client/tree/main . It currently uses an in-memory database to store and retrieve the various aws objects that the aao interacts with. This means, that upon every start, the client gets wiped clean again.

Some ideas/issues that might be useful to have before using this:

  • [ ] multi-account support - currently, there may be conflicts between objects that should live in different accounts.
  • [ ] Persist state upon reboots
  • [ ] Load initial state from some fixture

How to test

  • Create a local test cluster:
kind create cluster
  • Run cluster setup steps:
make predeploy-crud
  • This is a modified version of the normal make predeploy that omits every part that requires aws access
  • start the operator:
make deploy-local-crud
  • Then, in another shell, modify the accountpool size so accounts are actually created:
oc -n aws-account-operator patch accountpool -p '{"spec":{"poolSize":5}}' --type=merge zero-size-accountpool

oc -n aws-account-operator get accounts
NAME                    STATE   CLAIMED   CLAIM   AGE
osd-creds-mgmt-d72m2c   Ready                     23s
osd-creds-mgmt-mbfjjw   Ready                     10m
osd-creds-mgmt-qmj5ll   Ready                     23s
osd-creds-mgmt-sf7jc5   Ready                     23s
osd-creds-mgmt-v22nwb   Ready                     23s
osd-creds-mgmt-xjlsvq   Ready                     23s
  • Then create a namespace and Accountclaim and watch it being reconciled:
oc create ns test
cat << EOF | oc apply -f -
apiVersion: aws.managed.openshift.io/v1alpha1
kind: AccountClaim
metadata:
  name: testacct1
  namespace: test
spec:
  accountLink: ""
  aws:
    regions:
    - name: us-east-1
  awsCredentialSecret:
    name: "creds"
    namespace: "test"
  legalEntity:
    id: "111111"
    name: Test Organization
EOF


oc -n test get accountclaims                                              
NAME        STATE   ACCOUNT                 AGE
testacct1   Ready   osd-creds-mgmt-v22nwb   18s

oc -n aws-account-operator get accounts
NAME                    STATE   CLAIMED   CLAIM       AGE
osd-creds-mgmt-5dr4ql   Ready                         2m16s
osd-creds-mgmt-mbfjjw   Ready                         15m
osd-creds-mgmt-qmj5ll   Ready                         5m24s
osd-creds-mgmt-sf7jc5   Ready                         5m24s
osd-creds-mgmt-v22nwb   Ready   true      testacct1   5m24s
osd-creds-mgmt-x857dm   Ready                         2m6s
osd-creds-mgmt-xjlsvq   Ready                         5m24s

mrWinston avatar Jan 12 '24 14:01 mrWinston

PR needs rebase.

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/test-infra repository.

openshift-merge-robot avatar Jan 12 '24 14:01 openshift-merge-robot

Skipping CI for Draft Pull Request. If you want CI signal for your change, please convert it to an actual PR. You can still manually trigger a test run with /test all

openshift-ci[bot] avatar Jan 12 '24 14:01 openshift-ci[bot]

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mrWinston Once this PR has been reviewed and has the lgtm label, please assign bergmannf for approval. For more information see the Kubernetes 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

openshift-ci[bot] avatar Jan 12 '24 14:01 openshift-ci[bot]

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

openshift-bot avatar Apr 13 '24 01:04 openshift-bot

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten /remove-lifecycle stale

openshift-bot avatar May 14 '24 00:05 openshift-bot

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen. Mark the issue as fresh by commenting /remove-lifecycle rotten. Exclude this issue from closing again by commenting /lifecycle frozen.

/close

openshift-bot avatar Jun 13 '24 08:06 openshift-bot

@openshift-bot: Closed this PR.

In response to this:

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen. Mark the issue as fresh by commenting /remove-lifecycle rotten. Exclude this issue from closing again by commenting /lifecycle frozen.

/close

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.

openshift-ci[bot] avatar Jun 13 '24 08:06 openshift-ci[bot]