mirrord: File system mapping doesn't apply

Bug Description

I struggled with different mappings by feature.fs.mapping to see it in action but it don’t take effect.

According to documentation:

“mapping” - Map of patterns and their corresponding replacers. The replacement happens before any specific behavior as defined above or mode (uses Regex::replace)

And in other hand:

Check agains “mapping” if path needs to be replaced, if matched then continue to next step with new path after replacements otherwise continue as usual.

An example is provided by documentation too:

{ "^/home/(?<user>\\S+)/dev/tomcat": "/etc/tomcat" "^/home/(?<user>\\S+)/dev/config/(?<app>\\S+)": "/mnt/configs/${user}-$app" } Will do the next replacements for any io operaton /home/johndoe/dev/tomcat/context.xml => /etc/tomcat/context.xml

Steps to Reproduce

  1. Here is my code:

  console.log('I am here')
  const child = spawn('cat', ['/home/johndoe/dev/tomcat/context.xml'])
  child.on('error', (err) => {
    console.log(err)
  })
  child.stderr.on('data', (chunk) => {
    console.log('stderr:', chunk)
  })
  child.stdout.on('data', (chunk) => {
    console.warn('stdout:', chunk)
  })
  1. And here is output which indicates there is no replacement:
stderr:
cat: /home/johndoe/dev/tomcat/context.xml: No such file or directory

Backtrace

No response

mirrord layer logs

No response

mirrord intproxy logs

No response

mirrord agent logs

No response

mirrord config

{
  "target": {
    "path": {
      "deployment": "my-pod"
    },
    "namespace": "services"
  },
  "feature": {
    "env": {
      "override": {
        "CATEGORY_ID": "1",
      }
    },
    "fs": {
      "mode": "write",
      "mapping": {
        "^/home/(?<user>\\S+)/dev/tomcat": "/etc/tomcat",
        "^/home/(?<user>\\S+)/dev/config/(?<app>\\S+)": "/mnt/configs/${user}-$app"
      }
    },
    "network": true
  },
  "agent": {
    "namespace": "services",
    "startup_timeout": 360
  },
  "kubeconfig": "~/.kube/test",
  "kube_context": "test"
}

mirrord CLI version

No response

mirrord-agent version

No response

mirrord-operator version (if relevant)

No response

plugin kind and version (if relevant)

No response

Your operating system and version

6.1.111-1-MANJARO

Local process

/usr/bin/cat: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=f279ce1a7add04b3f8b3f16e4fb89ecbc5d88dfb, for GNU/Linux 4.4.0, stripped

Local process version

ls (GNU coreutils) 9.5

Additional Info

Please let me know if any other information is required. No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (10 by maintainers)

Most upvoted comments

BTW regarding relative mapping - that’s not supported - that’s a known issue that we haven’t prioritised yet. (in general, we don’t apply any fs logic to relative paths, since it’s trickier than absolute paths.)

Thank you! I’ve prioritized it - will update once we get working on it.

No - the path replacement happens in the libc level, meaning that your application won’t even know that the path was replaced - hence it’d think it actually read from the original path.