Skip to content

Add ipv4 to the late-initialize ignored fields#52

Merged
tchinmai7 merged 1 commit into
mainfrom
fix-instance-ips
Apr 28, 2025
Merged

Add ipv4 to the late-initialize ignored fields#52
tchinmai7 merged 1 commit into
mainfrom
fix-instance-ips

Conversation

@tchinmai7
Copy link
Copy Markdown
Collaborator

Description of your changes

The linode API is now surfacing ALL ips on the linode, including ones that are added out of band. The instance's forProvider configuration shouldn't save the IPs, they are automatically assigned by linode. Adding it to the ignoredFields of late-initalizer fixes this problem. Also go back to upstream terraform library

I have:

  • Read and followed Crossplane's [contribution process].
  • Run make reviewable test to ensure this PR is ready for review.

How has this code been tested

1.make local-deploy
2. Create a linode secret & provider config

apiVersion: v1
data:
  credentials: YourCREDSHERE
kind: Secret
metadata:
  name: linode-api-token
  namespace: default
type: Opaque
---
apiVersion: linode.upbound.io/v1beta1
kind: ProviderConfig
metadata:
  name: default
spec:
  credentials:
    source: Secret
    secretRef:
      name: linode-api-token
      namespace: default
      key: credentials
  config:
    obj_bucket_force_delete: true
    obj_use_temp_keys: true
  1. create a instance and IP
apiVersion: instance.linode.upbound.io/v1alpha1
kind: Instance
metadata:
  name: "test-instance-take4"
  labels:
    foo.linode.com/type: ip-holder
spec:
  forProvider:
    region: "us-sea"
    backupsEnabled: false
    booted: false
    privateIp: false
    type: g6-nanode-1
    watchdogEnabled: false
---
apiVersion: instance.linode.upbound.io/v1alpha1
kind: IP
metadata:
  name: "test-ip-take4"
spec:
  forProvider:
    applyImmediately: true
    public: true
    linodeIdSelector:
      matchLabels:
        foo.linode.com/type: ip-holder
  1. Wait for it to be synced. Edit an annotation on the instance after ~60 seconds to force a reconcile.
  2. Verify that the instance stays synced, atProvider.ipv4 shows 2 ips and forProvider doesn't have any
    [contribution process]: https://git.io/fj2m9

@tchinmai7 tchinmai7 requested a review from Copilot April 28, 2025 18:53
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the configuration to ignore the IPv4 field during late initialization, preventing user-provided IPv4 values from being persisted in the instance’s configuration. It also adjusts debugging instructions in the developer documentation.

  • Updated developer documentation with new commands to set up and debug the provider.
  • Modified the late initializer in config/instance/config.go by adding "ipv4" to the ignored fields.
  • Updated the late initializer in apis/instance/v1alpha1/zz_instance_terraformed.go to include a name filter for "IPv4".

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.

File Description
docs/developer.md Revised debug commands for local deployment and provider debugging.
config/instance/config.go Added "ipv4" to the list of late initializer ignored fields.
apis/instance/v1alpha1/zz_instance_terraformed.go Added name filter "IPv4" to support late initialization and ignore field values.
Files not reviewed (1)
  • go.mod: Language not supported
Comments suppressed due to low confidence (1)

apis/instance/v1alpha1/zz_instance_terraformed.go:123

  • The case used for 'IPv4' in the name filter is inconsistent with the 'ipv4' string in the ignored fields list in config.go. Consider unifying the case to prevent potential mismatches.
opts = append(opts, resource.WithNameFilter("IPv4"))

@tchinmai7 tchinmai7 merged commit 2e8199c into main Apr 28, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants