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

🐛 Ensure that existing ports also have correct tags and trunks #2256

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mquhuy
Copy link
Contributor

@mquhuy mquhuy commented Nov 15, 2024

What this PR does / why we need it:
When a port is created, it is tagged and explicitly checked if it needs a trunk, but if the port already exists for some reason, it is taken without any of those checking. This PR fixes that by adding a similar check for the existing ports, similar to the check in new ports.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Special notes for your reviewer:

  1. Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

TODOs:

  • squashed commits
  • if necessary:
    • includes documentation
    • adds unit tests

/hold

@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 15, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @mquhuy. Thanks for your PR.

I'm waiting for a kubernetes-sigs 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.

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.

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Nov 15, 2024
Copy link

netlify bot commented Nov 15, 2024

Deploy Preview for kubernetes-sigs-cluster-api-openstack ready!

Name Link
🔨 Latest commit fd992ba
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-cluster-api-openstack/deploys/673cd0ff18fc410008b86340
😎 Deploy Preview https://deploy-preview-2256--kubernetes-sigs-cluster-api-openstack.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@mquhuy mquhuy force-pushed the mquhuy/ensure-port-tags-and-trunks branch 3 times, most recently from f345dc1 to 921813b Compare November 15, 2024 10:53
@adilGhaffarDev
Copy link

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 15, 2024
@mquhuy mquhuy force-pushed the mquhuy/ensure-port-tags-and-trunks branch 2 times, most recently from dbd9ad8 to 777d80c Compare November 15, 2024 13:23
@mquhuy
Copy link
Contributor Author

mquhuy commented Nov 15, 2024

/retest

@EmilienM
Copy link
Contributor

no need to retest, the unit test failed

@mquhuy mquhuy force-pushed the mquhuy/ensure-port-tags-and-trunks branch from 777d80c to ce3bc0c Compare November 16, 2024 10:04
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 16, 2024
@mquhuy mquhuy force-pushed the mquhuy/ensure-port-tags-and-trunks branch from ce3bc0c to 674ffd2 Compare November 16, 2024 10:52
@mquhuy
Copy link
Contributor Author

mquhuy commented Nov 16, 2024

/retest

1 similar comment
@mquhuy
Copy link
Contributor Author

mquhuy commented Nov 18, 2024

/retest

@mquhuy mquhuy force-pushed the mquhuy/ensure-port-tags-and-trunks branch from 674ffd2 to 4d04792 Compare November 18, 2024 15:05
Copy link
Contributor

@lentzi90 lentzi90 left a comment

Choose a reason for hiding this comment

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

This looks pretty much ready! I just have a couple of comments on the tests.

controllers/openstackserver_controller_test.go Outdated Show resolved Hide resolved
controllers/openstackserver_controller_test.go Outdated Show resolved Hide resolved
test/e2e/data/e2e_conf.yaml Show resolved Hide resolved
pkg/cloud/services/networking/port_test.go Outdated Show resolved Hide resolved
@mquhuy mquhuy force-pushed the mquhuy/ensure-port-tags-and-trunks branch from 4d04792 to fd992ba Compare November 19, 2024 17:55
@mquhuy
Copy link
Contributor Author

mquhuy commented Nov 19, 2024

Thank you @lentzi90 . I've fixed the errors you pointed out.

Copy link
Contributor

@lentzi90 lentzi90 left a comment

Choose a reason for hiding this comment

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

/approve
/cc @EmilienM

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lentzi90

The full list of commands accepted by this bot can be found here.

The pull request process is described 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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 20, 2024
@EmilienM
Copy link
Contributor

To avoid copy/pasting my thoughts, I'll share a thread on Slack about this PR: https://kubernetes.slack.com/archives/CFKJB65G9/p1732192515903409
Before we merge this, I want to make sure we don't have another (long term) way of fixing these kind of issues which really can happen on any kind of OpenStack resources, not just ports and trunks.

@lentzi90
Copy link
Contributor

Also, @mquhuy we need to check if #1940 is the actual issue we are hitting.
It was fixed in v0.10 but not backported to v0.9.

Comment on lines +129 to +134
if len(portSpec.Tags) > 0 {
if err := s.replaceAllAttributesTags(eventObject, portResource, port.ID, portSpec.Tags); err != nil {
record.Warnf(eventObject, "FailedReplaceTags", "Failed to replace port tags %s: %v", portSpec.Name, err)
return err
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this going to call replaceAllAttributesTags on every reconcile, regardless of whether they're already set?

Comment on lines +152 to +155
existingPorts, err := s.client.ListPort(ports.ListOpts{
Name: portSpec.Name,
NetworkID: portSpec.NetworkID,
})
Copy link
Contributor

Choose a reason for hiding this comment

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

We have the port IDs of ports we've already created. Can we fetch by port ID? We should fall back to fetch by name in case we created a port but failed to write it to the status, but ideally fetch by ID would be the default here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

6 participants