Skip to content

Commit

Permalink
up: remove logDir argument
Browse files Browse the repository at this point in the history
  • Loading branch information
mfojtik committed May 9, 2018
1 parent 8742eeb commit 7aa2aea
Show file tree
Hide file tree
Showing 20 changed files with 39 additions and 100 deletions.
2 changes: 1 addition & 1 deletion pkg/oc/bootstrap/clusteradd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (c *ClusterAddConfig) Run() error {
component := availableComponents[componentName](installContext)
componentsToInstall = append(componentsToInstall, component)
}
return componentinstall.InstallComponents(componentsToInstall, c.dockerClient, c.GetLogDir())
return componentinstall.InstallComponents(componentsToInstall, c.dockerClient)
}

type ClusterAddConfig struct {
Expand Down
5 changes: 3 additions & 2 deletions pkg/oc/bootstrap/clusteradd/componentinstall/apply_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package componentinstall
import (
"io/ioutil"
"path"
"path/filepath"
"time"

"github.com/golang/glog"
Expand Down Expand Up @@ -56,7 +57,7 @@ func (opt *installReadyList) Name() string {
return opt.list.Name
}

func (opt *installReadyList) Install(dockerClient dockerhelper.Interface, logdir string) error {
func (opt *installReadyList) Install(dockerClient dockerhelper.Interface) error {
imageRunHelper := run.NewRunHelper(dockerhelper.NewHelper(dockerClient)).New()

clusterAdminConfigBytes, err := ioutil.ReadFile(path.Join(opt.baseDir, kubeapiserver.KubeAPIServerDirName, "admin.kubeconfig"))
Expand All @@ -83,7 +84,7 @@ func (opt *installReadyList) Install(dockerClient dockerhelper.Interface, logdir
HostNetwork().
HostPid().
Entrypoint("sh").
SaveContainerLogs(opt.Name(), logdir).
SaveContainerLogs(opt.Name(), filepath.Join(opt.baseDir, "logs")).
Command("-c", "chmod 755 /apply.sh && /apply.sh").Run()
if err != nil {
lastErr = errors.NewError("failed to install %q: %v", opt.Name(), err).WithCause(err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"io/ioutil"
"path"
"path/filepath"
"time"

"github.com/golang/glog"
Expand Down Expand Up @@ -76,7 +77,7 @@ func (opt installReadyTemplate) Name() string {
return opt.template.Name
}

func (opt installReadyTemplate) Install(dockerClient dockerhelper.Interface, logdir string) error {
func (opt installReadyTemplate) Install(dockerClient dockerhelper.Interface) error {
imageRunHelper := run.NewRunHelper(dockerhelper.NewHelper(dockerClient)).New()

glog.Infof("Installing %q\n", opt.Name())
Expand Down Expand Up @@ -104,7 +105,7 @@ func (opt installReadyTemplate) Install(dockerClient dockerhelper.Interface, log
Privileged().
DiscardContainer().
Copy(contentToCopy).
SaveContainerLogs(opt.Name(), logdir).
SaveContainerLogs(opt.Name(), filepath.Join(opt.baseDir, "logs")).
HostNetwork().
HostPid().
Entrypoint("sh").
Expand Down
6 changes: 3 additions & 3 deletions pkg/oc/bootstrap/clusteradd/componentinstall/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (

type Component interface {
Name() string
Install(dockerClient dockerhelper.Interface, logdir string) error
Install(dockerClient dockerhelper.Interface) error
}

func InstallComponents(components []Component, dockerClient dockerhelper.Interface, logdir string) error {
func InstallComponents(components []Component, dockerClient dockerhelper.Interface) error {
componentNames := []string{}
errorCh := make(chan error, len(components))
waitGroupOne := sync.WaitGroup{}
Expand All @@ -29,7 +29,7 @@ func InstallComponents(components []Component, dockerClient dockerhelper.Interfa
go func() {
defer waitGroupOne.Done()

err := component.Install(dockerClient, logdir)
err := component.Install(dockerClient)
if err != nil {
glog.Errorf("Failed to install %q: %v", component.Name(), err)
errorCh <- err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ type Components []Component
func (c Components) Name() string {
return "union"
}
func (c Components) Install(dockerClient dockerhelper.Interface, logdir string) error {
return InstallComponents(c, dockerClient, logdir)
func (c Components) Install(dockerClient dockerhelper.Interface) error {
return InstallComponents(c, dockerClient)
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (c *RHELImageStreamsComponentOptions) Name() string {
return "rhel-imagestreams"
}

func (c *RHELImageStreamsComponentOptions) Install(dockerClient dockerhelper.Interface, logdir string) error {
func (c *RHELImageStreamsComponentOptions) Install(dockerClient dockerhelper.Interface) error {
component := componentinstall.List{
Name: c.Name(),
Namespace: "openshift",
Expand All @@ -28,7 +28,7 @@ func (c *RHELImageStreamsComponentOptions) Install(dockerClient dockerhelper.Int

return component.MakeReady(
c.InstallContext.ClientImage(),
c.InstallContext.BaseDir()).Install(dockerClient, logdir)
c.InstallContext.BaseDir()).Install(dockerClient)
}

type CentosImageStreamsComponentOptions struct {
Expand All @@ -39,7 +39,7 @@ func (c *CentosImageStreamsComponentOptions) Name() string {
return "centos-imagestreams"
}

func (c *CentosImageStreamsComponentOptions) Install(dockerClient dockerhelper.Interface, logdir string) error {
func (c *CentosImageStreamsComponentOptions) Install(dockerClient dockerhelper.Interface) error {
component := componentinstall.List{
Name: c.Name(),
Namespace: "openshift",
Expand All @@ -48,5 +48,5 @@ func (c *CentosImageStreamsComponentOptions) Install(dockerClient dockerhelper.I

return component.MakeReady(
c.InstallContext.ClientImage(),
c.InstallContext.BaseDir()).Install(dockerClient, logdir)
c.InstallContext.BaseDir()).Install(dockerClient)
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const (

// TODO this should be a controller based on the actual cluster state
// RegisterTemplateServiceBroker registers the TSB with the SC by creating the broker resource
func RegisterTemplateServiceBroker(dockerClient dockerhelper.Interface, ocImage, baseDir, configDir, logDir string) error {
func RegisterTemplateServiceBroker(dockerClient dockerhelper.Interface, ocImage, baseDir, configDir string) error {
// Register the template broker with the service catalog
glog.V(2).Infof("registering the template broker with the service catalog")

Expand All @@ -41,6 +41,6 @@ func RegisterTemplateServiceBroker(dockerClient dockerhelper.Interface, ocImage,
return component.MakeReady(
ocImage,
baseDir,
params).Install(dockerClient, logDir)
params).Install(dockerClient)

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"os"
"path"
"path/filepath"

"github.com/golang/glog"

Expand Down Expand Up @@ -52,7 +53,7 @@ func (r *RegistryComponentOptions) ensureRemoteRegistryStoragePermissions(dir st
return err
}

func (r *RegistryComponentOptions) Install(dockerClient dockerhelper.Interface, logdir string) error {
func (r *RegistryComponentOptions) Install(dockerClient dockerhelper.Interface) error {
kubeAdminClient, err := kubernetes.NewForConfig(r.InstallContext.ClusterAdminClientConfig())
if err != nil {
return err
Expand Down Expand Up @@ -103,7 +104,7 @@ func (r *RegistryComponentOptions) Install(dockerClient dockerhelper.Interface,
DiscardContainer().
HostNetwork().
HostPid().
SaveContainerLogs(r.Name(), logdir).
SaveContainerLogs(r.Name(), filepath.Join(r.InstallContext.BaseDir(), "logs")).
Bind(masterConfigDir + ":" + masterConfigDir).
Entrypoint("oc").
Command(flags...).Run()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (c *RouterComponentOptions) Name() string {
return "openshift-router"
}

func (c *RouterComponentOptions) Install(dockerClient dockerhelper.Interface, logdir string) error {
func (c *RouterComponentOptions) Install(dockerClient dockerhelper.Interface) error {
kubeAdminClient, err := kclientset.NewForConfig(c.InstallContext.ClusterAdminClientConfig())
if err != nil {
return err
Expand Down Expand Up @@ -139,7 +139,7 @@ func (c *RouterComponentOptions) Install(dockerClient dockerhelper.Interface, lo
Privileged().
DiscardContainer().
HostNetwork().
SaveContainerLogs(componentName, logdir).
SaveContainerLogs(componentName, filepath.Join(c.InstallContext.BaseDir(), "logs")).
Bind(masterConfigDir + ":" + masterConfigDir).
Entrypoint("oc").
Command(flags...).Run()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (c *SampleTemplatesComponentOptions) Name() string {
return "sample-templates"
}

func (c *SampleTemplatesComponentOptions) Install(dockerClient dockerhelper.Interface, logdir string) error {
func (c *SampleTemplatesComponentOptions) Install(dockerClient dockerhelper.Interface) error {
componentsToInstall := componentinstall.Components{}
for name, location := range templateLocations {
componentsToInstall = append(componentsToInstall,
Expand All @@ -40,5 +40,5 @@ func (c *SampleTemplatesComponentOptions) Install(dockerClient dockerhelper.Inte
)
}

return componentsToInstall.Install(dockerClient, logdir)
return componentsToInstall.Install(dockerClient)
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (c *ServiceCatalogComponentOptions) Name() string {
return "openshift-service-catalog"
}

func (c *ServiceCatalogComponentOptions) Install(dockerClient dockerhelper.Interface, logdir string) error {
func (c *ServiceCatalogComponentOptions) Install(dockerClient dockerhelper.Interface) error {
kubeAdminClient, err := kubernetes.NewForConfig(c.InstallContext.ClusterAdminClientConfig())
if err != nil {
return err
Expand Down Expand Up @@ -118,7 +118,7 @@ func (c *ServiceCatalogComponentOptions) Install(dockerClient dockerhelper.Inter
err = component.MakeReady(
c.InstallContext.ClientImage(),
c.InstallContext.BaseDir(),
params).Install(dockerClient, logdir)
params).Install(dockerClient)

if err != nil {
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (c *TemplateServiceBrokerComponentOptions) Name() string {
return "openshift-template-service-broker"
}

func (c *TemplateServiceBrokerComponentOptions) Install(dockerClient dockerhelper.Interface, logdir string) error {
func (c *TemplateServiceBrokerComponentOptions) Install(dockerClient dockerhelper.Interface) error {
kubeAdminClient, err := kubernetes.NewForConfig(c.InstallContext.ClusterAdminClientConfig())
if err != nil {
return errors.NewError("cannot obtain API clients").WithCause(err)
Expand Down Expand Up @@ -71,7 +71,7 @@ func (c *TemplateServiceBrokerComponentOptions) Install(dockerClient dockerhelpe
err = component.MakeReady(
c.InstallContext.ClientImage(),
c.InstallContext.BaseDir(),
params).Install(dockerClient, logdir)
params).Install(dockerClient)

if err != nil {
return err
Expand All @@ -84,7 +84,6 @@ func (c *TemplateServiceBrokerComponentOptions) Install(dockerClient dockerhelpe
c.InstallContext.ImageFormat(),
c.InstallContext.BaseDir(),
masterConfigDir,
logdir,
)
return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (c *WebConsoleOperatorComponentOptions) Name() string {
return "openshift-web-console-operator"
}

func (c *WebConsoleOperatorComponentOptions) Install(dockerClient dockerhelper.Interface, logdir string) error {
func (c *WebConsoleOperatorComponentOptions) Install(dockerClient dockerhelper.Interface) error {
//kubeAdminClient, err := kubernetes.NewForConfig(c.InstallContext.ClusterAdminClientConfig())
//if err != nil {
// return errors.NewError("cannot obtain API clients").WithCause(err)
Expand Down Expand Up @@ -54,5 +54,5 @@ func (c *WebConsoleOperatorComponentOptions) Install(dockerClient dockerhelper.I
return component.MakeReady(
c.InstallContext.ClientImage(),
c.InstallContext.BaseDir(),
params).Install(dockerClient, logdir)
params).Install(dockerClient)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/url"
"path"

yaml "gopkg.in/yaml.v2"
"gopkg.in/yaml.v2"
"k8s.io/client-go/kubernetes"

"github.com/golang/glog"
Expand Down Expand Up @@ -36,7 +36,7 @@ func (c *WebConsoleComponentOptions) Name() string {
return "openshift-web-console"
}

func (c *WebConsoleComponentOptions) Install(dockerClient dockerhelper.Interface, logdir string) error {
func (c *WebConsoleComponentOptions) Install(dockerClient dockerhelper.Interface) error {
kubeAdminClient, err := kubernetes.NewForConfig(c.InstallContext.ClusterAdminClientConfig())
if err != nil {
return errors.NewError("cannot obtain API clients").WithCause(err)
Expand Down Expand Up @@ -105,7 +105,7 @@ func (c *WebConsoleComponentOptions) Install(dockerClient dockerhelper.Interface
return component.MakeReady(
c.InstallContext.ClientImage(),
c.InstallContext.BaseDir(),
params).Install(dockerClient, logdir)
params).Install(dockerClient)
}

func getMasterPublicHostPort(basedir string) (string, error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (c *SetupPersistentVolumesOptions) Name() string {
return "persistent-volumes"
}

func (c *SetupPersistentVolumesOptions) Install(dockerClient dockerhelper.Interface, logdir string) error {
func (c *SetupPersistentVolumesOptions) Install(dockerClient dockerhelper.Interface) error {
kclient, err := kubernetes.NewForConfig(c.InstallContext.ClusterAdminClientConfig())
if err != nil {
return err
Expand Down
7 changes: 2 additions & 5 deletions pkg/oc/bootstrap/docker/run_self_hosted.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ func (c *ClusterUpConfig) StartSelfHosted(out io.Writer) error {
c.BaseDir,
templateSubstitutionValues,
c.GetDockerClient(),
c.GetLogDir(),
)
if err != nil {
return err
Expand Down Expand Up @@ -221,7 +220,6 @@ func (c *ClusterUpConfig) StartSelfHosted(out io.Writer) error {
c.BaseDir,
templateSubstitutionValues,
c.GetDockerClient(),
c.GetLogDir(),
)
if err != nil {
return err
Expand Down Expand Up @@ -622,8 +620,7 @@ func newNamespaceBytes(namespace string, labels map[string]string) []byte {
return output
}

func installComponentTemplates(templates []componentInstallTemplate, imageFormat, baseDir string, params map[string]string, dockerClient dockerhelper.Interface,
logdir string) error {
func installComponentTemplates(templates []componentInstallTemplate, imageFormat, baseDir string, params map[string]string, dockerClient dockerhelper.Interface) error {
components := []componentinstall.Component{}
cliImage := strings.Replace(imageFormat, "${component}", "cli", -1)
for _, template := range templates {
Expand All @@ -638,5 +635,5 @@ func installComponentTemplates(templates []componentInstallTemplate, imageFormat
components = append(components, template.Template.MakeReady(cliImage, baseDir, paramsWithImage))
}

return componentinstall.InstallComponents(components, dockerClient, logdir)
return componentinstall.InstallComponents(components, dockerClient)
}
4 changes: 0 additions & 4 deletions pkg/oc/bootstrap/docker/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -1087,10 +1087,6 @@ func (c *ClusterUpConfig) GetKubeAPIServerConfigDir() string {
return path.Join(c.BaseDir, kubeapiserver.KubeAPIServerDirName)
}

func (c *ClusterUpConfig) GetLogDir() string {
return path.Join(c.BaseDir, "logs")
}

func (c *ClusterUpConfig) RESTConfig() (*rest.Config, error) {
clusterAdminKubeConfigBytes, err := c.ClusterAdminKubeConfigBytes()
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions pkg/oc/cli/cmd/login/loginoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/openshift/origin/pkg/oc/cli/cmd/errors"
loginutil "github.com/openshift/origin/pkg/oc/cli/cmd/login/util"
cliconfig "github.com/openshift/origin/pkg/oc/cli/config"
cmderr "github.com/openshift/origin/pkg/oc/errors"
"github.com/openshift/origin/pkg/oc/util/tokencmd"
projectclient "github.com/openshift/origin/pkg/project/generated/internalclientset"
userapi "github.com/openshift/origin/pkg/user/apis/user"
Expand Down Expand Up @@ -380,7 +379,7 @@ func (o *LoginOptions) SaveConfig() (bool, error) {
}

out := &bytes.Buffer{}
cmderr.PrintError(errors.ErrKubeConfigNotWriteable(o.PathOptions.GetDefaultFilename(), o.PathOptions.IsExplicitFile(), err), out)
fmt.Fprintf(out, errors.ErrKubeConfigNotWriteable(o.PathOptions.GetDefaultFilename(), o.PathOptions.IsExplicitFile(), err).Error())
return false, fmt.Errorf("%v", out)
}

Expand Down
26 changes: 1 addition & 25 deletions pkg/oc/errors/errors.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
package errors

import (
"bytes"
"fmt"
"io"
"runtime/debug"

"github.com/golang/glog"

"github.com/openshift/origin/pkg/oc/util/prefixwriter"
)

type Error interface {
Expand Down Expand Up @@ -61,23 +54,6 @@ func (e *internalError) WithDetails(details string) Error {
}

func (e *internalError) WithSolution(solution string) Error {
e.solution = fmt.Sprintf(solution)
e.solution = solution
return e
}

func LogError(err error) {
if err == nil {
return
}
glog.V(1).Infof("Unexpected error: %v", err)
if glog.V(5) {
debug.PrintStack()
}
}

func PrintLog(out io.Writer, title string, content []byte) {
fmt.Fprintf(out, "%s:\n", title)
w := prefixwriter.New(" ", out)
w.Write(bytes.TrimSpace(content))
fmt.Fprintf(out, "\n")
}
Loading

0 comments on commit 7aa2aea

Please sign in to comment.