Skip to content

Conversation

@Patryk-Stefanski
Copy link
Contributor

@Patryk-Stefanski Patryk-Stefanski commented May 4, 2022

Threescale-7135

What

Addition of proxyconfigpromote CRD that allows for single-use product promotion to stage or production.

Verification

  1. Deploy 3scale-operator locally

2.Create dummy smtp secret

kubectl apply -f - <<EOF
---
kind: Secret
apiVersion: v1
metadata: 
  name: s3-credentials
  namespace: 3scale-test
data: 
  AWS_ACCESS_KEY_ID: UkVQTEFDRV9NRQ==
  AWS_BUCKET: UkVQTEFDRV9NRQ==
  AWS_REGION: UkVQTEFDRV9NRQ==
  AWS_SECRET_ACCESS_KEY: UkVQTEFDRV9NRQ==
type: Opaque
EOF

3.Create apimanager resource

kubectl apply -f - <<EOF
---
apiVersion: apps.3scale.net/v1alpha1
kind: APIManager
metadata: 
  name: apimanager-sample
  namespace: 3scale-test
spec: 
  system: 
    fileStorage: 
      simpleStorageService: 
        configurationSecretRef: 
          name: s3-credentials
  wildcardDomain: <cluster_domain>
EOF

cluster domain example : apps.pstefans.uq32.s1.devshift.org

  1. Create Backend resource
kubectl apply -f - <<EOF
---
apiVersion: capabilities.3scale.net/v1beta1
kind: Backend
metadata:
  name: backend1-cr
  namespace: 3scale-test
spec:
  mappingRules:
    - httpMethod: GET
      increment: 1
      last: true
      metricMethodRef: hits
      pattern: /
  name: backend1
  privateBaseURL: 'https://api.example.com'
  systemName: backend1
EOF
  1. Create product resources with the backend referenced
kubectl apply -f - <<EOF
---
apiVersion: capabilities.3scale.net/v1beta1
kind: Product
metadata:
  name: product1-cr
  namespace: 3scale-test
spec:
  name: product1
  backendUsages:
    backend1:
      path: /
EOF
  1. Create proxyconfigpromote resources to promote product to staging.
kubectl apply -f - <<EOF
---
apiVersion: capabilities.3scale.net/v1beta1
kind: ProxyConfigPromote
metadata:
  name: product1-v1-staging
  namespace: 3scale-test
spec:
  productCRName: product1-cr
EOF
  1. In 3scale UI check that product1 configuration was promoted to staging

  2. Create proxyconfigpromote resource to promote a product to production and remove resource after successful promotion

kubectl apply -f - <<EOF
---
apiVersion: capabilities.3scale.net/v1beta1
kind: ProxyConfigPromote
metadata:
  name: product1-v1-production
  namespace: 3scale-test
spec:
  productCRName: product1-cr
  production: true
  deleteCR: true
EOF
  1. In 3scale UI check that product1 configuration has been promoted to production and that the resource has been deleted in openshift UI

@openshift-ci
Copy link

openshift-ci bot commented May 4, 2022

Hi @Patryk-Stefanski. Thanks for your PR.

I'm waiting for a 3scale 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.

Details

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.

@Patryk-Stefanski
Copy link
Contributor Author

@eguzki @MStokluska @KevFan
If anyone would have a chance to review it would be great.

@Patryk-Stefanski Patryk-Stefanski changed the title [WIP] Threescale 7135 - Product Promotion Threescale 7135 - Product Promotion May 5, 2022
@eguzki
Copy link
Member

eguzki commented May 6, 2022

One tip after reading the verification steps and before going to the code. You do not need to create a secret with the admin access token to use it as accountref. When you deploy 3scale, a default tenant is created ready to be used. And admin access token is already available in 3scale namespace's secret. The operator will read that for you if your CR is deployed in the same namespace as 3scale. So, your backend, product and ProxyConfigPromote resources do not need providerAccountRef to be specified because they are deployed in the same namespace as 3scale. The code implementing that is here and documented here

Copy link
Member

@eguzki eguzki left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! 🥳
I haven't gone through the details of the implementation. But let's discuss the current comments and I will review more later

// Important: Run "make" to regenerate code after modifying this file

// product CR metadata.name
ProductCRName string `json:"productCRName,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

this is a required field. Remove omitempty json tag

Copy link
Contributor

Choose a reason for hiding this comment

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

👍


// ProviderAccountRef references account provider credentials
// +optional
ProviderAccountRef *corev1.LocalObjectReference `json:"providerAccountRef,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

I do not think it is necessary. The provider account ref will be read from the product CR. Adding provider account ref opens the door to have product from tenant A and proxyconfigpromote from tenant B having reference to the previous product.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes good idea, we can make this change.


// Environment you wish to promote to, if not present defaults to staging and if set to true promotes to production
// +optional
Production bool `json:"production,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

if it's optional, better to be a pointer to bool. That way you can differentiate between when the user did not set and when the user set that to false. Maybe not relevant for this use case, but still to be consistent with the other optional attributes in the operator CRDs.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍


// deleteCR deletes this CR when it has successfully completed the promotion
// +optional
DeleteCR bool `json:"deleteCR,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

nice!

As commented above, better to be a pointer to bool.

you can define a handy ProxyConfigPromote struct method to abstract the pointer type

func (p *ProxyConfigPromote) IsDeleteCR() bool {
    if p.Spec.DeleteCR == nil {
        return false
    }

   return *p.Spec.DeleteCR
}

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@austincunningham
Copy link
Contributor

@MStokluska & @KevFan if you have time for a review

@Patryk-Stefanski Patryk-Stefanski force-pushed the Threescale-7135 branch 4 times, most recently from 4be6c3f to 2016d2d Compare June 2, 2022 10:32
@Patryk-Stefanski Patryk-Stefanski force-pushed the Threescale-7135 branch 4 times, most recently from 4d7db25 to 8493c13 Compare June 3, 2022 11:20
@austincunningham austincunningham force-pushed the Threescale-7135 branch 4 times, most recently from c665b93 to 20bf2c1 Compare June 8, 2022 11:47
@austincunningham austincunningham force-pushed the Threescale-7135 branch 7 times, most recently from 402e753 to 39f18b8 Compare June 17, 2022 14:00
@austincunningham
Copy link
Contributor

@eguzki thinking the unit-test failing on circle-ci is some issue on the circle-ci side as rerunning the test will fail for a different reason each time its run with no code changes. The same unit test pass on the ci/prow/test-unit, my guess is its the memory footprint, will try some memory logging to see if this is the case.

@eguzki
Copy link
Member

eguzki commented Jun 20, 2022

The weird thing is that in master branch, tests pass.

@austincunningham austincunningham force-pushed the Threescale-7135 branch 2 times, most recently from fa51423 to 0b84cdc Compare June 20, 2022 09:12
@qlty-cloud-legacy
Copy link

Code Climate has analyzed commit d92f15d and detected 18 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 9
Duplication 1
Style 8

View more on Code Climate.

@austincunningham
Copy link
Contributor

@eguzki yep looks like memory footprint
added https://github.com/3scale/3scale-operator/pull/742/files#diff-78a8a19706dbd2a4425dd72bdab0502ed7a2cef16365ab7030a5a0588927bf47R425

resource_class: large

to the unit tests and now passing on circleci
Looks like the tests are using about 7.5 GiB
with out the resource_class set the container gets a medium size which is about 4GiB
I left the memory log in the circleci yaml , output is as follows
image

@eguzki eguzki merged commit f5477b9 into 3scale:master Jun 20, 2022
@eguzki eguzki mentioned this pull request Jun 21, 2022
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.

4 participants