Skip to content
Merged
Show file tree
Hide file tree
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
33 changes: 20 additions & 13 deletions pkg/controller/template/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,18 @@ func GenerateMachineConfigsForRole(config *RenderConfig, role, templateDir strin
}

cfgs := []*mcfgv1.MachineConfig{}
// This func doesn't process "common"
// common templates are only added to 00-<role>
// templates/<role>/{00-<role>,01-<role>-container-runtime,01-<role>-kubelet}
var commonAdded bool
for _, info := range infos {
if !info.IsDir() {
glog.Infof("ignoring non-directory path %q", info.Name())
continue
}
name := info.Name()
namePath := filepath.Join(path, name)
nameConfig, err := generateMachineConfigForName(config, role, name, templateDir, namePath)
nameConfig, err := generateMachineConfigForName(config, role, name, templateDir, namePath, &commonAdded)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -171,26 +175,29 @@ func filterTemplates(toFilter map[string]string, path string, config *RenderConf
return filepath.Walk(path, walkFn)
}

func generateMachineConfigForName(config *RenderConfig, role, name, templateDir, path string) (*mcfgv1.MachineConfig, error) {
func generateMachineConfigForName(config *RenderConfig, role, name, templateDir, path string, commonAdded *bool) (*mcfgv1.MachineConfig, error) {
platform, err := platformFromControllerConfigSpec(config.ControllerConfigSpec)
if err != nil {
return nil, err
}

platformDirs := []string{}
// Loop over templates/common which applies everywhere
for _, dir := range []string{platformBase, platform} {
basePath := filepath.Join(templateDir, "common", dir)
exists, err := existsDir(basePath)
if err != nil {
return nil, err
}
if !exists {
continue
if !*commonAdded {
// Loop over templates/common which applies everywhere
for _, dir := range []string{platformBase, platform} {
basePath := filepath.Join(templateDir, "common", dir)
exists, err := existsDir(basePath)
if err != nil {
return nil, err
}
if !exists {
continue
}
platformDirs = append(platformDirs, basePath)
}
platformDirs = append(platformDirs, basePath)
*commonAdded = true
}
// And now over the target e.g. templates/master
// And now over the target e.g. templates/master/00-master,01-master-container-runtime,01-master-kubelet
for _, dir := range []string{platformBase, platform} {
platformPath := filepath.Join(path, dir)
exists, err := existsDir(platformPath)
Expand Down
3 changes: 0 additions & 3 deletions pkg/controller/template/template_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,6 @@ func (ctrl *Controller) syncControllerConfig(key string) error {
if err := ctrl.syncRunningStatus(cfg); err != nil {
return err
}
} else {
glog.V(2).Info("ControllerConfig didn't change, skipping templates sync")
return nil
}

var pullSecretRaw []byte
Expand Down