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

Unable to ignore resource limit for ephemeral-storage with transfomations #3376

Open
landorg opened this issue Dec 18, 2024 · 0 comments
Open
Labels
kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team

Comments

@landorg
Copy link

landorg commented Dec 18, 2024

What happened?

I am using an autopilot cluster on gcp and therefore I'm ignoring changes to spec.template.spec.containers[0].resources of my redis helm charts' Statefulsets with transfomations. This works for memory and cpu but not for ephemeral-storage and triggers an update on every up.

Example

import pulumi
from pulumi_kubernetes.helm.v4 import Chart

from pulumi import ResourceOptions


class Redis(pulumi.ComponentResource):
    """Redis instance resources."""

    def __init__(
        self,
        name: str,
        namespace: str,
        opts: ResourceOptions | None = None,
    ):
        """Intitialize all the components."""
        super().__init__("iDMlib:dbs:Redis", name, {}, opts)

        def ignore_autopilot_changes(args: pulumi.ResourceTransformArgs):
            if args.type_ == "kubernetes:apps/v1:StatefulSet":
                return pulumi.ResourceTransformationResult(
                    props=args.props,
                    opts=pulumi.ResourceOptions.merge(
                        args.opts,
                        pulumi.ResourceOptions(
                            parent=self,
                            ignore_changes=[
                                "spec.template.spec.containers[0].resources",
                                # tried all these:
                                # "spec.template.spec.containers[0].resources.requests.cpu",
                                # "spec.template.spec.containers[0].resources.requests.memory",
                                # "spec.template.spec.containers[0].resources.limits.cpu",
                                # "spec.template.spec.containers[0].resources.limits.memory",
                                # "spec.template.spec.containers[0].resources.limits.ephemeral-storage",
                                # "spec.template.spec.containers[0].resources.limits.*",
                            ],
                        ),
                    ),
                )

        child_opts = pulumi.ResourceOptions(
            parent=self,
            transforms=[ignore_autopilot_changes],
        )

        self.chart = Chart(
            "redis",
            namespace=namespace,
            chart="oci://registry-1.docker.io/bitnamicharts/redis",
            version="20.5.0",
            opts=child_opts,
            values={"replica": {"replicaCount": 0}},
        )

Applying this twice gives me that diff:

❯ pulumi up
Previewing update (production):
     Type                                     Name                                               Plan       Info
     pulumi:pulumi:Stack                      web-navpro-frontend-production                                2 messages
     └─ iDMlib:dbs:Redis                      web-navpro-frontend
        └─ kubernetes:helm.sh/v4:Chart        redis
 ~         ├─ kubernetes:apps/v1:StatefulSet  redis:web-navpro-frontend-cc2e5a88/redis-replicas  update     [diff: ~spec]
 ~         └─ kubernetes:apps/v1:StatefulSet  redis:web-navpro-frontend-cc2e5a88/redis-master    update     [diff: ~spec]

Diagnostics:
  pulumi:pulumi:Stack (web-navpro-frontend-production):
    Error in sys.excepthook:
    Original exception was:

Resources:
    ~ 2 to update
    30 unchanged

Do you want to perform this update? details
  pulumi:pulumi:Stack: (same)
    [urn=urn:pulumi:production::web-navpro-frontend::pulumi:pulumi:Stack::web-navpro-frontend-production]
            ~ kubernetes:apps/v1:StatefulSet: (update)
                [id=web-navpro-frontend-cc2e5a88/redis-replicas]
                [urn=urn:pulumi:production::web-navpro-frontend::iDMlib:dbs:Redis$kubernetes:helm.sh/v4:Chart$kubernetes:apps/v1:StatefulSet::redis:web-navpro-frontend-cc2e5a88/redis-replicas]
              ~ spec: {
                  ~ template: {
                      ~ spec: {
                          ~ containers: [
                              ~ [0]: {
                                      ~ resources: {
                                          ~ limits: {
                                              ~ ephemeral-storage: "50Mi" => "2Gi"
                                            }
                                        }
                                    }
                            ]
                        }
                    }
                }
            ~ kubernetes:apps/v1:StatefulSet: (update)
                [id=web-navpro-frontend-cc2e5a88/redis-master]
                [urn=urn:pulumi:production::web-navpro-frontend::iDMlib:dbs:Redis$kubernetes:helm.sh/v4:Chart$kubernetes:apps/v1:StatefulSet::redis:web-navpro-frontend-cc2e5a88/redis-master]
              ~ spec: {
                  ~ template: {
                      ~ spec: {
                          ~ containers: [
                              ~ [0]: {
                                      ~ resources: {
                                          ~ limits: {
                                              ~ ephemeral-storage: "50Mi" => "2Gi"
                                            }
                                        }
                                    }
                            ]
                        }
                    }
                }

Do you want to perform this update? yes
Updating (production):
     Type                                     Name                                               Status              Info
     pulumi:pulumi:Stack                      web-navpro-frontend-production                                         2 messages
     └─ iDMlib:dbs:Redis                      web-navpro-frontend
        └─ kubernetes:helm.sh/v4:Chart        redis
 ~         ├─ kubernetes:apps/v1:StatefulSet  redis:web-navpro-frontend-cc2e5a88/redis-master    updated (0.32s)     [diff: ~spec]
 ~         └─ kubernetes:apps/v1:StatefulSet  redis:web-navpro-frontend-cc2e5a88/redis-replicas  updated (0.34s)     [diff: ~spec]

Diagnostics:
  pulumi:pulumi:Stack (web-navpro-frontend-production):
    Error in sys.excepthook:
    Original exception was:

Resources:
    ~ 2 updated
    30 unchanged

Duration: 9s

Output of pulumi about

CLI          
Version      3.143.0
Go Version   go1.23.4
Go Compiler  gc

Plugins
KIND      NAME        VERSION
resource  gcp         8.10.2
resource  kubernetes  4.18.4
language  python      3.143.0

Host     
OS       arch
Version  
Arch     x86_64

This project is written in python: executable='/home/user/development/iDM/web_navpro_frontend/infrastructure/venv/bin/python' version='3.12.7'

Current Stack: organization/web-navpro-frontend/production

TYPE                                                 URN
pulumi:pulumi:Stack                                  urn:pulumi:production::web-navpro-frontend::pulumi:pulumi:Stack::web-navpro-frontend-production
iDMlib:general:Cluster                               urn:pulumi:production::web-navpro-frontend::iDMlib:general:Cluster::cluster
pulumi:providers:gcp                                 urn:pulumi:production::web-navpro-frontend::iDMlib:general:Cluster$pulumi:providers:gcp::default
gcp:compute/globalAddress:GlobalAddress              urn:pulumi:production::web-navpro-frontend::iDMlib:general:Cluster$gcp:compute/globalAddress:GlobalAddress::cloud-myidm-wildcard
pulumi:providers:kubernetes                          urn:pulumi:production::web-navpro-frontend::pulumi:providers:kubernetes::default
iDMlib:general:ObjectStore                           urn:pulumi:production::web-navpro-frontend::iDMlib:general:ObjectStore::web-navpro-frontend
iDMlib:general:Basics                                urn:pulumi:production::web-navpro-frontend::iDMlib:general:Basics::web-navpro-frontend
iDMlib:dbs:Redis                                     urn:pulumi:production::web-navpro-frontend::iDMlib:dbs:Redis::web-navpro-frontend
iDMlib:general:App                                   urn:pulumi:production::web-navpro-frontend::iDMlib:general:App::web-navpro-frontend
gcp:storage/bucket:Bucket                            urn:pulumi:production::web-navpro-frontend::iDMlib:general:ObjectStore$gcp:storage/bucket:Bucket::web-navpro-frontend
kubernetes:core/v1:Namespace                         urn:pulumi:production::web-navpro-frontend::iDMlib:general:Basics$kubernetes:core/v1:Namespace::web-navpro-frontend
gcp:storage/bucketIAMBinding:BucketIAMBinding        urn:pulumi:production::web-navpro-frontend::iDMlib:general:ObjectStore$gcp:storage/bucketIAMBinding:BucketIAMBinding::web-navpro-frontend
kubernetes:core/v1:ConfigMap                         urn:pulumi:production::web-navpro-frontend::iDMlib:general:App$kubernetes:core/v1:ConfigMap::web-navpro-frontend
kubernetes:cloud.google.com/v1:BackendConfig         urn:pulumi:production::web-navpro-frontend::iDMlib:general:App$kubernetes:cloud.google.com/v1:BackendConfig::web-navpro-frontend
kubernetes:networking.gke.io/v1beta1:FrontendConfig  urn:pulumi:production::web-navpro-frontend::iDMlib:general:App$kubernetes:networking.gke.io/v1beta1:FrontendConfig::web-navpro-frontend
kubernetes:networking.gke.io/v1:ManagedCertificate   urn:pulumi:production::web-navpro-frontend::iDMlib:general:App$kubernetes:networking.gke.io/v1:ManagedCertificate::web-navpro-frontend
pulumi:providers:pulumi                              urn:pulumi:production::web-navpro-frontend::pulumi:providers:pulumi::default
kubernetes:core/v1:Service                           urn:pulumi:production::web-navpro-frontend::iDMlib:general:App$kubernetes:core/v1:Service::web-navpro-frontend
kubernetes:helm.sh/v4:Chart                          urn:pulumi:production::web-navpro-frontend::iDMlib:dbs:Redis$kubernetes:helm.sh/v4:Chart::redis
kubernetes:apps/v1:Deployment                        urn:pulumi:production::web-navpro-frontend::iDMlib:general:App$kubernetes:apps/v1:Deployment::web-navpro-frontend
kubernetes:networking.k8s.io/v1:Ingress              urn:pulumi:production::web-navpro-frontend::iDMlib:general:App$kubernetes:networking.k8s.io/v1:Ingress::web-navpro-frontend
kubernetes:core/v1:ConfigMap                         urn:pulumi:production::web-navpro-frontend::iDMlib:dbs:Redis$kubernetes:helm.sh/v4:Chart$kubernetes:core/v1:ConfigMap::redis:web-navpro-frontend-cc2e5a88/redis-health
kubernetes:core/v1:Secret                            urn:pulumi:production::web-navpro-frontend::iDMlib:dbs:Redis$kubernetes:helm.sh/v4:Chart$kubernetes:core/v1:Secret::redis:web-navpro-frontend-cc2e5a88/redis
kubernetes:core/v1:ServiceAccount                    urn:pulumi:production::web-navpro-frontend::iDMlib:dbs:Redis$kubernetes:helm.sh/v4:Chart$kubernetes:core/v1:ServiceAccount::redis:web-navpro-frontend-cc2e5a88/redis-replica
kubernetes:core/v1:Service                           urn:pulumi:production::web-navpro-frontend::iDMlib:dbs:Redis$kubernetes:helm.sh/v4:Chart$kubernetes:core/v1:Service::redis:web-navpro-frontend-cc2e5a88/redis-replicas
kubernetes:core/v1:ConfigMap                         urn:pulumi:production::web-navpro-frontend::iDMlib:dbs:Redis$kubernetes:helm.sh/v4:Chart$kubernetes:core/v1:ConfigMap::redis:web-navpro-frontend-cc2e5a88/redis-scripts
kubernetes:core/v1:Service                           urn:pulumi:production::web-navpro-frontend::iDMlib:dbs:Redis$kubernetes:helm.sh/v4:Chart$kubernetes:core/v1:Service::redis:web-navpro-frontend-cc2e5a88/redis-headless
kubernetes:core/v1:ConfigMap                         urn:pulumi:production::web-navpro-frontend::iDMlib:dbs:Redis$kubernetes:helm.sh/v4:Chart$kubernetes:core/v1:ConfigMap::redis:web-navpro-frontend-cc2e5a88/redis-configuration
kubernetes:core/v1:Service                           urn:pulumi:production::web-navpro-frontend::iDMlib:dbs:Redis$kubernetes:helm.sh/v4:Chart$kubernetes:core/v1:Service::redis:web-navpro-frontend-cc2e5a88/redis-master
kubernetes:core/v1:ServiceAccount                    urn:pulumi:production::web-navpro-frontend::iDMlib:dbs:Redis$kubernetes:helm.sh/v4:Chart$kubernetes:core/v1:ServiceAccount::redis:web-navpro-frontend-cc2e5a88/redis-master
kubernetes:policy/v1:PodDisruptionBudget             urn:pulumi:production::web-navpro-frontend::iDMlib:dbs:Redis$kubernetes:helm.sh/v4:Chart$kubernetes:policy/v1:PodDisruptionBudget::redis:web-navpro-frontend-cc2e5a88/redis-replicas
kubernetes:policy/v1:PodDisruptionBudget             urn:pulumi:production::web-navpro-frontend::iDMlib:dbs:Redis$kubernetes:helm.sh/v4:Chart$kubernetes:policy/v1:PodDisruptionBudget::redis:web-navpro-frontend-cc2e5a88/redis-master
kubernetes:networking.k8s.io/v1:NetworkPolicy        urn:pulumi:production::web-navpro-frontend::iDMlib:dbs:Redis$kubernetes:helm.sh/v4:Chart$kubernetes:networking.k8s.io/v1:NetworkPolicy::redis:web-navpro-frontend-cc2e5a88/redis
kubernetes:apps/v1:StatefulSet                       urn:pulumi:production::web-navpro-frontend::iDMlib:dbs:Redis$kubernetes:helm.sh/v4:Chart$kubernetes:apps/v1:StatefulSet::redis:web-navpro-frontend-cc2e5a88/redis-master
kubernetes:apps/v1:StatefulSet                       urn:pulumi:production::web-navpro-frontend::iDMlib:dbs:Redis$kubernetes:helm.sh/v4:Chart$kubernetes:apps/v1:StatefulSet::redis:web-navpro-frontend-cc2e5a88/redis-replicas


Found no pending operations associated with production

Backend        
Name           iDM-01033
URL            file://~
User           user
Organizations  
Token type     personal

Dependencies:
NAME               VERSION
pip                24.3.1
pulumi_gcp         8.10.2
pulumi_kubernetes  4.18.4
pyright            1.1.390
setuptools         75.6.0
wheel              0.45.1

Pulumi locates its logs in /tmp by default

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

@landorg landorg added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team
Projects
None yet
Development

No branches or pull requests

1 participant