Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarpicas committed Jun 6, 2023
2 parents f9a158b + a6be106 commit c955115
Show file tree
Hide file tree
Showing 214 changed files with 16,397 additions and 1,845 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/bugs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ on:
push:
branches:
- 'bug/**'
- 'bugs/**'
- 'task/**'
- 'tasks/**'
pull_request:
branches:
- 'bug/**'
- 'bugs/**'
- 'task/**'
- 'tasks/**'

env:
PROTOCVERSION: 3.17.3
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ on:
push:
branches:
- 'check/**'
- 'experimental/**'
- 'feature/**'
- 'tasks/**'
- 'pr/**'
pull_request:
branches:
- 'experimental/**'
- 'feature/**'
- 'tasks/**'
- 'check/**'
- 'pr/**'

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/go-generics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- master
- develop
- hotfixes
- 'release/**'
- 'review/**'
- 'pr/**'
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
- master
- develop
- hotfixes
- 'experimental/**'
- 'feature/**'
- 'tasks/**'
- 'release/**'
- 'review/**'
- 'pr/**'
Expand All @@ -14,6 +17,9 @@ on:
- master
- develop
- hotfixes
- 'experimental/**'
- 'feature/**'
- 'tasks/**'
- 'release/**'
- 'review/**'
- 'pr/**'
Expand Down
12 changes: 7 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ COVEREXECS=cli/safescale/safescale-cover$(EXT) cli/safescaled/safescaled-cover$(
STRINGER := golang.org/x/tools/cmd/stringer
PROTOC := google.golang.org/protobuf
PROTOBUF := google.golang.org/protobuf/protoc-gen-go
PROTOVER := v1.28.1
PROTOVER := v1.30.0

# Build tools
CONVEY := github.com/smartystreets/goconvey
Expand Down Expand Up @@ -48,7 +48,7 @@ export BUILD_TAGS
TEST_COVERAGE_ARGS =
export TEST_COVERAGE_ARGS

all: logclean ground getdevdeps modclean sdk generate lib mintest cli minimock err vet semgrep style metalint
all: logclean ground getdevdeps modclean sdk generate lib mintest cli minimock err vet style metalint
@printf "%b" "$(OK_COLOR)$(OK_STRING) Build, branch $$(git rev-parse --abbrev-ref HEAD) SUCCESSFUL $(NO_COLOR)\n";
@git ls-tree --full-tree --name-only -r HEAD | grep \.go | xargs $(MD5) 2>/dev/null > sums.log || true
@git ls-tree --full-tree --name-only -r HEAD | grep \.sh | xargs $(MD5) 2>/dev/null >> sums.log || true
Expand All @@ -63,13 +63,13 @@ with-race:
@$(eval RACE_CHECK_TEST = "-race")
@$(eval RACE_CHECK = "-race")

ci: logclean ground getdevdeps mod sdk generate with-race lib cli minimock err vet with-soft semgrep style metalint
ci: logclean ground getdevdeps mod sdk generate with-race lib cli minimock err vet with-soft style metalint
@printf "%b" "$(OK_COLOR)$(OK_STRING) Build, branch $$(git rev-parse --abbrev-ref HEAD) SUCCESSFUL $(NO_COLOR)\n";

rawci: logclean ground getdevdeps mod sdk generate with-race lib cli minimock
@printf "%b" "$(OK_COLOR)$(OK_STRING) Build, branch $$(git rev-parse --abbrev-ref HEAD) SUCCESSFUL $(NO_COLOR)\n";

allcover: logclean ground getdevdeps mod sdk generate lib cli minimock err vet semgrep style metalint
allcover: logclean ground getdevdeps mod sdk generate lib cli minimock err vet style metalint
@(cd cli/safescale && $(MAKE) $(@))
@(cd cli/safescaled && $(MAKE) $(@))
@git ls-tree --full-tree --name-only -r HEAD | grep \.go | xargs $(MD5) 2>/dev/null > sums.log || true
Expand All @@ -79,7 +79,7 @@ allcover: logclean ground getdevdeps mod sdk generate lib cli minimock err vet s
version:
@printf "%b" "$(VERSION)-$$(git rev-parse --abbrev-ref HEAD | tr \"/\" \"_\")";

release: logclean ground getdevdeps mod releasetags tunnel sdk generate lib cli test minimock err vet semgrep style metalint releasearchive
release: logclean ground getdevdeps mod releasetags tunnel sdk generate lib cli test minimock err vet style metalint releasearchive
@printf "%b" "$(OK_COLOR)$(OK_STRING) Build for release, branch $$(git rev-parse --abbrev-ref HEAD) SUCCESSFUL $(NO_COLOR)\n";
@git ls-tree --full-tree --name-only -r HEAD | grep \.go | xargs $(MD5) 2>/dev/null > sums.log || true
@git ls-tree --full-tree --name-only -r HEAD | grep \.sh | xargs $(MD5) 2>/dev/null >> sums.log || true
Expand Down Expand Up @@ -512,6 +512,7 @@ mintest: begin
@$(GO) test $(RACE_CHECK_TEST) $(GO_TEST_TAGS) -timeout 480s -v ./lib/utils/... -parallel 8 $(TEST_COVERAGE_ARGS) 2>&1 > test_results.log || true
@$(CP) ./cover.out ./cover.tmp 2>/dev/null || true
@$(GO) test $(RACE_CHECK_TEST) $(GO_TEST_TAGS) -timeout 480s -v ./lib/backend/resources/... -parallel 8 $(TEST_COVERAGE_ARGS) 2>&1 >> test_results.log || true
@$(GO) test $(RACE_CHECK_TEST) $(GO_TEST_TAGS) -timeout 480s -v ./lib/backend/iaas/... -parallel 8 $(TEST_COVERAGE_ARGS) 2>&1 >> test_results.log || true
@$(TAIL) -n +2 ./cover.out >> ./cover.tmp 2>/dev/null || true
@$(MV) ./cover.tmp ./cover.out 2>/dev/null || true
@if [ -s ./test_results.log ] && grep -e '--- FAIL' -e 'panic: test timed out' ./test_results.log 2>&1 > /dev/null; then printf "%b" "$(ERROR_COLOR)$(ERROR_STRING) minimal tests FAILED ! Take a look at ./test_results.log $(NO_COLOR)\n";else printf "%b" "$(OK_COLOR)$(OK_STRING) CONGRATS. TESTS PASSED ! $(NO_COLOR)\n";fi;
Expand All @@ -532,6 +533,7 @@ test: begin coverdeps # Run unit tests
@$(GO) test $(RACE_CHECK_TEST) $(GO_TEST_TAGS) -timeout 480s -v ./lib/utils/... -parallel 8 $(TEST_COVERAGE_ARGS) 2>&1 > test_results.log || true
@$(CP) ./cover.out ./cover.tmp 2>/dev/null || true
@$(GO) test $(RACE_CHECK_TEST) $(GO_TEST_TAGS) -timeout 480s -v ./lib/backend/resources/... -parallel 8 $(TEST_COVERAGE_ARGS) 2>&1 >> test_results.log || true
@$(GO) test $(RACE_CHECK_TEST) $(GO_TEST_TAGS) -timeout 480s -v ./lib/backend/iaas/... -parallel 8 $(TEST_COVERAGE_ARGS) 2>&1 >> test_results.log || true
@$(TAIL) -n +2 ./cover.out >> ./cover.tmp 2>/dev/null || true
@$(MV) ./cover.tmp ./cover.out 2>/dev/null || true
@go2xunit -input test_results.log -output xunit_tests.xml || true
Expand Down
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ SafeScale offers an APIs and a CLI tools to deploy versatile computing clusters
- SafeScale Infra to manage Cloud infrastructure (IaaS - Infrastructure as a Service)
- SafeScale Platform to manage Cloud computing platforms (PaaS - Platform as a Service)

![SafeScale](doc/img/SafeScale.png "SafeScale")

### SafeScale Infra

SafeScale Infra offers an API to completely abstract the IaaS services offered by Cloud platforms providers.
Expand All @@ -45,8 +43,6 @@ It allows to:
- Create / Destroy clusters
- Add / Remove "features" (software components) on hosts and clusters

![SafeScale Infra](doc/img/SafeScale_Infra.png "SafeScale Infra")

SafeScale Infra provides a complete abstraction overlay over underlying IaaS APIs to mask their heterogeneity.

### SafeScale Platform
Expand Down Expand Up @@ -137,6 +133,7 @@ SafeScale is currently under active development and does not yet offer all the a
- AWS
- GCP (Google Cloud Platform)
- Outscale
- Azure (Work In Progress)


## Contributing
Expand Down
12 changes: 5 additions & 7 deletions cli/safescale/commands/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,10 @@ func outputClusterConfig(cluster *protocol.ClusterResponse) (map[string]interfac
// convertToMap converts clusterInstance to its equivalent in map[string]interface{},
// with fields converted to string and used as keys
func convertToMap(c *protocol.ClusterResponse) (map[string]interface{}, fail.Error) {
// identity := c.Identity(concurrency.RootTask()

result := map[string]interface{}{
"name": c.GetIdentity().GetName(),
"flavor": c.GetIdentity().GetFlavor(),
"flavor_label": clusterflavor.Enum(c.GetIdentity().GetFlavor()).String(),
"name": c.GetIdentity().GetName(),
"flavor": c.GetIdentity().GetFlavor(),
// "flavor_label": clusterflavor.Enum(c.GetIdentity().GetFlavor()).String(),
"complexity": c.GetIdentity().GetComplexity(),
"complexity_label": clustercomplexity.Enum(c.GetIdentity().GetComplexity()).String(),
"admin_login": "cladm",
Expand All @@ -321,7 +319,7 @@ func convertToMap(c *protocol.ClusterResponse) (map[string]interface{}, fail.Err
result["subnet_id"] = c.Network.SubnetId
result["cidr"] = c.Network.Cidr
result["default_route_ip"] = c.Network.DefaultRouteIp
result["primary_gateway_ip"] = c.Network.GatewayIp
result["primary_gateway_ip"] = c.Network.GatewayIp // FIXME: Maybe this should be DefaultRouteIp
result["endpoint_ip"] = c.Network.EndpointIp
result["primary_public_ip"] = c.Network.EndpointIp
if sgwpubip = c.Network.SecondaryPublicIp; sgwpubip != "" {
Expand Down Expand Up @@ -381,7 +379,7 @@ var clusterCreateCommand = cli.Command{
},
cli.StringFlag{
Name: "flavor, F",
Value: "K8S",
Value: "BOH",
Usage: `Defines the type of the cluster; can be BOH, K8S
Default sizing for each cluster type is:
BOH: gws(cpu=[2-4], ram=[7-16], disk=[50]), masters(cpu=[4-8], ram=[15-32], disk=[100]), nodes(cpu=[2-4], ram=[15-32], disk=[80])
Expand Down
6 changes: 4 additions & 2 deletions cli/safescale/commands/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,7 @@ var networkSecurityGroupRuleAdd = cli.Command{
}()
}

if err := ClientSession.SecurityGroup.AddRule(c.Args().Get(1), rule, 0); err != nil {
if err := ClientSession.SecurityGroup.AddRule(c.Args().Get(0), c.Args().Get(1), rule, 0); err != nil {
err = fail.FromGRPCStatus(err)
return clitools.FailureResponse(clitools.ExitOnRPC(strprocess.Capitalize(client.DecorateTimeoutError(err, "addition of a rule to a security-group", true).Error())))
}
Expand Down Expand Up @@ -1351,7 +1351,9 @@ var subnetInspect = cli.Command{
return err
}

mapped["state_label"] = subnetstate.Enum(mapped["state"].(float64)).String()
if _, ok := mapped["state"]; ok {
mapped["state_label"] = subnetstate.Enum(mapped["state"].(float64)).String()
}
mapped["gateway-failover"] = false
if gws, ok := mapped["gateways"]; ok {
if ok {
Expand Down
56 changes: 52 additions & 4 deletions cli/safescaled/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package main

import (
"fmt"
"github.com/CS-SI/SafeScale/v22/lib/utils/valid"
"net"
"net/http"
"os"
Expand All @@ -30,6 +29,8 @@ import (
"syscall"
"time"

"github.com/CS-SI/SafeScale/v22/lib/utils/valid"

"github.com/oscarpicas/covertool/pkg/exit"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
Expand All @@ -52,8 +53,9 @@ import (
var profileCloseFunc = func() {}

const (
defaultDaemonHost string = "localhost" // By default, safescaled only listen on localhost
defaultDaemonPort string = "50051"
defaultDaemonHost string = "localhost" // By default, safescaled only listen on localhost
defaultDaemonPort string = "50051"
defaultDaemonWebPort string = "50052"
)

func cleanup(onAbort bool) {
Expand Down Expand Up @@ -118,7 +120,8 @@ func work(c *cli.Context) {
}

go func() {
nl, err := net.Listen("tcp", ":50052")
webPort := assembleListenWebString(c)
nl, err := net.Listen("tcp", webPort)
if err != nil {
logrus.Fatalf("failed to listen: %v", err)
}
Expand Down Expand Up @@ -233,6 +236,47 @@ func createGrpcServer() *grpc.Server {
}

// assembleListenString constructs the listen string we will use in net.Listen()
func assembleListenWebString(c *cli.Context) string {
// Get listen from parameters
listen := c.String("web")
if listen == "" {
listen = os.Getenv("SAFESCALED_WEB_LISTEN")
}
if listen != "" {
// Validate port part of the content of listen...
parts := strings.Split(listen, ":")
switch len(parts) {
case 1:
listen = parts[0] + ":" + defaultDaemonWebPort
case 2:
num, err := strconv.Atoi(parts[1])
if err != nil || num <= 0 {
logrus.Warnf("Parameter 'web' content is invalid (port cannot be '%s'): ignored.", parts[1])
}
default:
logrus.Warnf("Parameter 'web' content is invalid, ignored.")
}
}
// if listen is empty, get the port from env
if listen == "" {
if port := os.Getenv("SAFESCALED_WEB_PORT"); port != "" {
num, err := strconv.Atoi(port)
if err != nil || num <= 0 {
logrus.Warnf("Environment variable 'SAFESCALED_WEB_PORT' contains invalid content ('%s'): ignored.", port)
} else {
listen = defaultDaemonHost + ":" + port
}
}

// At last, if listen is empty, build it from defaults
if listen == "" {
listen = defaultDaemonHost + ":" + defaultDaemonWebPort
}
}

return listen
}

func assembleListenString(c *cli.Context) string {
// Get listen from parameters
listen := c.String("listen")
Expand Down Expand Up @@ -315,6 +359,10 @@ func main() {
Name: "listen, l",
Usage: "Listen on specified port `IP:PORT` (default: localhost:50051)",
},
&cli.StringFlag{
Name: "web, w",
Usage: "Listen on specified port for GRPC Web `IP:PORT` (default: localhost:50052)",
},
}

app.Before = func(c *cli.Context) (ferr error) {
Expand Down
2 changes: 1 addition & 1 deletion common.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=22.11.6
VERSION=22.11.9
export VERSION

ifeq ($(MAKE_LEVEL),)
Expand Down
Loading

0 comments on commit c955115

Please sign in to comment.