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

Delete Consul custom resources with consul-k8s uninstall #1623

Merged
merged 43 commits into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
9e1c77a
Change uses to point to Git hash
Oct 27, 2022
7fa8bdc
Update Go client dep
Oct 13, 2022
22e8ee3
Rework to patch CRs
Oct 18, 2022
8ec67d2
Delete and patch CRs
Oct 19, 2022
616a253
Patch finalizers after uninstall
Oct 19, 2022
aa9d853
Add function for ignoring 404 errors
Oct 20, 2022
90ebac7
Change to using apiextensions lib
Oct 20, 2022
68863bc
Handle timeout for deletion
Oct 20, 2022
ca93bf4
Remove finalizer obj (took different route)
Oct 20, 2022
8f6cf15
Add DeletionError
Oct 20, 2022
bc7546d
Add some early returns
Oct 20, 2022
d363394
WIP: mocking dynamic client
Oct 20, 2022
ac82890
Test the new functions
Oct 21, 2022
c2ffdf1
Finish mocking the CRs in tests
Oct 21, 2022
573cecc
Polish tests
Oct 21, 2022
b5922e3
Add CR deletion to full uninstall test
Oct 21, 2022
273e63b
go mod tidy
Oct 21, 2022
d200b84
Add output to notify user of deletion/patching process
Oct 21, 2022
2687941
Polish output text
Oct 22, 2022
56ba323
Add mapping of kind to resource name
Oct 26, 2022
d5f6169
Fix tests with line break
Oct 26, 2022
d31baf3
Use uiLogger for consistency
Oct 26, 2022
55c6ada
Fix tests to fetch crds
Oct 26, 2022
2f8686c
Test mapCRKindToResource
Oct 26, 2022
e41d4e6
Use DurationVar for timeout
Oct 26, 2022
1371f45
Add CHANGELOG entry for PR 1623
Oct 26, 2022
862cce6
Remove merge conflict in workflows/test
Oct 31, 2022
12ca57e
Include Deletion of CRs message in TestUninstall
Oct 31, 2022
bc4f07b
Re-unify test strings
Oct 31, 2022
01131c1
Use k8serrors and test CR in another ns
Nov 1, 2022
2581d84
Comment out GHA
Nov 1, 2022
56fdd07
Rename k8s clients
Nov 1, 2022
476e4a1
Remove `IgnoreNotFoundError`
Nov 1, 2022
b4d61a9
Match style guide on CHANGELOG
Nov 1, 2022
8569563
Use schema.ParseGroupVersion
Nov 1, 2022
07d535f
Fix punctuation on initKubernetes
Nov 1, 2022
0d47724
Improve logging and separate out removal of CRs
Nov 1, 2022
3b3c034
Clean up the CR deletion method a bit
Nov 1, 2022
2073acd
Order imports
Nov 1, 2022
63aaf5b
Add doc comment to removeCustomResources
Nov 1, 2022
8c02cf2
Add fakeUILogger
Nov 1, 2022
168450c
Add retry to verifying patch command
Nov 1, 2022
2be231a
Fix output in uninstall test
Nov 2, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 38 additions & 38 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -342,43 +342,43 @@ jobs:
target: release-default
tags: docker.io/hashicorppreview/${{ env.repo }}-control-plane:${{ env.version }}-pr-${{ github.sha }}

acceptance:
t-eckert marked this conversation as resolved.
Show resolved Hide resolved
needs: [ get-product-version, dev-upload-docker, get-go-version ]
uses: hashicorp/consul-k8s/.github/workflows/reusable-acceptance.yml@main
with:
name: acceptance
directory: acceptance/tests
go-version: ${{ needs.get-go-version.outputs.go-version }}
additional-flags: "-use-kind -kubecontext=kind-dc1 -secondary-kubecontext=kind-dc2 -consul-image=docker.mirror.hashicorp.services/hashicorppreview/consul-enterprise:1.14-dev"
gotestsum-version: 1.8.2
consul-k8s-image: docker.io/hashicorppreview/${{ github.event.repository.name }}-control-plane:${{ needs.get-product-version.outputs.product-version }}-pr-${{ github.sha }}
secrets:
CONSUL_ENT_LICENSE: ${{ secrets.CONSUL_ENT_LICENSE }}

acceptance-tproxy:
needs: [ get-product-version, dev-upload-docker, get-go-version ]
uses: hashicorp/consul-k8s/.github/workflows/reusable-acceptance.yml@main
with:
name: acceptance-tproxy
directory: acceptance/tests
go-version: ${{ needs.get-go-version.outputs.go-version }}
additional-flags: "-use-kind -kubecontext=kind-dc1 -secondary-kubecontext=kind-dc2 -enable-transparent-proxy -consul-image=docker.mirror.hashicorp.services/hashicorppreview/consul-enterprise:1.14-dev"
gotestsum-version: 1.8.2
consul-k8s-image: docker.io/hashicorppreview/${{ github.event.repository.name }}-control-plane:${{ needs.get-product-version.outputs.product-version }}-pr-${{ github.sha }}
secrets:
CONSUL_ENT_LICENSE: ${{ secrets.CONSUL_ENT_LICENSE }}

acceptance-cni:
needs: [ get-product-version, dev-upload-docker, get-go-version ]
uses: hashicorp/consul-k8s/.github/workflows/reusable-acceptance.yml@main
with:
name: acceptance
directory: acceptance/tests
go-version: ${{ needs.get-go-version.outputs.go-version }}
additional-flags: "-use-kind -kubecontext=kind-dc1 -secondary-kubecontext=kind-dc2 -enable-transparent-proxy -enable-cni -consul-image=docker.mirror.hashicorp.services/hashicorppreview/consul-enterprise:1.14-dev"
gotestsum-version: 1.8.2
consul-k8s-image: docker.io/hashicorppreview/${{ github.event.repository.name }}-control-plane:${{ needs.get-product-version.outputs.product-version }}-pr-${{ github.sha }}
secrets:
CONSUL_ENT_LICENSE: ${{ secrets.CONSUL_ENT_LICENSE }}
# acceptance:
# needs: [ get-product-version, dev-upload-docker, get-go-version ]
# uses: hashicorp/consul-k8s/.github/workflows/reusable-acceptance.yml@main
# with:
# name: acceptance
# directory: acceptance/tests
# go-version: ${{ needs.get-go-version.outputs.go-version }}
# additional-flags: "-use-kind -kubecontext=kind-dc1 -secondary-kubecontext=kind-dc2 -consul-image=docker.mirror.hashicorp.services/hashicorppreview/consul-enterprise:1.14-dev"
# gotestsum-version: 1.8.2
# consul-k8s-image: docker.io/hashicorppreview/${{ github.event.repository.name }}-control-plane:${{ needs.get-product-version.outputs.product-version }}-pr-${{ github.sha }}
# secrets:
# CONSUL_ENT_LICENSE: ${{ secrets.CONSUL_ENT_LICENSE }}

# acceptance-tproxy:
# needs: [ get-product-version, dev-upload-docker, get-go-version ]
# uses: hashicorp/consul-k8s/.github/workflows/reusable-acceptance.yml@main
# with:
# name: acceptance-tproxy
# directory: acceptance/tests
# go-version: ${{ needs.get-go-version.outputs.go-version }}
# additional-flags: "-use-kind -kubecontext=kind-dc1 -secondary-kubecontext=kind-dc2 -enable-transparent-proxy -consul-image=docker.mirror.hashicorp.services/hashicorppreview/consul-enterprise:1.14-dev"
# gotestsum-version: 1.8.2
# consul-k8s-image: docker.io/hashicorppreview/${{ github.event.repository.name }}-control-plane:${{ needs.get-product-version.outputs.product-version }}-pr-${{ github.sha }}
# secrets:
# CONSUL_ENT_LICENSE: ${{ secrets.CONSUL_ENT_LICENSE }}

# acceptance-cni:
# needs: [ get-product-version, dev-upload-docker, get-go-version ]
# uses: hashicorp/consul-k8s/.github/workflows/reusable-acceptance.yml@main
# with:
# name: acceptance
# directory: acceptance/tests
# go-version: ${{ needs.get-go-version.outputs.go-version }}
# additional-flags: "-use-kind -kubecontext=kind-dc1 -secondary-kubecontext=kind-dc2 -enable-transparent-proxy -enable-cni -consul-image=docker.mirror.hashicorp.services/hashicorppreview/consul-enterprise:1.14-dev"
# gotestsum-version: 1.8.2
# consul-k8s-image: docker.io/hashicorppreview/${{ github.event.repository.name }}-control-plane:${{ needs.get-product-version.outputs.product-version }}-pr-${{ github.sha }}
# secrets:
# CONSUL_ENT_LICENSE: ${{ secrets.CONSUL_ENT_LICENSE }}


1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ FEATURES:
IMPROVEMENTS:
* CLI
* Update minimum go version for project to 1.19 [[GH-1633](https://github.com/hashicorp/consul-k8s/pull/1633)]
* Enable `consul-k8s uninstall` to delete custom resources when uninstalling Consul. This is done by default. [[GH-1623](https://github.com/hashicorp/consul-k8s/pull/1623)]
* Control Plane
* Update minimum go version for project to 1.19 [[GH-1633](https://github.com/hashicorp/consul-k8s/pull/1633)]
* Remove unneeded `agent:read` ACL permissions from mesh gateway policy. [[GH-1255](https://github.com/hashicorp/consul-k8s/pull/1255)]
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ func (c *Command) installConsul(valuesYaml []byte, vals map[string]interface{},
if len(vals) == 0 {
c.UI.Output("\nNo overrides provided, using the default Helm values.", terminal.WithInfoStyle())
} else {
c.UI.Output("\nHelm value overrides\n-------------------\n"+string(valuesYaml), terminal.WithInfoStyle())
c.UI.Output("\nHelm value overrides\n--------------------\n"+string(valuesYaml), terminal.WithInfoStyle())
t-eckert marked this conversation as resolved.
Show resolved Hide resolved
}

// Without informing the user, default global.name to consul if it hasn't been set already. We don't allow setting
Expand Down
6 changes: 3 additions & 3 deletions cli/cmd/install/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ func TestInstall(t *testing.T) {
},
messages: []string{
"\n==> Checking if Consul can be installed\n ✓ No existing Consul installations found.\n ✓ No existing Consul persistent volume claims found\n ✓ No existing Consul secrets found.\n ✓ Valid enterprise Consul secret found.\n",
"\n==> Consul Installation Summary\n Name: consul\n Namespace: consul\n \n Helm value overrides\n -------------------\n global:\n enterpriseLicense:\n secretName: consul-license\n \n",
"\n==> Consul Installation Summary\n Name: consul\n Namespace: consul\n \n Helm value overrides\n --------------------\n global:\n enterpriseLicense:\n secretName: consul-license\n \n",
"\n==> Installing Consul\n ✓ Downloaded charts.\n ✓ Consul installed in namespace \"consul\".\n",
},
helmActionsRunner: &helm.MockActionRunner{},
Expand Down Expand Up @@ -558,7 +558,7 @@ func TestInstall(t *testing.T) {
},
messages: []string{
"\n==> Checking if Consul can be installed\n ✓ No existing Consul installations found.\n ✓ No existing Consul persistent volume claims found\n ✓ No existing Consul secrets found.\n",
"\n==> Consul Installation Summary\n Name: consul\n Namespace: consul\n \n Helm value overrides\n -------------------\n connectInject:\n enabled: true\n metrics:\n defaultEnableMerging: true\n defaultEnabled: true\n enableGatewayMetrics: true\n controller:\n enabled: true\n global:\n metrics:\n enableAgentMetrics: true\n enabled: true\n name: consul\n prometheus:\n enabled: true\n server:\n replicas: 1\n ui:\n enabled: true\n service:\n enabled: true\n \n",
"\n==> Consul Installation Summary\n Name: consul\n Namespace: consul\n \n Helm value overrides\n --------------------\n connectInject:\n enabled: true\n metrics:\n defaultEnableMerging: true\n defaultEnabled: true\n enableGatewayMetrics: true\n controller:\n enabled: true\n global:\n metrics:\n enableAgentMetrics: true\n enabled: true\n name: consul\n prometheus:\n enabled: true\n server:\n replicas: 1\n ui:\n enabled: true\n service:\n enabled: true\n \n",
"\n==> Installing Consul\n ✓ Downloaded charts.\n ✓ Consul installed in namespace \"consul\".\n",
},
helmActionsRunner: &helm.MockActionRunner{},
Expand All @@ -574,7 +574,7 @@ func TestInstall(t *testing.T) {
},
messages: []string{
"\n==> Checking if Consul can be installed\n ✓ No existing Consul installations found.\n ✓ No existing Consul persistent volume claims found\n ✓ No existing Consul secrets found.\n",
"\n==> Consul Installation Summary\n Name: consul\n Namespace: consul\n \n Helm value overrides\n -------------------\n connectInject:\n enabled: true\n controller:\n enabled: true\n global:\n acls:\n manageSystemACLs: true\n gossipEncryption:\n autoGenerate: true\n name: consul\n tls:\n enableAutoEncrypt: true\n enabled: true\n server:\n replicas: 1\n \n",
"\n==> Consul Installation Summary\n Name: consul\n Namespace: consul\n \n Helm value overrides\n --------------------\n connectInject:\n enabled: true\n controller:\n enabled: true\n global:\n acls:\n manageSystemACLs: true\n gossipEncryption:\n autoGenerate: true\n name: consul\n tls:\n enableAutoEncrypt: true\n enabled: true\n server:\n replicas: 1\n \n",
"\n==> Installing Consul\n ✓ Downloaded charts.\n ✓ Consul installed in namespace \"consul\".\n",
},
helmActionsRunner: &helm.MockActionRunner{},
Expand Down
Loading