GoogleContainerTools / skaffold

Easy and Repeatable Kubernetes Development
https://skaffold.dev/
Apache License 2.0
14.93k stars 1.62k forks source link

'file name too long' error with configmap kustomize patch when running skaffold dev(only). #4439

Closed lee-baines closed 4 years ago

lee-baines commented 4 years ago

Expected behavior

Skaffold dev lists the files to watch then proceeds with deployment.

Actual behavior

Skaffold dev actually throws a file name too long error, when listing the configmap file to watch, that includes the strategicPatchMerge config. Reducing the amount in the patch will allow it to work.

Information

  commonArtifactSets:
    default-artifacts: &default-artifacts
    - *AM
    - *AMSTER
    - *IDM
    - *DS-CTS
    - *DS-IDREPO
    - *FORGEOPS-SECRETS
    - *IG
    - *LDIF-IMPORTER

build: &default-build
  artifacts: *default-artifacts
  tagPolicy:
    sha256: {}

- name: small
  build: *default-build
  deploy:
    kustomize:
      path: ./kustomize/overlay/7.0/small
configMapGenerator:
- name: platform-config
  # The env vars below can be passed into a pod using the envFrom pod spec.
  # These global variables can be used to parameterize your deployments.
  # The FQDN and URLs here should match your ingress or istio gateway definitions
  literals:
  - SUBDOMAIN=iam
  - DOMAIN=example.com
  - FQDN=default.iam.example.com
  - AM_URL=https://$(FQDN)/am
  - AM_ADMIN_URL=https://$(FQDN)/am/ui-admin/
  - IDM_ADMIN_URL=https://$(FQDN)/admin
  - IDM_UPLOAD_URL=https://$(FQDN)/upload
  - IDM_EXPORT_URL=https://$(FQDN)/export
  - PLATFORM_ADMIN_URL=https://$(FQDN)/platform
  - IDM_REST_URL=https://$(FQDN)/openidm
  - ENDUSER_UI_URL=https://$(FQDN)/enduser
  - LOGIN_UI_URL=https://$(FQDN)/login/#/service/Login
  - ENDUSER_CLIENT_ID=end-user-ui
  - ADMIN_CLIENT_ID=idm-admin-ui
  - THEME=default
  - AM_STORES_CTS_SERVERS="ds-cts-0.ds-cts:1389"
  - AM_STORES_USER_SERVERS="ds-idrepo-0.ds-idrepo:1389"
  - AM_SERVER_FQDN="$(FQDN)"
  - AUTORESTORE_FROM_DSBACKUP="false" # Set to "true" to enable DS auto recovery. See documentation 
  - DSBACKUP_DIRECTORY="" # Ex. gs://bucket | s3://bucket | az://bucket
  - CERT_ISSUER="default-issuer" # cert manager issuer. Patch with letsencrypt-prod for LE SSL certs.
patchesStrategicMerge:
- |-
  apiVersion: v1
  kind: ConfigMap
  metadata:
    name: platform-config
  data:
    # Some optional settings
    # Set the FQDN - includes the namespace prefix!
    # FQDN: prod.pit-test.forgeops.com
    # If you are using cert-manager and Let's Encrypt in your cluster and want real certs - set this
    # CERT_ISSUER: letsencrypt-prod
    AM_STORES_CTS_SERVERS: "ds-cts-0.ds-cts:1389,ds-cts-1.ds-cts:1389,ds-cts-2.ds-cts:1389"
    AM_STORES_USER_SERVERS: "ds-idrepo-0.ds-idrepo:1389,ds-idrepo-1.ds-idrepo:1389,ds-idrepo-2.ds-idrepo:1389"

Steps to reproduce the behavior

  1. https://github.com/ForgeRock/forgeops
  2. skaffold dev -p small
lee-baines commented 4 years ago

log output with -v debug


INFO[0000] starting gRPC HTTP server on port 50052      
INFO[0000] Skaffold &{Version:v1.12.0 ConfigVersion:skaffold/v2beta5 GitVersion: GitCommit:e680a831292e1c7efc54e0c6d40544ae141e6354 GitTreeState:clean BuildDate:2020-06-26T02:56:04Z GoVersion:go1.14.4 Compiler:gc Platform:darwin/amd64} 
DEBU[0000] config version "skaffold/v1" out of date: upgrading to latest "skaffold/v2beta5" 
DEBU[0000] found config for context "gke_engineering-devops_us-east1-c_eng-shared" 
INFO[0000] applying profile: small                      
DEBU[0000] overlaying profile on config for field Build 
DEBU[0000] overlaying profile on config for field artifacts 
DEBU[0000] overlaying profile on config for field insecureRegistries 
DEBU[0000] overlaying profile on config for field tagPolicy 
DEBU[0000] overlaying profile on config for field BuildType 
INFO[0000] no values found in profile for field BuildType, using original config values 
DEBU[0000] overlaying profile on config for field Test  
DEBU[0000] overlaying profile on config for field Deploy 
DEBU[0000] overlaying profile on config for field DeployType 
DEBU[0000] overlaying profile on config for field helm  
DEBU[0000] overlaying profile on config for field kubectl 
DEBU[0000] overlaying profile on config for field kustomize 
DEBU[0000] overlaying profile on config for field statusCheckDeadlineSeconds 
DEBU[0000] overlaying profile on config for field kubeContext 
DEBU[0000] overlaying profile on config for field PortForward 
DEBU[0000] Defaulting build type to local build         
DEBU[0000] validating yamltags of struct SkaffoldConfig 
DEBU[0000] validating yamltags of struct Metadata       
DEBU[0000] validating yamltags of struct Pipeline       
DEBU[0000] validating yamltags of struct BuildConfig    
DEBU[0000] validating yamltags of struct Artifact       
DEBU[0000] validating yamltags of struct ArtifactType   
DEBU[0000] validating yamltags of struct DockerArtifact 
DEBU[0000] validating yamltags of struct Artifact       
DEBU[0000] validating yamltags of struct ArtifactType   
DEBU[0000] validating yamltags of struct DockerArtifact 
DEBU[0000] validating yamltags of struct Artifact       
DEBU[0000] validating yamltags of struct ArtifactType   
DEBU[0000] validating yamltags of struct DockerArtifact 
DEBU[0000] validating yamltags of struct Artifact       
DEBU[0000] validating yamltags of struct ArtifactType   
DEBU[0000] validating yamltags of struct DockerArtifact 
DEBU[0000] validating yamltags of struct Artifact       
DEBU[0000] validating yamltags of struct ArtifactType   
DEBU[0000] validating yamltags of struct DockerArtifact 
DEBU[0000] validating yamltags of struct Artifact       
DEBU[0000] validating yamltags of struct ArtifactType   
DEBU[0000] validating yamltags of struct DockerArtifact 
DEBU[0000] validating yamltags of struct Artifact       
DEBU[0000] validating yamltags of struct ArtifactType   
DEBU[0000] validating yamltags of struct DockerArtifact 
DEBU[0000] validating yamltags of struct Artifact       
DEBU[0000] validating yamltags of struct ArtifactType   
DEBU[0000] validating yamltags of struct DockerArtifact 
DEBU[0000] validating yamltags of struct TagPolicy      
DEBU[0000] validating yamltags of struct ShaTagger      
DEBU[0000] validating yamltags of struct BuildType      
DEBU[0000] validating yamltags of struct LocalBuild     
DEBU[0000] validating yamltags of struct DeployConfig   
DEBU[0000] validating yamltags of struct DeployType     
DEBU[0000] validating yamltags of struct KustomizeDeploy 
DEBU[0000] validating yamltags of struct KubectlFlags   
INFO[0000] Using kubectl context: gke_engineering-devops_us-east1-c_eng-shared 
DEBU[0000] Using builder: local                         
DEBU[0000] setting Docker user agent to skaffold-v1.12.0 
DEBU[0000] push value not present, defaulting to true because localCluster is false 
Listing files to watch...
 - am
DEBU[0000] Found dependencies for dockerfile: [{config /home/forgerock/openam/config true} {logback.xml /usr/local/tomcat/webapps/am/WEB-INF/classes false} {custom-entrypoint.sh /home/forgerock false}] 
 - amster
DEBU[0000] Found dependencies for dockerfile: [{. /opt/amster false}] 
 - idm
DEBU[0000] Found dependencies for dockerfile: [{. /opt/openidm false}] 
 - ds-cts
DEBU[0000] Found dependencies for dockerfile: [{cts /opt/opendj true} {scripts /opt/opendj/scripts false}] 
 - ds-idrepo
DEBU[0000] Found dependencies for dockerfile: [{idrepo /opt/opendj true} {scripts /opt/opendj/scripts false}] 
 - forgeops-secrets
DEBU[0000] Found dependencies for dockerfile: [{forgeops-secrets-image /opt/gen true}] 
 - ig
DEBU[0000] Found dependencies for dockerfile: [{. /var/ig false}] 
 - ldif-importer
DEBU[0000] Found dependencies for dockerfile: [{start.sh /opt/opendj false} {ds-passwords.sh /opt/opendj false} {external-am-datastore.ldif /opt/opendj false}] 
DEBU[0000] could not stat dependency: stat kustomize/overlay/7.0/small/#Patch AM
apiVersion: apps/v1
kind: Deployment
metadata:
  name: am
spec:
  replicas: 1
  template:
    spec:
      containers:
      - name: openam
        imagePullPolicy: Always
        resources:
          limits:
            memory: 4Gi
          requests:
            cpu: 2000m
            memory: 4Gi: no such file or directory 
DEBU[0000] could not stat dependency: stat kustomize/overlay/7.0/small/#Patch DS CTS
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: ds-cts
spec:
  replicas: 3
  template:
    spec:
      containers:
        - name: ds
          resources:
            requests:
              memory: 3Gi
              cpu: 2000m
            limits:
              memory: 5Gi
      nodeSelector:
        forgerock.io/role: ds
  volumeClaimTemplates:
  - metadata:
      name: data
      annotations:
        pv.beta.kubernetes.io/gid: "0"
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 100Gi
      storageClassName: fast: no such file or directory 
DEBU[0000] could not stat dependency: stat kustomize/overlay/7.0/small/#Patch DS idrepo
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: ds-idrepo
spec:
  replicas: 3
  template:
    spec:
      containers:
        - name: ds
          resources:
            requests:
              memory: 4Gi
              cpu: 1500m
            limits:
              memory: 6Gi
      nodeSelector:
        forgerock.io/role: ds
  volumeClaimTemplates:
  - metadata:
      name: data
      annotations:
        pv.beta.kubernetes.io/gid: "0"
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 100Gi
      storageClassName: fast
      : no such file or directory 
DEBU[0000] could not stat dependency: stat kustomize/overlay/7.0/small/#Patch IDM
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: idm
spec:
  replicas: 1
  template:
    spec:
      containers:
      - name: openidm
        imagePullPolicy: Always
        resources:
          limits:
            memory: 2Gi
          requests:
            cpu: 1500m
            memory: 2Gi: no such file or directory 
watching files for deployer: unable to stat file "kustomize/overlay/7.0/small/apiVersion: v1\nkind: ConfigMap\nmetadata:\n  name: platform-config\ndata:\n  # Some optional settings\n  # Set the FQDN - includes the namespace prefix!\n  # FQDN: prod.pit-test.forgeops.com\n  # If you are using cert-manager and Let's Encrypt in your cluster and want real certs - set this\n  # CERT_ISSUER: letsencrypt-prod\n  AM_STORES_CTS_SERVERS: \"ds-cts-0.ds-cts:1389,ds-cts-1.ds-cts:1389,ds-cts-2.ds-cts:1389\"\n  AM_STORES_USER_SERVERS: \"ds-idrepo-0.ds-idrepo:1389,ds-idrepo-1.ds-idrepo:1389,ds-idrepo-2.ds-idrepo:1389\"": stat kustomize/overlay/7.0/small/apiVersion: v1
kind: ConfigMap
metadata:
  name: platform-config
data:
  # Some optional settings
  # Set the FQDN - includes the namespace prefix!
  # FQDN: prod.pit-test.forgeops.com
  # If you are using cert-manager and Let's Encrypt in your cluster and want real certs - set this
  # CERT_ISSUER: letsencrypt-prod
  AM_STORES_CTS_SERVERS: "ds-cts-0.ds-cts:1389,ds-cts-1.ds-cts:1389,ds-cts-2.ds-cts:1389"
  AM_STORES_USER_SERVERS: "ds-idrepo-0.ds-idrepo:1389,ds-idrepo-1.ds-idrepo:1389,ds-idrepo-2.ds-idrepo:1389": file name too long```
wstrange commented 4 years ago

skaffold run works fine, so this issue appears to be related to skaffold dev functionality and the way it constructs kustomize file watchers.

briandealwis commented 4 years ago

Ah, according to the docs, kustomization.yaml's patchesStrategicMerge must be a list of files:

Name Type Desc
patchesStrategicMerge []string Paths to files containing sparse Resource Config.

You can't inline text unfortunately.

lee-baines commented 4 years ago

Ok thanks, that explains why it thinks its a file name. Thanks for your help

dgageot commented 4 years ago

inline texts are supported by Kustomize. Not by Skaffold. I'm going to work on a patch

briandealwis commented 4 years ago

@dgageot's sleuthing revealed that kustomize added support for inline patches in v3.2.0.

wstrange commented 4 years ago

Thanks for the quick turn around!

lee-baines commented 4 years ago

Yes thanks for sorting this

tejal29 commented 4 years ago

Welcome!