diff --git a/contrib/mesos/pkg/scheduler/service/publish.go b/contrib/mesos/pkg/scheduler/service/publish.go index adfabfdde42..4ea53e1bdd1 100644 --- a/contrib/mesos/pkg/scheduler/service/publish.go +++ b/contrib/mesos/pkg/scheduler/service/publish.go @@ -42,7 +42,7 @@ func (m *SchedulerServer) newServiceWriter(stop <-chan struct{}) func() { glog.Errorf("Can't create scheduler service: %v", err) } - if err := m.setEndpoints(SCHEDULER_SERVICE_NAME, net.IP(m.Address), m.Port); err != nil { + if err := m.setEndpoints(SCHEDULER_SERVICE_NAME, net.IP(m.address), m.port); err != nil { glog.Errorf("Can't create scheduler endpoints: %v", err) } @@ -76,8 +76,8 @@ func (m *SchedulerServer) createSchedulerServiceIfNeeded(serviceName string, ser SessionAffinity: api.ServiceAffinityNone, }, } - if m.ServiceAddress != nil { - svc.Spec.ClusterIP = m.ServiceAddress.String() + if m.serviceAddress != nil { + svc.Spec.ClusterIP = m.serviceAddress.String() } _, err := m.client.Services(api.NamespaceValue(ctx)).Create(svc) if err != nil && errors.IsAlreadyExists(err) { diff --git a/contrib/mesos/pkg/scheduler/service/service.go b/contrib/mesos/pkg/scheduler/service/service.go index 6c162edfdaf..7d64c2f581c 100644 --- a/contrib/mesos/pkg/scheduler/service/service.go +++ b/contrib/mesos/pkg/scheduler/service/service.go @@ -87,78 +87,78 @@ const ( ) type SchedulerServer struct { - Port int - Address net.IP - EnableProfiling bool - AuthPath string - APIServerList []string - EtcdServerList []string - EtcdConfigFile string - AllowPrivileged bool - ExecutorPath string - ProxyPath string - MesosMaster string - MesosUser string - MesosRole string - MesosAuthPrincipal string - MesosAuthSecretFile string - MesosCgroupPrefix string - MesosExecutorCPUs mresource.CPUShares - MesosExecutorMem mresource.MegaBytes - Checkpoint bool - FailoverTimeout float64 + port int + address net.IP + enableProfiling bool + authPath string + apiServerList []string + etcdServerList []string + etcdConfigFile string + allowPrivileged bool + executorPath string + proxyPath string + mesosMaster string + mesosUser string + mesosRole string + mesosAuthPrincipal string + mesosAuthSecretFile string + mesosCgroupPrefix string + mesosExecutorCPUs mresource.CPUShares + mesosExecutorMem mresource.MegaBytes + checkpoint bool + failoverTimeout float64 - ExecutorLogV int - ExecutorBindall bool - ExecutorSuicideTimeout time.Duration - LaunchGracePeriod time.Duration + executorLogV int + executorBindall bool + executorSuicideTimeout time.Duration + launchGracePeriod time.Duration - RunProxy bool - ProxyBindall bool - ProxyLogV int + runProxy bool + proxyBindall bool + proxyLogV int - MinionPathOverride string - MinionLogMaxSize resource.Quantity - MinionLogMaxBackups int - MinionLogMaxAgeInDays int + minionPathOverride string + minionLogMaxSize resource.Quantity + minionLogMaxBackups int + minionLogMaxAgeInDays int - MesosAuthProvider string - DriverPort uint - HostnameOverride string - ReconcileInterval int64 - ReconcileCooldown time.Duration - DefaultContainerCPULimit mresource.CPUShares - DefaultContainerMemLimit mresource.MegaBytes - SchedulerConfigFileName string - Graceful bool - FrameworkName string - FrameworkWebURI string - HA bool - AdvertisedAddress string - ServiceAddress net.IP - HADomain string - KMPath string - ClusterDNS net.IP - ClusterDomain string - KubeletRootDirectory string - KubeletDockerEndpoint string - KubeletPodInfraContainerImage string - KubeletCadvisorPort uint - KubeletHostNetworkSources string - KubeletSyncFrequency time.Duration - KubeletNetworkPluginName string - StaticPodsConfigPath string - DockerCfgPath string - ContainPodResources bool - AccountForPodResources bool + mesosAuthProvider string + driverPort uint + hostnameOverride string + reconcileInterval int64 + reconcileCooldown time.Duration + defaultContainerCPULimit mresource.CPUShares + defaultContainerMemLimit mresource.MegaBytes + schedulerConfigFileName string + graceful bool + frameworkName string + frameworkWebURI string + ha bool + advertisedAddress string + serviceAddress net.IP + haDomain string + kmPath string + clusterDNS net.IP + clusterDomain string + kubeletRootDirectory string + kubeletDockerEndpoint string + kubeletPodInfraContainerImage string + kubeletCadvisorPort uint + kubeletHostNetworkSources string + kubeletSyncFrequency time.Duration + kubeletNetworkPluginName string + staticPodsConfigPath string + dockerCfgPath string + containPodResources bool + accountForPodResources bool nodeRelistPeriod time.Duration - SandboxOverlay string + sandboxOverlay string - executable string // path to the binary running this service - client *client.Client - driver bindings.SchedulerDriver - driverMutex sync.RWMutex - mux *http.ServeMux + executable string // path to the binary running this service + client *client.Client + driver bindings.SchedulerDriver + driverMutex sync.RWMutex + mux *http.ServeMux } // useful for unit testing specific funcs @@ -171,36 +171,36 @@ type schedulerProcessInterface interface { // NewSchedulerServer creates a new SchedulerServer with default parameters func NewSchedulerServer() *SchedulerServer { s := SchedulerServer{ - Port: ports.SchedulerPort, - Address: net.ParseIP("127.0.0.1"), - FailoverTimeout: time.Duration((1 << 62) - 1).Seconds(), + port: ports.SchedulerPort, + address: net.ParseIP("127.0.0.1"), + failoverTimeout: time.Duration((1 << 62) - 1).Seconds(), - RunProxy: true, - ExecutorSuicideTimeout: execcfg.DefaultSuicideTimeout, - LaunchGracePeriod: execcfg.DefaultLaunchGracePeriod, - DefaultContainerCPULimit: mresource.DefaultDefaultContainerCPULimit, - DefaultContainerMemLimit: mresource.DefaultDefaultContainerMemLimit, + runProxy: true, + executorSuicideTimeout: execcfg.DefaultSuicideTimeout, + launchGracePeriod: execcfg.DefaultLaunchGracePeriod, + defaultContainerCPULimit: mresource.DefaultDefaultContainerCPULimit, + defaultContainerMemLimit: mresource.DefaultDefaultContainerMemLimit, - MinionLogMaxSize: minioncfg.DefaultLogMaxSize(), - MinionLogMaxBackups: minioncfg.DefaultLogMaxBackups, - MinionLogMaxAgeInDays: minioncfg.DefaultLogMaxAgeInDays, + minionLogMaxSize: minioncfg.DefaultLogMaxSize(), + minionLogMaxBackups: minioncfg.DefaultLogMaxBackups, + minionLogMaxAgeInDays: minioncfg.DefaultLogMaxAgeInDays, - MesosAuthProvider: sasl.ProviderName, - MesosCgroupPrefix: minioncfg.DefaultCgroupPrefix, - MesosMaster: defaultMesosMaster, - MesosUser: defaultMesosUser, - MesosExecutorCPUs: defaultExecutorCPUs, - MesosExecutorMem: defaultExecutorMem, - ReconcileInterval: defaultReconcileInterval, - ReconcileCooldown: defaultReconcileCooldown, - Checkpoint: true, - FrameworkName: defaultFrameworkName, - HA: false, + mesosAuthProvider: sasl.ProviderName, + mesosCgroupPrefix: minioncfg.DefaultCgroupPrefix, + mesosMaster: defaultMesosMaster, + mesosUser: defaultMesosUser, + mesosExecutorCPUs: defaultExecutorCPUs, + mesosExecutorMem: defaultExecutorMem, + reconcileInterval: defaultReconcileInterval, + reconcileCooldown: defaultReconcileCooldown, + checkpoint: true, + frameworkName: defaultFrameworkName, + ha: false, mux: http.NewServeMux(), - KubeletCadvisorPort: 4194, // copied from github.com/GoogleCloudPlatform/kubernetes/blob/release-0.14/cmd/kubelet/app/server.go - KubeletSyncFrequency: 10 * time.Second, - ContainPodResources: true, - AccountForPodResources: true, + kubeletCadvisorPort: 4194, // copied from github.com/GoogleCloudPlatform/kubernetes/blob/release-0.14/cmd/kubelet/app/server.go + kubeletSyncFrequency: 10 * time.Second, + containPodResources: true, + accountForPodResources: true, nodeRelistPeriod: defaultNodeRelistPeriod, } // cache this for later use. also useful in case the original binary gets deleted, e.g. @@ -209,76 +209,76 @@ func NewSchedulerServer() *SchedulerServer { log.Fatalf("failed to determine path to currently running executable: %v", err) } else { s.executable = filename - s.KMPath = filename + s.kmPath = filename } return &s } func (s *SchedulerServer) addCoreFlags(fs *pflag.FlagSet) { - fs.IntVar(&s.Port, "port", s.Port, "The port that the scheduler's http service runs on") - fs.IPVar(&s.Address, "address", s.Address, "The IP address to serve on (set to 0.0.0.0 for all interfaces)") - fs.BoolVar(&s.EnableProfiling, "profiling", s.EnableProfiling, "Enable profiling via web interface host:port/debug/pprof/") - fs.StringSliceVar(&s.APIServerList, "api-servers", s.APIServerList, "List of Kubernetes API servers for publishing events, and reading pods and services. (ip:port), comma separated.") - fs.StringVar(&s.AuthPath, "auth-path", s.AuthPath, "Path to .kubernetes_auth file, specifying how to authenticate to API server.") - fs.StringSliceVar(&s.EtcdServerList, "etcd-servers", s.EtcdServerList, "List of etcd servers to watch (http://ip:port), comma separated. Mutually exclusive with --etcd-config") - fs.StringVar(&s.EtcdConfigFile, "etcd-config", s.EtcdConfigFile, "The config file for the etcd client. Mutually exclusive with --etcd-servers.") - fs.BoolVar(&s.AllowPrivileged, "allow-privileged", s.AllowPrivileged, "If true, allow privileged containers.") - fs.StringVar(&s.ClusterDomain, "cluster-domain", s.ClusterDomain, "Domain for this cluster. If set, kubelet will configure all containers to search this domain in addition to the host's search domains") - fs.IPVar(&s.ClusterDNS, "cluster-dns", s.ClusterDNS, "IP address for a cluster DNS server. If set, kubelet will configure all containers to use this for DNS resolution in addition to the host's DNS servers") - fs.StringVar(&s.StaticPodsConfigPath, "static-pods-config", s.StaticPodsConfigPath, "Path for specification of static pods. Path should point to dir containing the staticPods configuration files. Defaults to none.") + fs.IntVar(&s.port, "port", s.port, "The port that the scheduler's http service runs on") + fs.IPVar(&s.address, "address", s.address, "The IP address to serve on (set to 0.0.0.0 for all interfaces)") + fs.BoolVar(&s.enableProfiling, "profiling", s.enableProfiling, "Enable profiling via web interface host:port/debug/pprof/") + fs.StringSliceVar(&s.apiServerList, "api-servers", s.apiServerList, "List of Kubernetes API servers for publishing events, and reading pods and services. (ip:port), comma separated.") + fs.StringVar(&s.authPath, "auth-path", s.authPath, "Path to .kubernetes_auth file, specifying how to authenticate to API server.") + fs.StringSliceVar(&s.etcdServerList, "etcd-servers", s.etcdServerList, "List of etcd servers to watch (http://ip:port), comma separated. Mutually exclusive with --etcd-config") + fs.StringVar(&s.etcdConfigFile, "etcd-config", s.etcdConfigFile, "The config file for the etcd client. Mutually exclusive with --etcd-servers.") + fs.BoolVar(&s.allowPrivileged, "allow-privileged", s.allowPrivileged, "If true, allow privileged containers.") + fs.StringVar(&s.clusterDomain, "cluster-domain", s.clusterDomain, "Domain for this cluster. If set, kubelet will configure all containers to search this domain in addition to the host's search domains") + fs.IPVar(&s.clusterDNS, "cluster-dns", s.clusterDNS, "IP address for a cluster DNS server. If set, kubelet will configure all containers to use this for DNS resolution in addition to the host's DNS servers") + fs.StringVar(&s.staticPodsConfigPath, "static-pods-config", s.staticPodsConfigPath, "Path for specification of static pods. Path should point to dir containing the staticPods configuration files. Defaults to none.") - fs.StringVar(&s.MesosMaster, "mesos-master", s.MesosMaster, "Location of the Mesos master. The format is a comma-delimited list of of hosts like zk://host1:port,host2:port/mesos. If using ZooKeeper, pay particular attention to the leading zk:// and trailing /mesos! If not using ZooKeeper, standard URLs like http://localhost are also acceptable.") - fs.StringVar(&s.MesosUser, "mesos-user", s.MesosUser, "Mesos user for this framework, defaults to root.") - fs.StringVar(&s.MesosRole, "mesos-role", s.MesosRole, "Mesos role for this framework, defaults to none.") - fs.StringVar(&s.MesosAuthPrincipal, "mesos-authentication-principal", s.MesosAuthPrincipal, "Mesos authentication principal.") - fs.StringVar(&s.MesosAuthSecretFile, "mesos-authentication-secret-file", s.MesosAuthSecretFile, "Mesos authentication secret file.") - fs.StringVar(&s.MesosAuthProvider, "mesos-authentication-provider", s.MesosAuthProvider, fmt.Sprintf("Authentication provider to use, default is SASL that supports mechanisms: %+v", mech.ListSupported())) - fs.StringVar(&s.DockerCfgPath, "dockercfg-path", s.DockerCfgPath, "Path to a dockercfg file that will be used by the docker instance of the minions.") - fs.StringVar(&s.MesosCgroupPrefix, "mesos-cgroup-prefix", s.MesosCgroupPrefix, "The cgroup prefix concatenated with MESOS_DIRECTORY must give the executor cgroup set by Mesos") - fs.Var(&s.MesosExecutorCPUs, "mesos-executor-cpus", "Initial CPU shares to allocate for each Mesos executor container.") - fs.Var(&s.MesosExecutorMem, "mesos-executor-mem", "Initial memory (MB) to allocate for each Mesos executor container.") - fs.BoolVar(&s.Checkpoint, "checkpoint", s.Checkpoint, "Enable/disable checkpointing for the kubernetes-mesos framework.") - fs.Float64Var(&s.FailoverTimeout, "failover-timeout", s.FailoverTimeout, fmt.Sprintf("Framework failover timeout, in sec.")) - fs.UintVar(&s.DriverPort, "driver-port", s.DriverPort, "Port that the Mesos scheduler driver process should listen on.") - fs.StringVar(&s.HostnameOverride, "hostname-override", s.HostnameOverride, "If non-empty, will use this string as identification instead of the actual hostname.") - fs.Int64Var(&s.ReconcileInterval, "reconcile-interval", s.ReconcileInterval, "Interval at which to execute task reconciliation, in sec. Zero disables.") - fs.DurationVar(&s.ReconcileCooldown, "reconcile-cooldown", s.ReconcileCooldown, "Minimum rest period between task reconciliation operations.") - fs.StringVar(&s.SchedulerConfigFileName, "scheduler-config", s.SchedulerConfigFileName, "An ini-style configuration file with low-level scheduler settings.") - fs.BoolVar(&s.Graceful, "graceful", s.Graceful, "Indicator of a graceful failover, intended for internal use only.") - fs.BoolVar(&s.HA, "ha", s.HA, "Run the scheduler in high availability mode with leader election. All peers should be configured exactly the same.") - fs.StringVar(&s.FrameworkName, "framework-name", s.FrameworkName, "The framework name to register with Mesos.") - fs.StringVar(&s.FrameworkWebURI, "framework-weburi", s.FrameworkWebURI, "A URI that points to a web-based interface for interacting with the framework.") - fs.StringVar(&s.AdvertisedAddress, "advertised-address", s.AdvertisedAddress, "host:port address that is advertised to clients. May be used to construct artifact download URIs.") - fs.IPVar(&s.ServiceAddress, "service-address", s.ServiceAddress, "The service portal IP address that the scheduler should register with (if unset, chooses randomly)") - fs.Var(&s.DefaultContainerCPULimit, "default-container-cpu-limit", "Containers without a CPU resource limit are admitted this much CPU shares") - fs.Var(&s.DefaultContainerMemLimit, "default-container-mem-limit", "Containers without a memory resource limit are admitted this much amount of memory in MB") - fs.BoolVar(&s.ContainPodResources, "contain-pod-resources", s.ContainPodResources, "Reparent pod containers into mesos cgroups; disable if you're having strange mesos/docker/systemd interactions.") - fs.BoolVar(&s.AccountForPodResources, "account-for-pod-resources", s.AccountForPodResources, "Allocate pod CPU and memory resources from offers (Default: true)") + fs.StringVar(&s.mesosMaster, "mesos-master", s.mesosMaster, "Location of the Mesos master. The format is a comma-delimited list of of hosts like zk://host1:port,host2:port/mesos. If using ZooKeeper, pay particular attention to the leading zk:// and trailing /mesos! If not using ZooKeeper, standard URLs like http://localhost are also acceptable.") + fs.StringVar(&s.mesosUser, "mesos-user", s.mesosUser, "Mesos user for this framework, defaults to root.") + fs.StringVar(&s.mesosRole, "mesos-role", s.mesosRole, "Mesos role for this framework, defaults to none.") + fs.StringVar(&s.mesosAuthPrincipal, "mesos-authentication-principal", s.mesosAuthPrincipal, "Mesos authentication principal.") + fs.StringVar(&s.mesosAuthSecretFile, "mesos-authentication-secret-file", s.mesosAuthSecretFile, "Mesos authentication secret file.") + fs.StringVar(&s.mesosAuthProvider, "mesos-authentication-provider", s.mesosAuthProvider, fmt.Sprintf("Authentication provider to use, default is SASL that supports mechanisms: %+v", mech.ListSupported())) + fs.StringVar(&s.dockerCfgPath, "dockercfg-path", s.dockerCfgPath, "Path to a dockercfg file that will be used by the docker instance of the minions.") + fs.StringVar(&s.mesosCgroupPrefix, "mesos-cgroup-prefix", s.mesosCgroupPrefix, "The cgroup prefix concatenated with MESOS_DIRECTORY must give the executor cgroup set by Mesos") + fs.Var(&s.mesosExecutorCPUs, "mesos-executor-cpus", "Initial CPU shares to allocate for each Mesos executor container.") + fs.Var(&s.mesosExecutorMem, "mesos-executor-mem", "Initial memory (MB) to allocate for each Mesos executor container.") + fs.BoolVar(&s.checkpoint, "checkpoint", s.checkpoint, "Enable/disable checkpointing for the kubernetes-mesos framework.") + fs.Float64Var(&s.failoverTimeout, "failover-timeout", s.failoverTimeout, fmt.Sprintf("Framework failover timeout, in sec.")) + fs.UintVar(&s.driverPort, "driver-port", s.driverPort, "Port that the Mesos scheduler driver process should listen on.") + fs.StringVar(&s.hostnameOverride, "hostname-override", s.hostnameOverride, "If non-empty, will use this string as identification instead of the actual hostname.") + fs.Int64Var(&s.reconcileInterval, "reconcile-interval", s.reconcileInterval, "Interval at which to execute task reconciliation, in sec. Zero disables.") + fs.DurationVar(&s.reconcileCooldown, "reconcile-cooldown", s.reconcileCooldown, "Minimum rest period between task reconciliation operations.") + fs.StringVar(&s.schedulerConfigFileName, "scheduler-config", s.schedulerConfigFileName, "An ini-style configuration file with low-level scheduler settings.") + fs.BoolVar(&s.graceful, "graceful", s.graceful, "Indicator of a graceful failover, intended for internal use only.") + fs.BoolVar(&s.ha, "ha", s.ha, "Run the scheduler in high availability mode with leader election. All peers should be configured exactly the same.") + fs.StringVar(&s.frameworkName, "framework-name", s.frameworkName, "The framework name to register with Mesos.") + fs.StringVar(&s.frameworkWebURI, "framework-weburi", s.frameworkWebURI, "A URI that points to a web-based interface for interacting with the framework.") + fs.StringVar(&s.advertisedAddress, "advertised-address", s.advertisedAddress, "host:port address that is advertised to clients. May be used to construct artifact download URIs.") + fs.IPVar(&s.serviceAddress, "service-address", s.serviceAddress, "The service portal IP address that the scheduler should register with (if unset, chooses randomly)") + fs.Var(&s.defaultContainerCPULimit, "default-container-cpu-limit", "Containers without a CPU resource limit are admitted this much CPU shares") + fs.Var(&s.defaultContainerMemLimit, "default-container-mem-limit", "Containers without a memory resource limit are admitted this much amount of memory in MB") + fs.BoolVar(&s.containPodResources, "contain-pod-resources", s.containPodResources, "Reparent pod containers into mesos cgroups; disable if you're having strange mesos/docker/systemd interactions.") + fs.BoolVar(&s.accountForPodResources, "account-for-pod-resources", s.accountForPodResources, "Allocate pod CPU and memory resources from offers (Default: true)") fs.DurationVar(&s.nodeRelistPeriod, "node-monitor-period", s.nodeRelistPeriod, "Period between relisting of all nodes from the apiserver.") - fs.IntVar(&s.ExecutorLogV, "executor-logv", s.ExecutorLogV, "Logging verbosity of spawned minion and executor processes.") - fs.BoolVar(&s.ExecutorBindall, "executor-bindall", s.ExecutorBindall, "When true will set -address of the executor to 0.0.0.0.") - fs.DurationVar(&s.ExecutorSuicideTimeout, "executor-suicide-timeout", s.ExecutorSuicideTimeout, "Executor self-terminates after this period of inactivity. Zero disables suicide watch.") - fs.DurationVar(&s.LaunchGracePeriod, "mesos-launch-grace-period", s.LaunchGracePeriod, "Launch grace period after which launching tasks will be cancelled. Zero disables launch cancellation.") - fs.StringVar(&s.SandboxOverlay, "mesos-sandbox-overlay", s.SandboxOverlay, "Path to an archive (tar.gz, tar.bz2 or zip) extracted into the sandbox.") + fs.IntVar(&s.executorLogV, "executor-logv", s.executorLogV, "Logging verbosity of spawned minion and executor processes.") + fs.BoolVar(&s.executorBindall, "executor-bindall", s.executorBindall, "When true will set -address of the executor to 0.0.0.0.") + fs.DurationVar(&s.executorSuicideTimeout, "executor-suicide-timeout", s.executorSuicideTimeout, "Executor self-terminates after this period of inactivity. Zero disables suicide watch.") + fs.DurationVar(&s.launchGracePeriod, "mesos-launch-grace-period", s.launchGracePeriod, "Launch grace period after which launching tasks will be cancelled. Zero disables launch cancellation.") + fs.StringVar(&s.sandboxOverlay, "mesos-sandbox-overlay", s.sandboxOverlay, "Path to an archive (tar.gz, tar.bz2 or zip) extracted into the sandbox.") - fs.BoolVar(&s.ProxyBindall, "proxy-bindall", s.ProxyBindall, "When true pass -proxy-bindall to the executor.") - fs.BoolVar(&s.RunProxy, "run-proxy", s.RunProxy, "Run the kube-proxy as a side process of the executor.") - fs.IntVar(&s.ProxyLogV, "proxy-logv", s.ProxyLogV, "Logging verbosity of spawned minion proxy processes.") + fs.BoolVar(&s.proxyBindall, "proxy-bindall", s.proxyBindall, "When true pass -proxy-bindall to the executor.") + fs.BoolVar(&s.runProxy, "run-proxy", s.runProxy, "Run the kube-proxy as a side process of the executor.") + fs.IntVar(&s.proxyLogV, "proxy-logv", s.proxyLogV, "Logging verbosity of spawned minion proxy processes.") - fs.StringVar(&s.MinionPathOverride, "minion-path-override", s.MinionPathOverride, "Override the PATH in the environment of the minion sub-processes.") - fs.Var(resource.NewQuantityFlagValue(&s.MinionLogMaxSize), "minion-max-log-size", "Maximum log file size for the executor and proxy before rotation") - fs.IntVar(&s.MinionLogMaxAgeInDays, "minion-max-log-age", s.MinionLogMaxAgeInDays, "Maximum log file age of the executor and proxy in days") - fs.IntVar(&s.MinionLogMaxBackups, "minion-max-log-backups", s.MinionLogMaxBackups, "Maximum log file backups of the executor and proxy to keep after rotation") + fs.StringVar(&s.minionPathOverride, "minion-path-override", s.minionPathOverride, "Override the PATH in the environment of the minion sub-processes.") + fs.Var(resource.NewQuantityFlagValue(&s.minionLogMaxSize), "minion-max-log-size", "Maximum log file size for the executor and proxy before rotation") + fs.IntVar(&s.minionLogMaxAgeInDays, "minion-max-log-age", s.minionLogMaxAgeInDays, "Maximum log file age of the executor and proxy in days") + fs.IntVar(&s.minionLogMaxBackups, "minion-max-log-backups", s.minionLogMaxBackups, "Maximum log file backups of the executor and proxy to keep after rotation") - fs.StringVar(&s.KubeletRootDirectory, "kubelet-root-dir", s.KubeletRootDirectory, "Directory path for managing kubelet files (volume mounts,etc). Defaults to executor sandbox.") - fs.StringVar(&s.KubeletDockerEndpoint, "kubelet-docker-endpoint", s.KubeletDockerEndpoint, "If non-empty, kubelet will use this for the docker endpoint to communicate with.") - fs.StringVar(&s.KubeletPodInfraContainerImage, "kubelet-pod-infra-container-image", s.KubeletPodInfraContainerImage, "The image whose network/ipc namespaces containers in each pod will use.") - fs.UintVar(&s.KubeletCadvisorPort, "kubelet-cadvisor-port", s.KubeletCadvisorPort, "The port of the kubelet's local cAdvisor endpoint") - fs.StringVar(&s.KubeletHostNetworkSources, "kubelet-host-network-sources", s.KubeletHostNetworkSources, "Comma-separated list of sources from which the Kubelet allows pods to use of host network. For all sources use \"*\" [default=\"file\"]") - fs.DurationVar(&s.KubeletSyncFrequency, "kubelet-sync-frequency", s.KubeletSyncFrequency, "Max period between synchronizing running containers and config") - fs.StringVar(&s.KubeletNetworkPluginName, "kubelet-network-plugin", s.KubeletNetworkPluginName, " The name of the network plugin to be invoked for various events in kubelet/pod lifecycle") + fs.StringVar(&s.kubeletRootDirectory, "kubelet-root-dir", s.kubeletRootDirectory, "Directory path for managing kubelet files (volume mounts,etc). Defaults to executor sandbox.") + fs.StringVar(&s.kubeletDockerEndpoint, "kubelet-docker-endpoint", s.kubeletDockerEndpoint, "If non-empty, kubelet will use this for the docker endpoint to communicate with.") + fs.StringVar(&s.kubeletPodInfraContainerImage, "kubelet-pod-infra-container-image", s.kubeletPodInfraContainerImage, "The image whose network/ipc namespaces containers in each pod will use.") + fs.UintVar(&s.kubeletCadvisorPort, "kubelet-cadvisor-port", s.kubeletCadvisorPort, "The port of the kubelet's local cAdvisor endpoint") + fs.StringVar(&s.kubeletHostNetworkSources, "kubelet-host-network-sources", s.kubeletHostNetworkSources, "Comma-separated list of sources from which the Kubelet allows pods to use of host network. For all sources use \"*\" [default=\"file\"]") + fs.DurationVar(&s.kubeletSyncFrequency, "kubelet-sync-frequency", s.kubeletSyncFrequency, "Max period between synchronizing running containers and config") + fs.StringVar(&s.kubeletNetworkPluginName, "kubelet-network-plugin", s.kubeletNetworkPluginName, " The name of the network plugin to be invoked for various events in kubelet/pod lifecycle") //TODO(jdef) support this flag once we have a better handle on mesos-dns and k8s DNS integration //fs.StringVar(&s.HADomain, "ha-domain", s.HADomain, "Domain of the HA scheduler service, only used in HA mode. If specified may be used to construct artifact download URIs.") @@ -286,12 +286,12 @@ func (s *SchedulerServer) addCoreFlags(fs *pflag.FlagSet) { func (s *SchedulerServer) AddStandaloneFlags(fs *pflag.FlagSet) { s.addCoreFlags(fs) - fs.StringVar(&s.ExecutorPath, "executor-path", s.ExecutorPath, "Location of the kubernetes executor executable") + fs.StringVar(&s.executorPath, "executor-path", s.executorPath, "Location of the kubernetes executor executable") } func (s *SchedulerServer) AddHyperkubeFlags(fs *pflag.FlagSet) { s.addCoreFlags(fs) - fs.StringVar(&s.KMPath, "km-path", s.KMPath, "Location of the km executable, may be a URI or an absolute file path.") + fs.StringVar(&s.kmPath, "km-path", s.kmPath, "Location of the km executable, may be a URI or an absolute file path.") } // returns (downloadURI, basename(path)) @@ -311,12 +311,12 @@ func (s *SchedulerServer) serveFrameworkArtifactWithFilename(path string, filena serveFile("/"+filename, path) hostURI := "" - if s.AdvertisedAddress != "" { - hostURI = fmt.Sprintf("http://%s/%s", s.AdvertisedAddress, filename) - } else if s.HA && s.HADomain != "" { - hostURI = fmt.Sprintf("http://%s.%s:%d/%s", SCHEDULER_SERVICE_NAME, s.HADomain, ports.SchedulerPort, filename) + if s.advertisedAddress != "" { + hostURI = fmt.Sprintf("http://%s/%s", s.advertisedAddress, filename) + } else if s.ha && s.haDomain != "" { + hostURI = fmt.Sprintf("http://%s.%s:%d/%s", SCHEDULER_SERVICE_NAME, s.haDomain, ports.SchedulerPort, filename) } else { - hostURI = fmt.Sprintf("http://%s:%d/%s", s.Address.String(), s.Port, filename) + hostURI = fmt.Sprintf("http://%s:%d/%s", s.address.String(), s.port, filename) } log.V(2).Infof("Hosting artifact '%s' at '%s'", filename, hostURI) @@ -328,21 +328,21 @@ func (s *SchedulerServer) prepareExecutorInfo(hks hyperkube.Interface) (*mesos.E Shell: proto.Bool(false), } - if s.ExecutorPath != "" { - uri, executorCmd := s.serveFrameworkArtifact(s.ExecutorPath) + if s.executorPath != "" { + uri, executorCmd := s.serveFrameworkArtifact(s.executorPath) ci.Uris = append(ci.Uris, &mesos.CommandInfo_URI{Value: proto.String(uri), Executable: proto.Bool(true)}) ci.Value = proto.String(fmt.Sprintf("./%s", executorCmd)) } else if !hks.FindServer(hyperkube.CommandMinion) { return nil, nil, fmt.Errorf("either run this scheduler via km or else --executor-path is required") } else { - if strings.Index(s.KMPath, "://") > 0 { + if strings.Index(s.kmPath, "://") > 0 { // URI could point directly to executable, e.g. hdfs:///km // or else indirectly, e.g. http://acmestorage/tarball.tgz // so we assume that for this case the command will always "km" - ci.Uris = append(ci.Uris, &mesos.CommandInfo_URI{Value: proto.String(s.KMPath), Executable: proto.Bool(true)}) + ci.Uris = append(ci.Uris, &mesos.CommandInfo_URI{Value: proto.String(s.kmPath), Executable: proto.Bool(true)}) ci.Value = proto.String("./km") // TODO(jdef) extract constant - } else if s.KMPath != "" { - uri, kmCmd := s.serveFrameworkArtifact(s.KMPath) + } else if s.kmPath != "" { + uri, kmCmd := s.serveFrameworkArtifact(s.kmPath) ci.Uris = append(ci.Uris, &mesos.CommandInfo_URI{Value: proto.String(uri), Executable: proto.Bool(true)}) ci.Value = proto.String(fmt.Sprintf("./%s", kmCmd)) } else { @@ -352,55 +352,55 @@ func (s *SchedulerServer) prepareExecutorInfo(hks hyperkube.Interface) (*mesos.E } ci.Arguments = append(ci.Arguments, hyperkube.CommandMinion) - ci.Arguments = append(ci.Arguments, fmt.Sprintf("--run-proxy=%v", s.RunProxy)) - ci.Arguments = append(ci.Arguments, fmt.Sprintf("--proxy-bindall=%v", s.ProxyBindall)) - ci.Arguments = append(ci.Arguments, fmt.Sprintf("--proxy-logv=%d", s.ProxyLogV)) + ci.Arguments = append(ci.Arguments, fmt.Sprintf("--run-proxy=%v", s.runProxy)) + ci.Arguments = append(ci.Arguments, fmt.Sprintf("--proxy-bindall=%v", s.proxyBindall)) + ci.Arguments = append(ci.Arguments, fmt.Sprintf("--proxy-logv=%d", s.proxyLogV)) - ci.Arguments = append(ci.Arguments, fmt.Sprintf("--path-override=%s", s.MinionPathOverride)) - ci.Arguments = append(ci.Arguments, fmt.Sprintf("--max-log-size=%v", s.MinionLogMaxSize.String())) - ci.Arguments = append(ci.Arguments, fmt.Sprintf("--max-log-backups=%d", s.MinionLogMaxBackups)) - ci.Arguments = append(ci.Arguments, fmt.Sprintf("--max-log-age=%d", s.MinionLogMaxAgeInDays)) + ci.Arguments = append(ci.Arguments, fmt.Sprintf("--path-override=%s", s.minionPathOverride)) + ci.Arguments = append(ci.Arguments, fmt.Sprintf("--max-log-size=%v", s.minionLogMaxSize.String())) + ci.Arguments = append(ci.Arguments, fmt.Sprintf("--max-log-backups=%d", s.minionLogMaxBackups)) + ci.Arguments = append(ci.Arguments, fmt.Sprintf("--max-log-age=%d", s.minionLogMaxAgeInDays)) } - if s.SandboxOverlay != "" { - if _, err := os.Stat(s.SandboxOverlay); os.IsNotExist(err) { - log.Fatalf("Sandbox overlay archive not found: %s", s.SandboxOverlay) + if s.sandboxOverlay != "" { + if _, err := os.Stat(s.sandboxOverlay); os.IsNotExist(err) { + log.Fatalf("Sandbox overlay archive not found: %s", s.sandboxOverlay) } - uri, _ := s.serveFrameworkArtifact(s.SandboxOverlay) + uri, _ := s.serveFrameworkArtifact(s.sandboxOverlay) ci.Uris = append(ci.Uris, &mesos.CommandInfo_URI{Value: proto.String(uri), Executable: proto.Bool(false), Extract: proto.Bool(true)}) } - if s.DockerCfgPath != "" { - uri := s.serveFrameworkArtifactWithFilename(s.DockerCfgPath, ".dockercfg") + if s.dockerCfgPath != "" { + uri := s.serveFrameworkArtifactWithFilename(s.dockerCfgPath, ".dockercfg") ci.Uris = append(ci.Uris, &mesos.CommandInfo_URI{Value: proto.String(uri), Executable: proto.Bool(false), Extract: proto.Bool(false)}) } //TODO(jdef): provide some way (env var?) for users to customize executor config //TODO(jdef): set -address to 127.0.0.1 if `address` is 127.0.0.1 - apiServerArgs := strings.Join(s.APIServerList, ",") + apiServerArgs := strings.Join(s.apiServerList, ",") ci.Arguments = append(ci.Arguments, fmt.Sprintf("--api-servers=%s", apiServerArgs)) - ci.Arguments = append(ci.Arguments, fmt.Sprintf("--v=%d", s.ExecutorLogV)) // this also applies to the minion - ci.Arguments = append(ci.Arguments, fmt.Sprintf("--allow-privileged=%t", s.AllowPrivileged)) - ci.Arguments = append(ci.Arguments, fmt.Sprintf("--suicide-timeout=%v", s.ExecutorSuicideTimeout)) - ci.Arguments = append(ci.Arguments, fmt.Sprintf("--mesos-launch-grace-period=%v", s.LaunchGracePeriod)) + ci.Arguments = append(ci.Arguments, fmt.Sprintf("--v=%d", s.executorLogV)) // this also applies to the minion + ci.Arguments = append(ci.Arguments, fmt.Sprintf("--allow-privileged=%t", s.allowPrivileged)) + ci.Arguments = append(ci.Arguments, fmt.Sprintf("--suicide-timeout=%v", s.executorSuicideTimeout)) + ci.Arguments = append(ci.Arguments, fmt.Sprintf("--mesos-launch-grace-period=%v", s.launchGracePeriod)) - if s.ExecutorBindall { + if s.executorBindall { //TODO(jdef) determine whether hostname-override is really needed for bindall because //it conflicts with kubelet node status checks/updates //ci.Arguments = append(ci.Arguments, "--hostname-override=0.0.0.0") ci.Arguments = append(ci.Arguments, "--address=0.0.0.0") } - ci.Arguments = append(ci.Arguments, fmt.Sprintf("--mesos-cgroup-prefix=%v", s.MesosCgroupPrefix)) - ci.Arguments = append(ci.Arguments, fmt.Sprintf("--cadvisor-port=%v", s.KubeletCadvisorPort)) - ci.Arguments = append(ci.Arguments, fmt.Sprintf("--sync-frequency=%v", s.KubeletSyncFrequency)) - ci.Arguments = append(ci.Arguments, fmt.Sprintf("--contain-pod-resources=%t", s.ContainPodResources)) - ci.Arguments = append(ci.Arguments, fmt.Sprintf("--enable-debugging-handlers=%t", s.EnableProfiling)) + ci.Arguments = append(ci.Arguments, fmt.Sprintf("--mesos-cgroup-prefix=%v", s.mesosCgroupPrefix)) + ci.Arguments = append(ci.Arguments, fmt.Sprintf("--cadvisor-port=%v", s.kubeletCadvisorPort)) + ci.Arguments = append(ci.Arguments, fmt.Sprintf("--sync-frequency=%v", s.kubeletSyncFrequency)) + ci.Arguments = append(ci.Arguments, fmt.Sprintf("--contain-pod-resources=%t", s.containPodResources)) + ci.Arguments = append(ci.Arguments, fmt.Sprintf("--enable-debugging-handlers=%t", s.enableProfiling)) - if s.AuthPath != "" { + if s.authPath != "" { //TODO(jdef) should probably support non-local files, e.g. hdfs:///some/config/file - uri, basename := s.serveFrameworkArtifact(s.AuthPath) + uri, basename := s.serveFrameworkArtifact(s.authPath) ci.Uris = append(ci.Uris, &mesos.CommandInfo_URI{Value: proto.String(uri)}) ci.Arguments = append(ci.Arguments, fmt.Sprintf("--auth-path=%s", basename)) } @@ -409,15 +409,15 @@ func (s *SchedulerServer) prepareExecutorInfo(hks hyperkube.Interface) (*mesos.E ci.Arguments = append(ci.Arguments, fmt.Sprintf("--%s=%s", name, value)) } } - if s.ClusterDNS != nil { - appendOptional("cluster-dns", s.ClusterDNS.String()) + if s.clusterDNS != nil { + appendOptional("cluster-dns", s.clusterDNS.String()) } - appendOptional("cluster-domain", s.ClusterDomain) - appendOptional("root-dir", s.KubeletRootDirectory) - appendOptional("docker-endpoint", s.KubeletDockerEndpoint) - appendOptional("pod-infra-container-image", s.KubeletPodInfraContainerImage) - appendOptional("host-network-sources", s.KubeletHostNetworkSources) - appendOptional("network-plugin", s.KubeletNetworkPluginName) + appendOptional("cluster-domain", s.clusterDomain) + appendOptional("root-dir", s.kubeletRootDirectory) + appendOptional("docker-endpoint", s.kubeletDockerEndpoint) + appendOptional("pod-infra-container-image", s.kubeletPodInfraContainerImage) + appendOptional("host-network-sources", s.kubeletHostNetworkSources) + appendOptional("network-plugin", s.kubeletNetworkPluginName) log.V(1).Infof("prepared executor command %q with args '%+v'", ci.GetValue(), ci.Arguments) @@ -430,8 +430,8 @@ func (s *SchedulerServer) prepareExecutorInfo(hks hyperkube.Interface) (*mesos.E // Check for staticPods var staticPodCPUs, staticPodMem float64 - if s.StaticPodsConfigPath != "" { - bs, paths, err := archive.ZipDir(s.StaticPodsConfigPath) + if s.staticPodsConfigPath != "" { + bs, paths, err := archive.ZipDir(s.staticPodsConfigPath) if err != nil { return nil, nil, err } @@ -452,8 +452,8 @@ func (s *SchedulerServer) prepareExecutorInfo(hks hyperkube.Interface) (*mesos.E } // TODO(sttts): allow unlimited static pods as well and patch in the default resource limits - unlimitedCPU := mresource.LimitPodCPU(&pod, s.DefaultContainerCPULimit) - unlimitedMem := mresource.LimitPodMem(&pod, s.DefaultContainerMemLimit) + unlimitedCPU := mresource.LimitPodCPU(&pod, s.defaultContainerCPULimit) + unlimitedMem := mresource.LimitPodMem(&pod, s.defaultContainerMemLimit) if unlimitedCPU { return nil, nil, fmt.Errorf("found static pod without limit on cpu resources: %v", podPath) } @@ -474,8 +474,8 @@ func (s *SchedulerServer) prepareExecutorInfo(hks hyperkube.Interface) (*mesos.E } execInfo.Resources = []*mesos.Resource{ - mutil.NewScalarResource("cpus", float64(s.MesosExecutorCPUs)+staticPodCPUs), - mutil.NewScalarResource("mem", float64(s.MesosExecutorMem)+staticPodMem), + mutil.NewScalarResource("cpus", float64(s.mesosExecutorCPUs)+staticPodCPUs), + mutil.NewScalarResource("mem", float64(s.mesosExecutorMem)+staticPodMem), } // calculate ExecutorInfo hash to be used for validating compatibility @@ -490,7 +490,7 @@ func (s *SchedulerServer) prepareExecutorInfo(hks hyperkube.Interface) (*mesos.E // TODO(jdef): hacked from kubelet/server/server.go // TODO(k8s): replace this with clientcmd func (s *SchedulerServer) createAPIServerClient() (*client.Client, error) { - authInfo, err := clientauth.LoadFromFile(s.AuthPath) + authInfo, err := clientauth.LoadFromFile(s.authPath) if err != nil { log.Warningf("Could not load kubernetes auth path: %v. Continuing with defaults.", err) } @@ -502,14 +502,14 @@ func (s *SchedulerServer) createAPIServerClient() (*client.Client, error) { if err != nil { return nil, err } - if len(s.APIServerList) < 1 { + if len(s.apiServerList) < 1 { return nil, fmt.Errorf("no api servers specified") } // TODO: adapt Kube client to support LB over several servers - if len(s.APIServerList) > 1 { + if len(s.apiServerList) > 1 { log.Infof("Multiple api servers specified. Picking first one") } - clientConfig.Host = s.APIServerList[0] + clientConfig.Host = s.apiServerList[0] c, err := client.New(&clientConfig) if err != nil { return nil, err @@ -532,8 +532,8 @@ func (s *SchedulerServer) getDriver() (driver bindings.SchedulerDriver) { func (s *SchedulerServer) Run(hks hyperkube.Interface, _ []string) error { // get scheduler low-level config sc := schedcfg.CreateDefaultConfig() - if s.SchedulerConfigFileName != "" { - f, err := os.Open(s.SchedulerConfigFileName) + if s.schedulerConfigFileName != "" { + f, err := os.Open(s.schedulerConfigFileName) if err != nil { log.Fatalf("Cannot open scheduler config file: %v", err) } @@ -546,18 +546,18 @@ func (s *SchedulerServer) Run(hks hyperkube.Interface, _ []string) error { schedulerProcess, driverFactory, etcdClient, eid := s.bootstrap(hks, sc) - if s.EnableProfiling { + if s.enableProfiling { profile.InstallHandler(s.mux) } go runtime.Until(func() { log.V(1).Info("Starting HTTP interface") - log.Error(http.ListenAndServe(net.JoinHostPort(s.Address.String(), strconv.Itoa(s.Port)), s.mux)) + log.Error(http.ListenAndServe(net.JoinHostPort(s.address.String(), strconv.Itoa(s.port)), s.mux)) }, sc.HttpBindInterval.Duration, schedulerProcess.Terminal()) - if s.HA { + if s.ha { validation := ha.ValidationFunc(validateLeadershipTransition) srv := ha.NewCandidate(schedulerProcess, driverFactory, validation) - path := fmt.Sprintf(meta.DefaultElectionFormat, s.FrameworkName) + path := fmt.Sprintf(meta.DefaultElectionFormat, s.frameworkName) sid := uid.New(eid.Group(), "").String() log.Infof("registering for election at %v with id %v", path, sid) go election.Notify(election.NewEtcdMasterElector(etcdClient), path, sid, srv, nil) @@ -596,7 +596,7 @@ func (s *SchedulerServer) awaitFailover(schedulerProcess schedulerProcessInterfa case <-schedulerProcess.Failover(): err = doFailover() default: - if s.HA { + if s.ha { err = fmt.Errorf("ha scheduler exiting instead of failing over") } else { log.Infof("exiting scheduler") @@ -638,22 +638,22 @@ func newEtcd(etcdConfigFile string, etcdServerList []string) (client tools.EtcdC func (s *SchedulerServer) bootstrap(hks hyperkube.Interface, sc *schedcfg.Config) (*ha.SchedulerProcess, ha.DriverFactory, tools.EtcdClient, *uid.UID) { - s.FrameworkName = strings.TrimSpace(s.FrameworkName) - if s.FrameworkName == "" { + s.frameworkName = strings.TrimSpace(s.frameworkName) + if s.frameworkName == "" { log.Fatalf("framework-name must be a non-empty string") } - s.FrameworkWebURI = strings.TrimSpace(s.FrameworkWebURI) + s.frameworkWebURI = strings.TrimSpace(s.frameworkWebURI) metrics.Register() runtime.Register() s.mux.Handle("/metrics", prometheus.Handler()) healthz.InstallHandler(s.mux) - if (s.EtcdConfigFile != "" && len(s.EtcdServerList) != 0) || (s.EtcdConfigFile == "" && len(s.EtcdServerList) == 0) { + if (s.etcdConfigFile != "" && len(s.etcdServerList) != 0) || (s.etcdConfigFile == "" && len(s.etcdServerList) == 0) { log.Fatalf("specify either --etcd-servers or --etcd-config") } - if len(s.APIServerList) < 1 { + if len(s.apiServerList) < 1 { log.Fatal("No api servers specified.") } @@ -663,9 +663,9 @@ func (s *SchedulerServer) bootstrap(hks hyperkube.Interface, sc *schedcfg.Config } s.client = client - if s.ReconcileCooldown < defaultReconcileCooldown { - s.ReconcileCooldown = defaultReconcileCooldown - log.Warningf("user-specified reconcile cooldown too small, defaulting to %v", s.ReconcileCooldown) + if s.reconcileCooldown < defaultReconcileCooldown { + s.reconcileCooldown = defaultReconcileCooldown + log.Warningf("user-specified reconcile cooldown too small, defaulting to %v", s.reconcileCooldown) } executor, eid, err := s.prepareExecutorInfo(hks) @@ -677,24 +677,24 @@ func (s *SchedulerServer) bootstrap(hks hyperkube.Interface, sc *schedcfg.Config // (1) the generic config store is available for the FrameworkId storage // (2) the generic master election is provided by the apiserver // Compare docs/proposals/high-availability.md - etcdClient, err := newEtcd(s.EtcdConfigFile, s.EtcdServerList) + etcdClient, err := newEtcd(s.etcdConfigFile, s.etcdServerList) if err != nil { log.Fatalf("misconfigured etcd: %v", err) } as := podschedulers.NewAllocationStrategy( podtask.NewDefaultPredicate( - s.DefaultContainerCPULimit, - s.DefaultContainerMemLimit, + s.defaultContainerCPULimit, + s.defaultContainerMemLimit, ), podtask.NewDefaultProcurement( - s.DefaultContainerCPULimit, - s.DefaultContainerMemLimit, + s.defaultContainerCPULimit, + s.defaultContainerMemLimit, ), ) // downgrade allocation strategy if user disables "account-for-pod-resources" - if !s.AccountForPodResources { + if !s.accountForPodResources { as = podschedulers.NewAllocationStrategy( podtask.DefaultMinimalPredicate, podtask.DefaultMinimalProcurement) @@ -723,20 +723,20 @@ func (s *SchedulerServer) bootstrap(hks hyperkube.Interface, sc *schedcfg.Config Executor: executor, PodScheduler: fcfs, Client: client, - FailoverTimeout: s.FailoverTimeout, - ReconcileInterval: s.ReconcileInterval, - ReconcileCooldown: s.ReconcileCooldown, + FailoverTimeout: s.failoverTimeout, + ReconcileInterval: s.reconcileInterval, + ReconcileCooldown: s.reconcileCooldown, LookupNode: lookupNode, StoreFrameworkId: func(id string) { // TODO(jdef): port FrameworkId store to generic Kubernetes config store as soon as available - _, err := etcdClient.Set(meta.FrameworkIDKey, id, uint64(s.FailoverTimeout)) + _, err := etcdClient.Set(meta.FrameworkIDKey, id, uint64(s.failoverTimeout)) if err != nil { log.Errorf("failed to renew frameworkId TTL: %v", err) } }, }) - masterUri := s.MesosMaster + masterUri := s.mesosMaster info, cred, err := s.buildFrameworkInfo() if err != nil { log.Fatalf("Misconfigured mesos framework: %v", err) @@ -748,12 +748,12 @@ func (s *SchedulerServer) bootstrap(hks hyperkube.Interface, sc *schedcfg.Config Framework: info, Master: masterUri, Credential: cred, - BindingAddress: s.Address, - BindingPort: uint16(s.DriverPort), - HostnameOverride: s.HostnameOverride, + BindingAddress: s.address, + BindingPort: uint16(s.driverPort), + HostnameOverride: s.hostnameOverride, WithAuthContext: func(ctx context.Context) context.Context { - ctx = auth.WithLoginProvider(ctx, s.MesosAuthProvider) - ctx = sasl.WithBindingAddress(ctx, s.Address) + ctx = auth.WithLoginProvider(ctx, s.mesosAuthProvider) + ctx = sasl.WithBindingAddress(ctx, s.address) return ctx }, } @@ -813,14 +813,14 @@ func (s *SchedulerServer) failover(driver bindings.SchedulerDriver, hks hyperkub args = append(args, fmt.Sprintf("--%s=%s", flag.Name, flag.Value.String())) } }) - if !s.Graceful { + if !s.graceful { args = append(args, "--graceful") } - if len(s.APIServerList) > 0 { - args = append(args, "--api-servers="+strings.Join(s.APIServerList, ",")) + if len(s.apiServerList) > 0 { + args = append(args, "--api-servers="+strings.Join(s.apiServerList, ",")) } - if len(s.EtcdServerList) > 0 { - args = append(args, "--etcd-servers="+strings.Join(s.EtcdServerList, ",")) + if len(s.etcdServerList) > 0 { + args = append(args, "--etcd-servers="+strings.Join(s.etcdServerList, ",")) } args = append(args, flags.Args()...) @@ -853,30 +853,30 @@ func (s *SchedulerServer) buildFrameworkInfo() (info *mesos.FrameworkInfo, cred } log.V(2).Infof("Framework configured with mesos user %v", username) info = &mesos.FrameworkInfo{ - Name: proto.String(s.FrameworkName), + Name: proto.String(s.frameworkName), User: proto.String(username), - Checkpoint: proto.Bool(s.Checkpoint), + Checkpoint: proto.Bool(s.checkpoint), } - if s.FrameworkWebURI != "" { - info.WebuiUrl = proto.String(s.FrameworkWebURI) + if s.frameworkWebURI != "" { + info.WebuiUrl = proto.String(s.frameworkWebURI) } - if s.FailoverTimeout > 0 { - info.FailoverTimeout = proto.Float64(s.FailoverTimeout) + if s.failoverTimeout > 0 { + info.FailoverTimeout = proto.Float64(s.failoverTimeout) } - if s.MesosRole != "" { - info.Role = proto.String(s.MesosRole) + if s.mesosRole != "" { + info.Role = proto.String(s.mesosRole) } - if s.MesosAuthPrincipal != "" { - info.Principal = proto.String(s.MesosAuthPrincipal) - if s.MesosAuthSecretFile == "" { + if s.mesosAuthPrincipal != "" { + info.Principal = proto.String(s.mesosAuthPrincipal) + if s.mesosAuthSecretFile == "" { return nil, nil, errors.New("authentication principal specified without the required credentials file") } - secret, err := ioutil.ReadFile(s.MesosAuthSecretFile) + secret, err := ioutil.ReadFile(s.mesosAuthSecretFile) if err != nil { return nil, nil, err } cred = &mesos.Credential{ - Principal: proto.String(s.MesosAuthPrincipal), + Principal: proto.String(s.mesosAuthPrincipal), Secret: secret, } } @@ -884,7 +884,7 @@ func (s *SchedulerServer) buildFrameworkInfo() (info *mesos.FrameworkInfo, cred } func (s *SchedulerServer) fetchFrameworkID(client tools.EtcdClient) (*mesos.FrameworkID, error) { - if s.FailoverTimeout > 0 { + if s.failoverTimeout > 0 { if response, err := client.Get(meta.FrameworkIDKey, false, false); err != nil { if !etcdstorage.IsEtcdNotFound(err) { return nil, fmt.Errorf("unexpected failure attempting to load framework ID from etcd: %v", err) @@ -907,7 +907,7 @@ func (s *SchedulerServer) fetchFrameworkID(client tools.EtcdClient) (*mesos.Fram } func (s *SchedulerServer) getUsername() (username string, err error) { - username = s.MesosUser + username = s.mesosUser if username == "" { if u, err := user.Current(); err == nil { username = u.Username diff --git a/contrib/mesos/pkg/scheduler/service/service_test.go b/contrib/mesos/pkg/scheduler/service/service_test.go index 24174b1e32f..26eaa5a63d5 100644 --- a/contrib/mesos/pkg/scheduler/service/service_test.go +++ b/contrib/mesos/pkg/scheduler/service/service_test.go @@ -121,8 +121,8 @@ func Test_DefaultResourceLimits(t *testing.T) { assert := assert.New(t) s := NewSchedulerServer() - assert.Equal(s.DefaultContainerCPULimit, mresource.DefaultDefaultContainerCPULimit) - assert.Equal(s.DefaultContainerMemLimit, mresource.DefaultDefaultContainerMemLimit) + assert.Equal(s.defaultContainerCPULimit, mresource.DefaultDefaultContainerCPULimit) + assert.Equal(s.defaultContainerMemLimit, mresource.DefaultDefaultContainerMemLimit) } func Test_StaticPods(t *testing.T) {