Skip to content

fix: inlude symlinks in scanning for init scripts - #11077

Merged
lidel merged 1 commit into
ipfs:masterfrom
ESA-PhiLab:fr/include-symlinks-20251125
Nov 26, 2025
Merged

lidel merged 1 commit into
ipfs:masterfrom
ESA-PhiLab:fr/include-symlinks-20251125

Conversation

@filipremb

Copy link
Copy Markdown
Contributor

When the /container-init.d directory is mounted from a ConfigMap in k8s, the file type of init script could be a symbolic link not a regular file.

Steps to reproduce:

Create init file

mkdir ipfs-container-init-d
echo "ipfs config Routing.Type dhtserver" > ipfs-container-init-d/01_init.sh

Create this kustomization.yaml file:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
configMapGenerator:
- name: ipfs-container-init-d
  files:
    - ipfs-container-init-d/01_init.sh
resources:
- k8s.yaml

Create a StatefulSet with the secret volume mount:

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: ipfs
spec:
  selector:
    matchLabels:
      app: ipfs
  replicas: 1
  template:
    metadata:
      labels:
        app: ipfs
    spec:
      containers:
      - name: kubo
        image: ipfs/kubo:v0.38.2  # https://github.com/ipfs/kubo/releases/tag/v0.38.2
        ports:
        - containerPort: 4001
          protocol: TCP
        - containerPort: 4001
          protocol: UDP
        - containerPort: 5001
        - containerPort: 8080
        volumeMounts:
        - name: ipfs-container-init-d
          mountPath: /container-init.d
      volumes:
      - name: ipfs-container-init-d
        configMap:
          name: ipfs-container-init-d

Apply with kubectl apply -k .

Using kubectl logs observe the init script is NOT loaded unless this fix is applied.

When the `/container-init.d` directory is mounted from a secret in k8s, the file type could be a symbolic link not a regular file.

Steps to reproduce:

Create init file

```bash
mkdir ipfs-container-init-d
echo "ipfs config Routing.Type dhtserver" > ipfs-container-init-d/01_init.sh
```

Create this kustomization.yaml file:

```yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
configMapGenerator:
- name: ipfs-container-init-d
  files:
    - ipfs-container-init-d/01_init.sh
resources:
- k8s.yaml
```

Create a StatefulSet with the secret volume mount:

```yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: ipfs
spec:
  selector:
    matchLabels:
      app: ipfs
  replicas: 1
  template:
    metadata:
      labels:
        app: ipfs
    spec:
      containers:
      - name: kubo
        image: ipfs/kubo:v0.38.2  # https://github.com/ipfs/kubo/releases/tag/v0.38.2
        ports:
        - containerPort: 4001
          protocol: TCP
        - containerPort: 4001
          protocol: UDP
        - containerPort: 5001
        - containerPort: 8080
        volumeMounts:
        - name: ipfs-container-init-d
          mountPath: /container-init.d
      volumes:
      - name: ipfs-container-init-d
        configMap:
          name: ipfs-container-init-d
```

Apply with `kubectl apply -k .`

Using `kubectl logs` observe the init script is NOT loaded unless this fix is applied.
@filipremb
filipremb requested a review from a team as a code owner November 25, 2025 22:30
@lidel lidel mentioned this pull request Nov 26, 2025
50 of 74 tasks

@lidel lidel left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good catch, thank you! We will include this in 0.39

Note to self: this option is preferable to -follow because it fails with an error when encountering broken symlinks, whereas -follow silently skips them without notification.

@lidel
lidel merged commit 72f4c6f into ipfs:master Nov 26, 2025
lidel pushed a commit that referenced this pull request Nov 26, 2025
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.

2 participants