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

Handle multiple backends for the TypeInstance #657

Merged
merged 13 commits into from
Mar 24, 2022

Conversation

mkuziemko
Copy link

@mkuziemko mkuziemko commented Mar 10, 2022

Description

Changes proposed in this pull request:

  • Argo action in case of the artifact:
value: 
    key: test
backend:
    context:
        (...)

will create an appropriate TypeInstance object and create a mutation.

  • modify Helm and Terraform runner to add value to output,
  • modify Jinja with the new configuration field: strip-value: true,
  • modify merger to remove value if exists in the artifacts.

Testing

Mattermost installation

  1. Check out this branch.
  2. Create a cluster with make dev-cluster
  3. Set manifest location to my fork
kubectl set env deploy/capact-hub-public -n capact-system -c hub-public-populator MANIFESTS_SOURCES="github.com/mkuziemko/hub-manifests?ref=context_handling"
  1. Wait until the manifests are populated
  2. Use port-foward for capact-gateway :
kubectl port-forward svc/capact-gateway 8080:80 -n capt-system
  1. Create parameters for Mattermost installation:
cat <<EOF > /tmp/mattermost-install.yaml
input-parameters:
  host: mattermost.capact.local
EOF
  1. Create action
capact action create --name mattermost-install cap.interface.productivity.mattermost.install --parameters-from-file /tmp/mattermost-install.yaml
  1. Use capact act run mattermost-install and capact act watch mattermost-install to observe the status of the running action.
  2. When it is finished, you can delete the action using capact act delete mattermost-install and helm charts.

PostgreSQL installation

  1. Prepare inputs for PostgreSQL:
cat <<EOF > /tmp/postgresql-install.yaml
input-parameters:
   superuser:
       username: "username"
       password: "password"
   defaultDBName: "default_db"
EOF
  1. Create the action:
capact action create --name test-1 cap.interface.database.postgresql.install --parameters-from-file /tmp/postgresql-install.yaml
  1. Run and watch the action:
capact act run test-1
capact act watch test-1

Run integration tests

Currently, the tests are failing due to a lack of storage backend integration. It will be fixed by: #655

Note: No longer valid. The PR was merged and this branch was updated. We can run tests by simple: make test-integration

  1. Install secret storage backend:
helm install dotenv -n capact-system ./deploy/kubernetes/charts/secret-storage-backend --set=global.containerRegistry.path="ghcr.io/capactio/pr" --set=global.containerRegistry.overrideTag="PR-653" --set=supportedProviders={aws_secretsmanager,dotenv} --wait
  1. Comment out line from e2e_suite_test.go:
waitTillServiceEndpointsAreReady()
  1. Create envs for test:
export STATUS_ENDPOINTS="not-needed"
export GATEWAY_USERNAME="graphql"
export GATEWAY_PASSWORD="t0p_s3cr3t"
export GATEWAY_ENDPOINT="https://gateway.capact.local/graphql"
  1. Run new scenario:
ginkgo -tags="integration" -v --focus="should propagate context provider to storage backend" ./test/e2e/...
ginkgo -tags="integration" -v --focus="should fail due to incorrect storage provider" ./test/e2e/...

Related issue(s)

@mkuziemko mkuziemko added area/engine Relates to Engine area/hub Relates to Hub labels Mar 10, 2022
pkg/runner/common.go Outdated Show resolved Hide resolved
typeInstance.Value = typeInstanceValue
} else {
// for backward compatibility, if there is an artifact without value/backend syntax,
// treat it as a value for TypeInstance
Copy link
Author

Choose a reason for hiding this comment

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

it is mainly for the case like here

@@ -50,7 +50,7 @@ readonly CAPACT_USE_TEST_SETUP="false"
#
Copy link
Author

Choose a reason for hiding this comment

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

will be removed before merge

Copy link
Member

@mszostok mszostok left a comment

Choose a reason for hiding this comment

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

In general, our contract is not implemented. So I didn't run the test as it shouldn't work that way.

hack/images/jinja2/jinja2-cli/jinja2cli/cli.py Outdated Show resolved Hide resolved
hack/images/jinja2/jinja2-cli/jinja2cli/cli.py Outdated Show resolved Hide resolved
hack/images/merger/merger.sh Show resolved Hide resolved
hack/images/jinja2/jinja2-cli/jinja2cli/cli.py Outdated Show resolved Hide resolved
hack/images/jinja2/jinja2-cli/jinja2cli/cli.py Outdated Show resolved Hide resolved
internal/installation/capact_register.go Outdated Show resolved Hide resolved
pkg/runner/helm/output.go Outdated Show resolved Hide resolved
pkg/runner/helm/output.go Outdated Show resolved Hide resolved
test/e2e/action_test.go Outdated Show resolved Hide resolved
@mkuziemko mkuziemko added the WIP Work in progress label Mar 15, 2022
@mkuziemko mkuziemko force-pushed the add_context_to_backend branch 3 times, most recently from efe5dbb to d00eed2 Compare March 15, 2022 07:52
@mkuziemko mkuziemko removed the WIP Work in progress label Mar 15, 2022
Copy link
Member

@mszostok mszostok 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 LGTM 👍 But please address my comments and additionally find in our code base all TODO(https://github.com/capactio/capact/issues/634) and fix them. Thanks!

pkg/argo-actions/update_type_instances.go Outdated Show resolved Hide resolved
pkg/argo-actions/update_type_instances.go Outdated Show resolved Hide resolved
pkg/argo-actions/upload_type_instances.go Outdated Show resolved Hide resolved
pkg/runner/common.go Outdated Show resolved Hide resolved
test/e2e/action_test.go Outdated Show resolved Hide resolved
@mkuziemko mkuziemko added the WIP Work in progress label Mar 18, 2022
Copy link
Member

@mszostok mszostok left a comment

Choose a reason for hiding this comment

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

I saw the WIP label, so it's probably not for review, but I already had some comments so I posted them but I understand that you may already addressed them locally :)

Please also fix e2e tests (dotenv storage backend definition). Thanks!

test/e2e/action_test.go Outdated Show resolved Hide resolved
test/e2e/action_test.go Outdated Show resolved Hide resolved
test/e2e/action_test.go Outdated Show resolved Hide resolved
test/e2e/action_test.go Show resolved Hide resolved
@mkuziemko mkuziemko removed the WIP Work in progress label Mar 21, 2022
@pkosiec pkosiec added the enhancement New feature or request label Mar 23, 2022

typeInstance.Value = unmarshalledTI.Value
if unmarshalledTI.Backend != nil {
if typeInstance.Backend != nil {
Copy link
Member

@mszostok mszostok Mar 23, 2022

Choose a reason for hiding this comment

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

nit: IMO we should return an error when typeInstance.Backend.ID is not set. As setting context without backend ID means that it will be stored in built-in storage and this storage doesn't allow context by definition.

for filename in "${SRC}"/*; do
filename=$(basename -- "$filename")
prefix="${filename%.*}"

# remove value key if exists
Copy link
Member

Choose a reason for hiding this comment

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

For consistency reason, it would be good to also have unpackValue conf option here. When I went through our manifests, it was hard to understand why it works in this way, as this is a "hidden" functionality.

But let's do that on a new follow-up PR. It's not a blocker for merging this one 👍

@mkuziemko mkuziemko merged commit 6b60379 into capactio:main Mar 24, 2022
@mkuziemko mkuziemko deleted the add_context_to_backend branch March 24, 2022 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/engine Relates to Engine area/hub Relates to Hub enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants