Skip to content

Commit

Permalink
Prevent admin templates from instantiating on older versions
Browse files Browse the repository at this point in the history
  • Loading branch information
csrwng committed May 25, 2017
1 parent 0bea328 commit 1342989
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
19 changes: 13 additions & 6 deletions pkg/bootstrap/docker/openshift/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ type Helper struct {
containerName string
routingSuffix string
serverIP string
version *semver.Version
}

// StartOptions represent the parameters sent to the start command
Expand Down Expand Up @@ -615,7 +616,10 @@ func GetConfigFromContainer(client *docker.Client) (*configapi.MasterConfig, err
return config, nil
}

func (h *Helper) serverVersion() (semver.Version, error) {
func (h *Helper) ServerVersion() (semver.Version, error) {
if h.version != nil {
return *h.version, nil
}
versionText, _, _, err := h.runHelper.New().Image(h.image).
Command("version").
DiscardContainer().
Expand All @@ -632,13 +636,16 @@ func (h *Helper) serverVersion() (semver.Version, error) {
break
}
}
return semver.Parse(versionStr)
version, err := semver.Parse(versionStr)
if err == nil {
// ignore pre-release portion
version.Pre = []semver.PRVersion{}
h.version = &version
}
return version, err
}

func useDNSIP(version semver.Version) bool {
// Ignore pre-release portion
version.Pre = []semver.PRVersion{}

if version.Major == 1 {
return version.GTE(version15)
}
Expand Down Expand Up @@ -720,7 +727,7 @@ func (h *Helper) updateConfig(configDir string, opt *StartOptions) error {
if err != nil {
return err
}
version, err := h.serverVersion()
version, err := h.ServerVersion()
if err != nil {
return err
}
Expand Down
15 changes: 14 additions & 1 deletion pkg/bootstrap/docker/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ var (
"heapster standalone": "examples/heapster/heapster-standalone.yaml",
}
dockerVersion112 = semver.MustParse("1.12.0")

openshiftVersion36 = semver.MustParse("3.6.0")
)

// NewCmdUp creates a command that starts openshift on Docker with reasonable defaults
Expand Down Expand Up @@ -917,7 +919,18 @@ func (c *ClientStartConfig) ImportTemplates(out io.Writer) error {
if err := c.importObjects(out, openshiftNamespace, templateLocations); err != nil {
return err
}
return c.importObjects(out, "kube-system", adminTemplateLocations)
version, err := c.OpenShiftHelper().ServerVersion()
if err != nil {
return err
}
if shouldImportAdminTemplates(version) {
return c.importObjects(out, "kube-system", adminTemplateLocations)
}
return nil
}

func shouldImportAdminTemplates(v semver.Version) bool {
return v.GTE(openshiftVersion36)
}

// InstallLogging will start the installation of logging components
Expand Down

0 comments on commit 1342989

Please sign in to comment.