{"record":{"id":"a2cf8043fde24020","repo":"hashicorp/nomad","slug":"failed-to-build-mount-for-resolv-conf-v-a2cf80","errorCode":null,"errorMessage":"failed to build mount for resolv.conf: %v","messagePattern":"failed to build mount for resolv\\.conf: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/java/driver.go","lineNumber":478,"sourceCode":"\thandle.Config = cfg\n\n\tpluginLogFile := filepath.Join(cfg.TaskDir().Dir, \"executor.out\")\n\texecutorConfig := &executor.ExecutorConfig{\n\t\tLogFile:     pluginLogFile,\n\t\tLogLevel:    \"debug\",\n\t\tFSIsolation: driverCapabilities.FSIsolation == fsisolation.Chroot,\n\t\tCompute:     d.nomadConfig.Topology.Compute(),\n\t}\n\n\tuser := cfg.User\n\tif user == \"\" && runtime.GOOS != \"windows\" {\n\t\tuser = \"nobody\"\n\t}\n\n\tif cfg.DNS != nil {\n\t\tdnsMount, err := resolvconf.GenerateDNSMount(cfg.TaskDir().Dir, cfg.DNS)\n\t\tif err != nil {\n\t\t\treturn nil, nil, fmt.Errorf(\"failed to build mount for resolv.conf: %v\", err)\n\t\t}\n\t\tcfg.Mounts = append(cfg.Mounts, dnsMount)\n\t}\n\n\tcaps, err := capabilities.Calculate(\n\t\tcapabilities.NomadDefaults(), d.config.AllowCaps, driverConfig.CapAdd, driverConfig.CapDrop,\n\t)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\td.logger.Debug(\"task capabilities\", \"capabilities\", caps)\n\n\texec, pluginClient, err := executor.CreateExecutor(\n\t\td.logger.With(\"task_name\", handle.Config.Name, \"alloc_id\", handle.Config.AllocID),\n\t\td.nomadConfig, executorConfig)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to create executor: %v\", err)\n\t}","sourceCodeStart":460,"sourceCodeEnd":496,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/java/driver.go#L460-L496","documentation":"When the task specifies DNS configuration, StartTask asks resolvconf.GenerateDNSMount to build a resolv.conf mount for the task directory. If that fails (typically inability to write the generated resolv.conf into the task dir, or an invalid DNS config), the driver wraps the error with this message. This happens before the executor is launched.","triggerScenarios":"Calling StartTask with cfg.DNS set while GenerateDNSMount fails — e.g. the task directory doesn't exist or isn't writable, the DNS stanza contains no/invalid servers, or the underlying file write for the mount fails.","commonSituations":"Job 'dns' blocks with malformed 'servers'/'options' lists; task dir not yet created or permission problems (running as 'nobody'); client filesystem full or read-only; DNS blocks combined with drivers/fsisolation setups that don't expect mounts.","solutions":["Check the task's dns stanza in the job file: servers, searches, options must be valid non-empty values.","Verify the task directory exists and is writable by the Nomad client / task user.","Check client disk space and permissions on the alloc dir.","Remove or correct the dns block if the driver/task doesn't need custom DNS, then retry the allocation."],"exampleFix":"// before\n  dns {\n    servers = [\"  \"]\n  }\n// after\n  dns {\n    servers = [\"1.1.1.1\", \"8.8.8.8\"]\n  }","handlingStrategy":"validation","validationCode":"// validate dns stanza and task dir writability before StartTask\nif cfg.DNS != nil {\n    if len(cfg.DNS.Servers) == 0 {\n        return errors.New(\"dns block present but no servers configured\")\n    }\n    if err := os.MkdirAll(cfg.TaskDir().Dir, 0o755); err != nil {\n        return fmt.Errorf(\"task dir not usable for resolv.conf mount: %w\", err)\n    }\n}","typeGuard":null,"tryCatchPattern":"_, _, err := driver.StartTask(cfg)\nif err != nil && strings.Contains(err.Error(), \"failed to build mount for resolv.conf\") {\n    // drop or fix the dns block and resubmit\n    return fmt.Errorf(\"check job dns stanza and task dir permissions: %w\", err)\n}","preventionTips":["Keep dns blocks minimal and valid (servers as IP strings).","Ensure alloc/task dirs exist and are writable by the client and task user.","Monitor client disk space; full disks break generated mount files.","Test dns blocks on a dev client before production rollout."],"tags":["nomad","java-driver","dns","filesystem"],"backgroundTag":"dns-config-mount-failed","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}