kubernetes/kops · error
error loading config file: %v
Error message
error loading config file: %v
What it means
OpenstackConfig.getSection loads the INI config file resolved by filename() using go-ini's ini.Load. If the file cannot be read or parsed (missing, unreadable permissions, malformed INI), the error is wrapped as 'error loading config file'.
Source
Thrown at util/pkg/vfs/swiftfs.go:125
}
homeDir := homedir.HomeDir()
if homeDir == "" {
return "", fmt.Errorf("can not find home directory")
}
f := filepath.Join(homeDir, ".openstack", "config")
klog.V(2).Infof("using openstack config found in %s", f)
return f, nil
}
func (oc OpenstackConfig) getSection(name string, items []string) (map[string]string, error) {
filename, err := oc.filename()
if err != nil {
return nil, err
}
config, err := ini.Load(filename)
if err != nil {
return nil, fmt.Errorf("error loading config file: %v", err)
}
section, err := config.GetSection(name)
if err != nil {
return nil, fmt.Errorf("error getting section of %s: %v", name, err)
}
values := make(map[string]string)
for _, item := range items {
values[item] = section.Key(item).String()
}
return values, nil
}
func (oc OpenstackConfig) GetCredential() (gophercloud.AuthOptions, error) {
// prioritize environment config
env, enverr := openstack.AuthOptionsFromEnv()
if enverr != nil {
klog.Warningf("Could not initialize OpenStack config from environment: %v", enverr)
// fallback to config fileView on GitHub (pinned to 4c8573c808)
Solutions
- Verify the resolved path exists and is readable: ls -l $(echo $OPENSTACK_CREDENTIAL_FILE || echo ~/.openstack/config).
- Ensure the file is valid INI with [section] headers and key = value lines.
- Fix file permissions so the kops process user can read it.
- Check the wrapped %v cause for parse errors and fix the offending line.
Example fix
// before (malformed INI) Global region RegionOne // after [Global] region = RegionOne
Defensive patterns
Strategy: validation
Validate before calling
// Pre-validate the INI file parses before invoking the library
if _, err := ini.Load(configPath); err != nil {
return fmt.Errorf("openstack config %s is not valid INI: %w", configPath, err)
} Prevention
- Keep the file in strict INI format ([section], key = value)
- Fix permissions after copying (readable by the kops user)
- Don't write YAML/JSON into OPENSTACK_CREDENTIAL_FILE
- Lint the config with `openstack --os-cloud` tooling when available
When it happens
Trigger: GetRegion, GetServiceConfig, or getCredentialFromFile -> getSection when the config path (from OPENSTACK_CREDENTIAL_FILE or ~/.openstack/config) does not exist, has wrong permissions, or contains invalid INI syntax.
Common situations: OPENSTACK_CREDENTIAL_FILE pointing to a nonexistent path, config file with YAML/JSON content instead of INI, duplicate/broken keys, or a permissions issue after copying with root ownership.
Related errors
- error getting section of %s: %v
- missing %s in section of %s
- did not find floatingsubnet for external router
- did not find floatingsubnet for LB
- Failed to find external network: %v
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/507664acc3764bf1.
Report an issue: GitHub.