Skip to content

Conversation

@adduarte
Copy link

If the user provides a subnet UUID under the networks filter,
we should not override the net uuid of the subnet because
by property of the subnet having UUID it means it already has
been created, which means that here already is an immutable link
between the subnet and a network
Overriding the value of the net uuid in the subnet definition at that point
can result in an invalid query, because
the current code allows for listing network UUIDs and subnet UUIDs under
the same entry of providerSpec.Networks which do not belong together.

The resulting lookup can end up in returning a port to be created which
cannot be created by OpenStack.
A port to be attached to a subnet that does not belong to the network
listed.

This patch give preference to the subnet associated with the subnet.UUID

If the user provides a subnet UUID under the networks filter,
we should not override the net uuid of the subnet because
by property of the subnet having UUID it means it already has
been created, which means that here already is an ummutable link
between the subnet and _a_ network
Overriding the value of the net uuid in the subnet definition  at that point
can result in an invalid query, because
the current code allows for listing nertwork UUIDs and subnet UUIDs under
the same entry of providerSpec.Networks which do not belong together.

The resulting lookup can end up in returning a port to be created which
cannot be created by OpenStack.
A port to be attached to a subnet that does not belong to the network
listed.

This patch give preference to the subnet associated with the subnet.UUID
@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 16, 2021
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please ask for approval from adduarte after the PR has been reviewed.

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

Details 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

if snetParam.UUID == "" {
sopts.ID = snetParam.UUID
}
sopts.NetworkID = netID
Copy link
Author

@adduarte adduarte Apr 16, 2021

Choose a reason for hiding this comment

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

If you look a the code before for networks the following entry will fail if the subnet does not belong to the network

ProviderSpec: ...
Networks: 
- UUID: my_net_uuid
  subnets:
         - uuid_of_subnet_not_under_my_net_uuid

It is even possible to create a problem if the subnet DOES belong to the net_uuid but the network filter returns more than one net.
For example, if for some reason there are two networks called "my_network" then the following entry will cause problems:

Providerspec:
     Networks: 
         - filter: 
               name: my_network
            subnets:
               - uuid: uuid_of_subnet_belonging_to_one_of_the_networks

Copy link
Author

@adduarte adduarte Apr 16, 2021

Choose a reason for hiding this comment

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

and one more It think:
again two networks with name "my_network"

Providerspec:
 Networks:
   - filter:
        - name: my_network
     subnets:
        - tags: primry-network

In this case oneport will be created correctly, while a second port will be created incorrectly (probably fail with an openstack error).
Note that I used network "name" to create the problem, but any filter under Networks, that returns more than one network will cause the same problem.

Choose a reason for hiding this comment

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

So, while it might not be the best user experience, because subnet is a neseted field under networks, it makes sense that if you define a network, then define a subnet that is not in that network, it will fail to create the resource. The easy solution is to just not set the network ID since it is not required, and a subnet can always be found by its ID. Also, all this code does is make it so you can never set the subnet ID...

Copy link
Author

@adduarte adduarte Apr 20, 2021

Choose a reason for hiding this comment

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

"all this code does is make it so you can never set the subnet iD" << that is incorrect.
What this code does is use the subnet.uuid defined by the user. Which is probably what the user intends.
If the user, does not define the subnet.uuid, then the network filters/and uuid (if provided) prevails.
But the moment a user defines a subnet.uuid under a network filter, that is what should override anything else. We don't need any other piece of information to attach the port. The subnet.uuid is the only piece of information we need to create the ports because there exists one and only one network with that subnet.uuid in its list of subnets.

The problem we have been seen as of late is that users are defining a network through a filter, then adding a subnet.uuid. In that case the subnet.uuid is what should be used because it is the more exact match.
Anything else in the providerspec.networks is superfluous to the subnet lookup. There is one and only one subnet that will match the subnet.uuid.

So, if the user is providing a subnet.uuid then there already exists a network uuid associated with that subnet.uuid. We should not be overriding the network.uuid in the struct representing the subnet. If we do so, we basically make that struct invalid, and no port will get connected, that is specially true if the user has defined a network filter which will return two or more networks. There can only be one network that matches the network filter and the subnet.uuid filter. Every other network will not be attached because the subnet.uuid will only match one network.
That becomes a problem has, for example, defined two networks with the same tag, and the providerspc.network filter is matching on tags. If the user defines a -subnet.uuid entry then only one network will be connected, which probably not what the user intended.

@openshift-bot
Copy link

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci openshift-ci bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 19, 2021
@openshift-bot
Copy link

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten
/remove-lifecycle stale

@openshift-ci openshift-ci bot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Aug 18, 2021
@openshift-bot
Copy link

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

@openshift-ci openshift-ci bot closed this Sep 17, 2021
@openshift-ci
Copy link

openshift-ci bot commented Sep 17, 2021

@openshift-bot: Closed this PR.

Details

In response to this:

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

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.

@mdbooth mdbooth deleted the BZ_1936511 branch April 6, 2022 15:56
pierreprinetti pushed a commit to shiftstack/cluster-api-provider-openstack that referenced this pull request Apr 22, 2024
Currently when provider tries to update cluster status, it gets error:

  User "system:serviceaccount:openstack-provider-system:default" cannot update resource "clusters/status" in API group "cluster.k8s.io" in the namespace "default"

This happens because "status" is separate subresource and access to it
must be granted separately.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants