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

Fix cluster-capacity functionality as a pod. #18198

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@

FROM golang:latest

MAINTAINER Dominika Hodovska <dhodovsk@redhat.com>
MAINTAINER Avesh Agarwal <avagarwa@redhat.com>

COPY hypercc /bin/hypercc
RUN ln -sf /bin/hypercc /bin/cluster-capacity
RUN ln -sf /bin/hypercc /bin/genpod
COPY config/default-scheduler.yaml /config/default-scheduler.yaml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is used when a customized scheduler config is passed, which should be done via configmap.

Copy link
Contributor Author

@aveshagarwal aveshagarwal Jan 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to hard code or embed in the image.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we document where this configmap should be mounted inside the container?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In https://docs.openshift.com/container-platform/3.7/admin_guide/cluster_capacity.html, we have documented how to mount pod spec via configmap but not customized scheduler config as mostly one does not need that. That said, the above documented can be updated with description about how to mount scheduler config as a ConfigMap in a pod.

CMD ["/bin/cluster-capacity --help"]
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,14 @@ func (s *ClusterCapacityConfig) parseSchedulerConfig(path string) (*schedapp.Sch
decoder.Decode(ksConfig)
}

// In a POD, master is passed as empty string.
var master string
master, err = utils.GetMasterFromKubeConfig(s.Options.Kubeconfig)
if err != nil {
return nil, err
_, present := os.LookupEnv("CC_INCLUSTER")
if !present {
master, err = utils.GetMasterFromKubeConfig(s.Options.Kubeconfig)
if err != nil {
return nil, err
}
}

// TODO(avesh): need to check if this works correctly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func Run(opt *options.ClusterCapacityOptions) error {

err := conf.SetDefaultScheduler()
if err != nil {
return fmt.Errorf("Failed to set default scheduler config: %v ", err)
return fmt.Errorf("Failed to create default scheduler server: %v ", err)
}

// TODO (avesh): Enable when support for multiple schedulers is implemented.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func PrintPod(pod *v1.Pod, format string) error {
func GetMasterFromKubeConfig(filename string) (string, error) {
config, err := clientcmd.LoadFromFile(filename)
if err != nil {
return "", err
return "", fmt.Errorf("can not load kubeconfig file: %v", err)
}

context, ok := config.Contexts[config.CurrentContext]
Expand Down