Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nodeinstaller: compare with the template file content #1186

Merged
merged 1 commit into from
Jan 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion nodeinstaller/node-installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ func patchContainerdConfig(runtimeHandler, basePath, configPath string, platform
func parseExistingContainerdConfig(path string) ([]byte, config.ContainerdConfig, error) {
// Read the rendered config instead of the template, as we can't parse the template.
// We then write the rendered config to the template path later.
configData, err := os.ReadFile(strings.TrimSuffix(path, ".tmpl"))
renderedPath, isRendered := strings.CutSuffix(path, ".tmpl")
configData, err := os.ReadFile(renderedPath)
if err != nil {
return nil, config.ContainerdConfig{}, err
}
Expand All @@ -266,6 +267,17 @@ func parseExistingContainerdConfig(path string) ([]byte, config.ContainerdConfig
return nil, config.ContainerdConfig{}, err
}

if !isRendered {
return configData, cfg, nil
}

// We return the raw file content so that the caller can decide whether to overwrite. Since
// they are overwriting the template file and not the rendered file, we need to return the
// template file here.
configData, err = os.ReadFile(path)
if err != nil {
return nil, config.ContainerdConfig{}, fmt.Errorf("reading containerd config template %s: %w", path, err)
}
return configData, cfg, nil
}

Expand Down