Skip to content

Conversation

@frozenprocess
Copy link
Contributor

Description

This PR allows users to change the filename via installation manfiest.

example:

apiVersion: operator.tigera.io/v1
kind: Installation
metadata:
  name: default
spec:
  cni:
    type: Calico
    ipam:
      type: Calico
    confName: "00-calico.conflist"

Release Note

Installation manifest now allows users to change the CNI file name using the `confName` value under the subtree of `cni`.

For PR author

  • Tests for change.
  • [ x ] If changing pkg/apis/, run make gen-files
  • [ x ] If changing versions, run make gen-versions

For PR reviewers

A note for code reviewers - all pull requests must have the following:

  • Milestone set according to targeted release.
  • Appropriate labels:
    • kind/bug if this is a bugfix.
    • kind/enhancement if this is a a new feature.
    • enterprise if this PR applies to Calico Enterprise only.

This PR allows users to change the filename via installation manfiest.

example:
```
apiVersion: operator.tigera.io/v1
kind: Installation
metadata:
  name: default
spec:
  cni:
    type: Calico
    ipam:
      type: Calico
    confName: "00-calico.conflist"
```
@frozenprocess frozenprocess requested a review from a team as a code owner January 24, 2026 22:42
@marvin-tigera marvin-tigera added this to the v1.42.0 milestone Jan 24, 2026
@frozenprocess frozenprocess marked this pull request as draft January 24, 2026 22:46
Copy link
Member

@caseydavenport caseydavenport left a comment

Choose a reason for hiding this comment

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

A few thoughts

// please ensure that this field matches the same name as specified in the container runtime settings.
// Default: "10-calico.conflist"
// +optional
// +kubebuilder:validation:Type=string
Copy link
Member

Choose a reason for hiding this comment

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

We should add a kubebuilder default here as well

Suggested change
// +kubebuilder:validation:Type=string
// +kubebuilder:validation:Type=string
// +kubebuilder:default=10-calico.conflist


// ConfName is the name of the CNI config file.
// If you have changed the name of the CNI configuration file in the container runtime configuration,
// please ensure that this field matches the same name as specified in the container runtime settings.
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this field needs to match anything in the container runtime settings (looks like copy/paste from the ConfDir param)

Comment on lines +641 to +642
defaultCNIConfName := "10-calico.conflist"
instance.Spec.CNI.ConfName = &defaultCNIConfName
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
defaultCNIConfName := "10-calico.conflist"
instance.Spec.CNI.ConfName = &defaultCNIConfName
instance.Spec.CNI.ConfName = ptr.To("10-calico.conflist")

}

if err := c.node.assertEnv(ctx, c.client, containerInstallCNI, "CNI_CONF_NAME", "10-calico.conflist"); err != nil {
if err := c.node.assertEnv(ctx, c.client, containerInstallCNI, "CNI_CONF_NAME", *install.Spec.CNI.ConfName); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Instead of asserting the env var matches, we should get the CNI_CONF_NAME env var and update the install.Spec.CNI.ConfName field to match.

This means we can now upgrade manifest -> operator even if a custom CNI config name has been used.


envVars := []corev1.EnvVar{
{Name: "CNI_CONF_NAME", Value: "10-calico.conflist"},
{Name: "CNI_CONF_NAME", Value: *c.cfg.Installation.CNI.ConfName},
Copy link
Member

Choose a reason for hiding this comment

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

Would like to see a unit test for this field

// Default: "10-calico.conflist"
// +optional
// +kubebuilder:validation:Type=string
ConfName *string `json:"confName,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

One thing we are going to have to solve is what to do if this value is changed to something with less priority.

e.g., if you switch from 20-calico.conflist to 30-calico.conflist, the new configuration file will be ignored by the container runtime because the old configuration sorts higher.

We have some very rudimentary support for removing old config files here: https://github.com/projectcalico/calico/blob/master/cni-plugin/pkg/install/install.go#L413-L420

But it requires knowing the name of the file you want to remove!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants