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
38 changes: 35 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,46 @@
# See the License for the specific language governing permissions and
# limitations under the License.

all: flame-scheduler

BIN_DIR=_output/bin
RELEASE_DIR=_output/release


all: flame-scheduler \
flame-controller-manager \
flame-session-manager \
flame-installer \
flame-webhook-manager \
flame-api-gateway

init:
mkdir -p ${BIN_DIR}
mkdir -p ${RELEASE_DIR}

grpc-pkg: init
go get google.golang.org/protobuf/cmd/protoc-gen-go@v1.26
go get google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.1

grpc-gen: grpc-pkg
protoc --plugin=protoc-gen-go=${GOPATH}/bin/protoc-gen-go \
-I${GOPATH}/src/ \
--go_out=${GOPATH}/src/xflops.cn/flame \
--go-grpc_out=${GOPATH}/src/xflops.cn/flame/ \
xflops.cn/flame/protos/session.proto

flame-api-gateway: init grpc-gen
go build -ldflags ${LD_FLAGS} -o=${BIN_DIR}/flame-api-gateway ./cmd/api-gateway

flame-scheduler: init
go build -ldflags ${LD_FLAGS} -o=${BIN_DIR}/flame-scheduler ./cmd/scheduler
go build -ldflags ${LD_FLAGS} -o=${BIN_DIR}/flame-scheduler ./cmd/scheduler

flame-controller-manager: init
go build -ldflags ${LD_FLAGS} -o=${BIN_DIR}/flame-controller-manager ./cmd/controller-manager

flame-session-manager: init grpc-gen
go build -ldflags ${LD_FLAGS} -o=${BIN_DIR}/flame-session-manager ./cmd/session-manager

flame-installer: init
go build -ldflags ${LD_FLAGS} -o=${BIN_DIR}/flame-installer ./cmd/installer

flame-webhook-manager: init
go build -ldflags ${LD_FLAGS} -o=${BIN_DIR}/flame-webhook-manager ./cmd/webhook-manager
17 changes: 17 additions & 0 deletions cmd/api-gateway/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
Copyright 2022 The Flame Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main

func main() {
panic("not implementaed!")
}
45 changes: 45 additions & 0 deletions cmd/cli/fping/client/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
Copyright 2022 The Flame Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

import (
"fmt"
"time"

"xflops.cn/flame/sdk/golang"
)

func main() {
conn := golang.NewConnection()
defer golang.CloseConnection(conn)

ssn := conn.NewSession()
defer conn.CloseSession(ssn)

before := time.Now()
task, err := ssn.SendInput([]byte("k82cn"))
if err != nil {
panic(err)
}
fmt.Printf("Task <%s/%s> was created\n", task.SSNID, task.ID)
output, err := ssn.RecvOutput(task)
if err != nil {
panic(err)
}
after := time.Now()

rtt := after.Sub(before).Milliseconds()

fmt.Printf("Task output is: %s (%d ms)\n", output.Output, rtt)
}
69 changes: 69 additions & 0 deletions cmd/cli/fping/server/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
Copyright 2022 The Flame Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

import (
"fmt"
"os"

"k8s.io/klog/v2"

"xflops.cn/flame/pkg/grpcs"
"xflops.cn/flame/sdk/golang"
)

type MyService struct {
}

func (m *MyService) OnRegistered() {
fmt.Println("OnRegistered")
}

func (m *MyService) OnUnregistered() {
fmt.Println("OnUnregistered")
}

func (m *MyService) OnSessionBound(*grpcs.Session) {
fmt.Println("OnSessionBound")
}

func (m *MyService) OnSessionUnbound(*grpcs.Session) {
fmt.Println("OnSessionUnBound")
}

func (m *MyService) OnTaskInvoke(input *grpcs.TaskInput) *grpcs.TaskOutput {
fmt.Println("OnTaskInvoke")

output := &grpcs.TaskOutput{
TaskID: input.TaskID,
SessionID: input.SessionID,
Output: fmt.Sprintf("Hello %s!", input.Input),
}

return output
}

func main() {
klog.InitFlags(nil)

svcMgr := &golang.ServiceManager{Service: &MyService{}}

exeName, err := os.Hostname()
if err != nil {
klog.Warningln("Failed to get hostname for executor")
exeName = "localhost"
}

svcMgr.Run(exeName)
}
64 changes: 64 additions & 0 deletions cmd/controller-manager/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
Copyright 2022 The Flame Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main

import (
"fmt"
"os"
"runtime"
"time"

"github.com/spf13/pflag"
_ "go.uber.org/automaxprocs"

"k8s.io/apimachinery/pkg/util/wait"
cliflag "k8s.io/component-base/cli/flag"
"k8s.io/klog"

_ "volcano.sh/volcano/pkg/controllers/garbagecollector"
_ "volcano.sh/volcano/pkg/controllers/job"
_ "volcano.sh/volcano/pkg/controllers/podgroup"
_ "volcano.sh/volcano/pkg/controllers/queue"

"volcano.sh/volcano/cmd/controller-manager/app"
"volcano.sh/volcano/cmd/controller-manager/app/options"
"volcano.sh/volcano/pkg/version"
)

var logFlushFreq = pflag.Duration("log-flush-frequency", 5*time.Second, "Maximum number of seconds between log flushes")

func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
klog.InitFlags(nil)

s := options.NewServerOption()
s.AddFlags(pflag.CommandLine)

cliflag.InitFlags()

if s.PrintVersion {
version.PrintVersionAndExit()
}
if err := s.CheckOptionOrDie(); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
// The default klog flush interval is 30 seconds, which is frighteningly long.
go wait.Until(klog.Flush, *logFlushFreq, wait.NeverStop)
defer klog.Flush()

if err := app.Run(s); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
}
17 changes: 17 additions & 0 deletions cmd/installer/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
Copyright 2022 The Flame Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main

func main() {
panic("not implementaed!")
}
26 changes: 26 additions & 0 deletions cmd/session-manager/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
Copyright 2022 The Flame Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

import (
"k8s.io/klog/v2"

manager "xflops.cn/flame/pkg/session-manager"
)

func main() {
klog.InitFlags(nil)

manager.Run()
}
66 changes: 66 additions & 0 deletions cmd/webhook-manager/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
Copyright 2022 The Flame Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main

import (
"fmt"
"os"
"runtime"
"time"

"github.com/spf13/pflag"
_ "go.uber.org/automaxprocs"

"k8s.io/apimachinery/pkg/util/wait"
cliflag "k8s.io/component-base/cli/flag"
"k8s.io/klog"

"volcano.sh/volcano/cmd/webhook-manager/app"
"volcano.sh/volcano/cmd/webhook-manager/app/options"

_ "volcano.sh/volcano/pkg/webhooks/admission/jobs/mutate"
_ "volcano.sh/volcano/pkg/webhooks/admission/jobs/validate"
_ "volcano.sh/volcano/pkg/webhooks/admission/podgroups/mutate"
_ "volcano.sh/volcano/pkg/webhooks/admission/pods/mutate"
_ "volcano.sh/volcano/pkg/webhooks/admission/pods/validate"
_ "volcano.sh/volcano/pkg/webhooks/admission/queues/mutate"
_ "volcano.sh/volcano/pkg/webhooks/admission/queues/validate"
)

var logFlushFreq = pflag.Duration("log-flush-frequency", 5*time.Second, "Maximum number of seconds between log flushes")

func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
klog.InitFlags(nil)

config := options.NewConfig()
config.AddFlags(pflag.CommandLine)

cliflag.InitFlags()

go wait.Until(klog.Flush, *logFlushFreq, wait.NeverStop)
defer klog.Flush()

if err := config.CheckPortOrDie(); err != nil {
klog.Fatalf("Configured port is invalid: %v", err)
}

if err := config.ParseCAFiles(nil); err != nil {
klog.Fatalf("Failed to parse CA file: %v", err)
}

if err := app.Run(config); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
}
Loading