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

Remove backfilling to AzureCluster spec from vnet reconciliation #3855

Open
nojnhuh opened this issue Aug 16, 2023 · 7 comments
Open

Remove backfilling to AzureCluster spec from vnet reconciliation #3855

nojnhuh opened this issue Aug 16, 2023 · 7 comments
Labels
kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API

Comments

@nojnhuh
Copy link
Contributor

nojnhuh commented Aug 16, 2023

/kind api-change

What needs cleanup:

During reconciliation of virtual network resources, several fields under an AzureCluster's spec.networkSpec.vnet are backfilled with "actual" state gathered from the Azure API.

These fields include:

  • id
  • tags
  • cidrBlocks

And under spec.networkSpec.subnets:

  • cidrBlocks

Populating spec fields from a resource's own controller this way is considered an anti-pattern [citation needed, but IIRC mostly because of the not-entirely-philosophical "spec = desired state, status = actual state" distinction].

Relevant code:

vnet := s.Scope.Vnet()
vnet.ID = ptr.Deref(existingVnet.ID, "")
vnet.Tags = converters.MapToTags(existingVnet.Tags)
var prefixes []string
if existingVnet.VirtualNetworkPropertiesFormat != nil && existingVnet.VirtualNetworkPropertiesFormat.AddressSpace != nil {
prefixes = azure.StringSlice(existingVnet.VirtualNetworkPropertiesFormat.AddressSpace.AddressPrefixes)
}
vnet.CIDRBlocks = prefixes
// Update the subnet CIDRs if they already exist.
// This makes sure the subnet CIDRs are up to date and there are no validation errors when updating the VNet.
// Subnets that are not part of this cluster spec are silently ignored.
if existingVnet.Subnets != nil {
for _, subnet := range *existingVnet.Subnets {
s.Scope.UpdateSubnetCIDRs(ptr.Deref(subnet.Name, ""), converters.GetSubnetAddresses(subnet))
}
}

In addition to following Kubernetes best practices, part of the motivation for this change is to simplify the ASO implementation for reconciling vnets and remove a dependency on implementing ASO for subnets at the same time as for vnets.

Describe the solution you'd like

Instead of populating fields in spec representing "actual" state, the same info would fit better in an AzureCluster's status field. There, it would still be available from the API but not subject to the same validation which triggered the issue fixed by #2339 and would more clearly not collide with any user-specified values.

Anything else you would like to add:
This is to some degree a breaking change to the API, where users may currently be relying on the current behavior.

@k8s-ci-robot k8s-ci-robot added the kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API label Aug 16, 2023
@CecileRobertMichon
Copy link
Contributor

related to #1685

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 26, 2024
@nojnhuh
Copy link
Contributor Author

nojnhuh commented Jan 26, 2024

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 26, 2024
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 25, 2024
@nawazkh
Copy link
Member

nawazkh commented May 16, 2024

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 16, 2024
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 14, 2024
@nawazkh
Copy link
Member

nawazkh commented Sep 4, 2024

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API
Projects
Status: No status
Development

No branches or pull requests

5 participants