I have this persistent volume claim resource: ```i...
# kubernetes
a
I have this persistent volume claim resource:
Copy code
import {
  PersistentVolumeClaim,
  type PersistentVolumeClaimArgs,
} from '@pulumi/kubernetes/core/v1/persistentVolumeClaim';
import { output } from '@pulumi/pulumi/output';
import type { CustomResourceOptions } from '@pulumi/pulumi/resource';

export class SaasPersistentVolumeClaim extends PersistentVolumeClaim {

  constructor(name: string, args: SaasPersistentVolumeClaimArgs, opts?: CustomResourceOptions) {

    super(
      name,
      {
        metadata: output(args).apply((args) => ({
          namespace: args.metadata?.namespace,
          labels: args.metadata?.labels,
          annotations: {
            '<http://pulumi.com/patchForce|pulumi.com/patchForce>': 'true',
            '<http://pulumi.com/skipAwait|pulumi.com/skipAwait>': 'true'
          },
          name: name,
        })),
        spec: {
          accessModes: ['ReadWriteOnce'],
          resources: { requests: { storage: `${args.newSize}Gi` } },
          storageClassName: 'performance-regular',
        },
      },
      {
        ...opts,
        ignoreChanges: ['metadata', 'spec.accessModes', 'spec.storageClassName'],
      },
    );
  }
}
Here, I deploy the pvc with 10Gi, and I want to upgrade it to have 20Gi. When I: • include the
metadata
field in the
ignoreChanges
array, the upgrade fails with
metadata.managedFields must be nil
• remove the
metadata
field from the
ignoreChanges
array, the upgrade is successful I think the
'<http://pulumi.com/patchForce|pulumi.com/patchForce>': 'true'
is getting ignored during the update because it's in the
ignoreChanges
array. I want to keep the
metadata
field in the
ignoreChanges
array. Theoretically, the
'<http://pulumi.com/patchForce|pulumi.com/patchForce>': 'true'
should be used during the operation, just changes to it should be ignored. This looks like a bug with pulumi, or is there something I'm missing? Versions:
Copy code
"@pulumi/kubernetes": "4.5.5",
    "@pulumi/pulumi": "3.94.2",
Any help is appreciated!
c
Why do you want to ignore those fields?
a
Because changing the metadata.name recreates a PVC. To not lose data, we ignore the whole metadata field because we don't know updates to which other metadata fields cause recreations.
c
Changing the name does indeed recreate a PVC, but that's the intended behaviour. I'd suggest using
preview
to verify change sets, as ignoring the entire metadata could have unintended side effects as you've noticed.
a
That's not a feasible option since the up flow is automated using the automation API, so we do not preview the changes. But anyway, ignoring just the
metadata.name
has been enough to ensure that the PVC is not deleted on changes. Thank you for your input!