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

Net 6575- Modify Gateways Cleanup Job to cleanup v2 resources #3317

Conversation

sarahalsmiller
Copy link
Member

Changes proposed in this PR:

  • Add v2 resources to gateway cleanup job

How I've tested this PR:

  • Local kind helm install/uninstall while running
    kubectl logs job/consul-consul-gateway-cleanup -n consul
    In order to make sure the cleanup job didn't actually error.
  • Updated unit test to cover v2 config map method

How I expect reviewers to test this PR:

  • Local kind helm install/uninstall from this branch
  • CI passes

Checklist:

@sarahalsmiller sarahalsmiller added pr/no-changelog PR does not need a corresponding .changelog entry pr/no-backport signals that a PR will not contain a backport label labels Dec 6, 2023
@sarahalsmiller sarahalsmiller requested review from a team, andrewstucki and NiniOak and removed request for a team December 6, 2023 21:24
@sarahalsmiller sarahalsmiller force-pushed the NET-6575-consul-k8s-Add-configmap-to-gateway-cleanup-job-to-allow-for-multiple-gatewayClasses-GatewayClassConfigs-and-also-a-MeshGateway branch from 80cedc2 to 0f65722 Compare December 6, 2023 21:28
_ = c.k8sClient.Delete(context.Background(), gatewayClass)

// make sure they're gone
if err := backoff.Retry(func() error {
Copy link
Member

Choose a reason for hiding this comment

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

why do we do this twice? any reason to not just do the entire delete in the retry block to begin with?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think since we're just ignoring the errors not having them in the retry block is an attempt to avoid spamming the same delete request while waiting for the finalizers to complete. But I just modified this code to make it into a loop.


// find the gateway class
gatewayClass := &v2beta1.GatewayClass{}
//TODO is the correct name for the gatewayclass?
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we are going to modify the configmap to have a gatewayclass in it, I will look for/make the story if you can add it as the TODO here

Copy link
Contributor

@missylbytes missylbytes Dec 8, 2023

Choose a reason for hiding this comment

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

//TODO: NET-6838
To pull the GatewayClassName from the Configmap

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you that makes sense. Will Add.

@sarahalsmiller sarahalsmiller force-pushed the NET-6575-consul-k8s-Add-configmap-to-gateway-cleanup-job-to-allow-for-multiple-gatewayClasses-GatewayClassConfigs-and-also-a-MeshGateway branch from 0f65722 to d03de67 Compare December 8, 2023 16:41
@@ -8,6 +8,9 @@ import (
"errors"
"flag"
"fmt"

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: extra newline

@sarahalsmiller sarahalsmiller merged commit 3f54861 into main Dec 8, 2023
32 of 48 checks passed
@sarahalsmiller sarahalsmiller deleted the NET-6575-consul-k8s-Add-configmap-to-gateway-cleanup-job-to-allow-for-multiple-gatewayClasses-GatewayClassConfigs-and-also-a-MeshGateway branch December 8, 2023 23:56
"github.com/hashicorp/consul-k8s/control-plane/api/v1alpha1"
"github.com/hashicorp/consul-k8s/control-plane/subcommand"
"github.com/hashicorp/consul-k8s/control-plane/subcommand/flags"
)

const (
gatewayConfigFilename = "/consul/config/config.yaml"
resourceConfigFilename = "/consul/config/resources.json"
Copy link
Member

Choose a reason for hiding this comment

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

should these live in another package? we use them in the resources job so I'm wondering if they belong in the gateways package as constants so we're not defining them twice across this and the resources job

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd be in favor of pulling them into a shared package.

return 0
}

func (c *Command) deleteV1GatewayClassAndGatewayClasConfig() error {
Copy link
Member

Choose a reason for hiding this comment

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

🙌

sarahalsmiller added a commit that referenced this pull request Jan 5, 2024
* cleanup existing gatewayclasses and gatewayclassconfigs

* add tests for v2

* fixed test to actually run against v2 resources, found issue where loop was failing out early

* add TODO with jira ticket

* cleanup debug line

* delete extra newline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr/no-backport signals that a PR will not contain a backport label pr/no-changelog PR does not need a corresponding .changelog entry theme/mesh-gw
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants