Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
Signed-off-by: Yee Hing Tong <[email protected]>
  • Loading branch information
wild-endeavor committed Dec 28, 2023
1 parent d896aa7 commit 7ee22a0
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 52 deletions.
14 changes: 6 additions & 8 deletions charts/flyte-sandbox/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ A Helm chart for the Flyte local sandbox
| file://../flyte-binary | flyte-binary | v0.1.10 |
| https://charts.bitnami.com/bitnami | minio | 12.1.1 |
| https://charts.bitnami.com/bitnami | postgresql | 12.1.9 |
| https://charts.bitnami.com/bitnami | redis | 18.0.1 |
| https://helm.twun.io/ | docker-registry | 2.2.2 |
| https://kubernetes.github.io/dashboard/ | kubernetes-dashboard | 6.0.0 |

Expand All @@ -28,6 +27,12 @@ A Helm chart for the Flyte local sandbox
| flyte-binary.clusterResourceTemplates.inlineConfigMap | string | `"{{ include \"flyte-sandbox.clusterResourceTemplates.inlineConfigMap\" . }}"` | |
| flyte-binary.configuration.database.host | string | `"{{ printf \"%s-postgresql\" .Release.Name | trunc 63 | trimSuffix \"-\" }}"` | |
| flyte-binary.configuration.database.password | string | `"postgres"` | |
| flyte-binary.configuration.inline.artifacts.host | string | `"localhost"` | |
| flyte-binary.configuration.inline.artifacts.insecure | bool | `true` | |
| flyte-binary.configuration.inline.artifacts.port | int | `50051` | |
| flyte-binary.configuration.inline.cloudEvents.cloudEventVersion | string | `"v2"` | |
| flyte-binary.configuration.inline.cloudEvents.enable | bool | `true` | |
| flyte-binary.configuration.inline.cloudEvents.type | string | `"sandbox"` | |
| flyte-binary.configuration.inline.plugins.k8s.default-env-vars[0].FLYTE_AWS_ENDPOINT | string | `"http://{{ printf \"%s-minio\" .Release.Name | trunc 63 | trimSuffix \"-\" }}.{{ .Release.Namespace }}:9000"` | |
| flyte-binary.configuration.inline.plugins.k8s.default-env-vars[1].FLYTE_AWS_ACCESS_KEY_ID | string | `"minio"` | |
| flyte-binary.configuration.inline.plugins.k8s.default-env-vars[2].FLYTE_AWS_SECRET_ACCESS_KEY | string | `"miniostorage"` | |
Expand Down Expand Up @@ -101,13 +106,6 @@ A Helm chart for the Flyte local sandbox
| postgresql.volumePermissions.enabled | bool | `true` | |
| postgresql.volumePermissions.image.pullPolicy | string | `"Never"` | |
| postgresql.volumePermissions.image.tag | string | `"sandbox"` | |
| redis.auth.enabled | bool | `false` | |
| redis.enabled | bool | `true` | |
| redis.image.pullPolicy | string | `"Never"` | |
| redis.image.tag | string | `"sandbox"` | |
| redis.master.service.nodePorts.redis | int | `30004` | |
| redis.master.service.type | string | `"NodePort"` | |
| redis.replica.replicaCount | int | `0` | |
| sandbox.buildkit.enabled | bool | `true` | |
| sandbox.buildkit.image.pullPolicy | string | `"Never"` | |
| sandbox.buildkit.image.repository | string | `"moby/buildkit"` | |
Expand Down
3 changes: 1 addition & 2 deletions flyteartifacts/cmd/shared/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@ func launchHttpServer(ctx context.Context, cfg *sharedCfg.ServerConfiguration, h
// getHTTPHandler gets the http handler for the configured security options
func getHTTPHandler(httpServer *http.ServeMux, _ sharedCfg.ServerSecurityOptions) http.Handler {
// not really used yet (reserved for admin)
var handler http.Handler
handler = httpServer
var handler http.Handler = httpServer
return handler
}

Expand Down
19 changes: 0 additions & 19 deletions flyteartifacts/pkg/configuration/shared/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (
"github.com/flyteorg/flyte/flytestdlib/config"
)

const sharedServer = "sharedServer"

type Metrics struct {
MetricsScope string `json:"metricsScope" pflag:",MetricsScope"`
Port config.Port `json:"port" pflag:",Profile port to start listen for pprof and metric handlers on."`
Expand Down Expand Up @@ -36,23 +34,6 @@ type ServerConfiguration struct {
MaxConcurrentStreams int `json:"maxConcurrentStreams" pflag:",Limit on the number of concurrent streams to each ServerTransport."`
}

var sharedServerConfiguration = ServerConfiguration{
Metrics: Metrics{
MetricsScope: "service:",
Port: config.Port{Port: 10254},
ProfilerEnabled: false,
},
Port: config.Port{Port: 8089},
HttpPort: config.Port{Port: 8088},
GrpcMaxResponseStatusBytes: 320000,
GrpcServerReflection: false,
Security: ServerSecurityOptions{
Secure: false,
UseAuth: false,
},
MaxConcurrentStreams: 100,
}

func (s ServerConfiguration) GetGrpcHostAddress() string {
return fmt.Sprintf("0.0.0.0:%s", s.Port.String())
}
Expand Down
2 changes: 1 addition & 1 deletion flyteartifacts/pkg/db/gorm_transformers.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func PartitionsIdlToHstore(idlPartitions *core.Partitions) pgtype.Hstore {
}

func HstoreToIdlPartitions(hs pgtype.Hstore) *core.Partitions {
if hs == nil || len(hs) == 0 {
if len(hs) == 0 {
return nil
}
m := make(map[string]*core.LabelValue, len(hs))
Expand Down
6 changes: 3 additions & 3 deletions flyteartifacts/pkg/db/querying_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ func TestQuery3_Find(t *testing.T) {

res, ct, err := rds.SearchArtifacts(ctx, s)
assert.NoError(t, err)

fmt.Println(res, ct)
assert.Equal(t, "", ct)

s = artifact.SearchArtifactsRequest{
ArtifactKey: &core.ArtifactKey{
Expand All @@ -153,8 +152,9 @@ func TestQuery3_Find(t *testing.T) {
},
}

res, ct, err = rds.SearchArtifacts(ctx, s)
_, ct, err = rds.SearchArtifacts(ctx, s)
assert.NoError(t, err)
assert.Equal(t, "", ct)

s = artifact.SearchArtifactsRequest{
ArtifactKey: &core.ArtifactKey{
Expand Down
2 changes: 1 addition & 1 deletion flyteartifacts/pkg/db/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ func (r *RDSStorage) GetTriggersByArtifactKey(ctx context.Context, key core.Arti
return nil, err
}
logger.Debugf(ctx, "Found trigger keys: %+v for artifact key %v", triggerKey, key)
if triggerKey == nil || len(triggerKey) == 0 {
if len(triggerKey) == 0 {
logger.Infof(ctx, "No triggers found for artifact key %v", key)
return nil, nil
}
Expand Down
3 changes: 2 additions & 1 deletion flyteartifacts/pkg/lib/url_parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ func TestURLParseNameWithSlashes(t *testing.T) {
assert.Equal(t, "name/with/slashes", artifactID.ArtifactKey.Name)
assert.Equal(t, "", tag)

artifactID, tag, err = ParseFlyteURL("flyte://av0.1/project/domain/name/with/slashes?ds=2020-01-01")
artifactID, _, err = ParseFlyteURL("flyte://av0.1/project/domain/name/with/slashes?ds=2020-01-01")
assert.NoError(t, err)
assert.Equal(t, "name/with/slashes", artifactID.ArtifactKey.Name)
assert.Equal(t, "project", artifactID.ArtifactKey.Project)
assert.Equal(t, "domain", artifactID.ArtifactKey.Domain)
Expand Down
2 changes: 1 addition & 1 deletion flyteartifacts/pkg/models/transformers.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func CreateArtifactModelFromRequest(ctx context.Context, key *core.ArtifactKey,
}

func PartitionsToIdl(partitions map[string]string) *core.Partitions {
if partitions == nil || len(partitions) == 0 {
if len(partitions) == 0 {
return nil
}

Expand Down
7 changes: 3 additions & 4 deletions flyteartifacts/pkg/server/processor/events_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ func (s *ServiceCallHandler) HandleEventNodeExec(ctx context.Context, source str
var taskExecID *core.TaskExecutionIdentifier
if taskExecID = evt.GetTaskExecId(); taskExecID == nil {
logger.Debugf(ctx, "No task execution id to process for task event from [%s] node %s", execID, evt.RawEvent.Id.NodeId)
return nil
}

// Iterate through the output interface. For any outputs that have an artifact ID specified, grab the
Expand Down Expand Up @@ -298,10 +299,8 @@ func (s *ServiceCallHandler) HandleEventNodeExec(ctx context.Context, source str
Principal: evt.Principal,
}

if taskExecID != nil {
aSrc.RetryAttempt = taskExecID.RetryAttempt
aSrc.TaskId = taskExecID.TaskId
}
aSrc.RetryAttempt = taskExecID.RetryAttempt
aSrc.TaskId = taskExecID.TaskId

spec := artifact.ArtifactSpec{
Value: output,
Expand Down
9 changes: 0 additions & 9 deletions flyteartifacts/pkg/server/processor/http_processor.go

This file was deleted.

7 changes: 6 additions & 1 deletion flyteartifacts/pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,17 @@ func NewArtifactService(ctx context.Context, scope promutils.Scope) *ArtifactSer
coreService := NewCoreService(storage, &blobStore, scope.NewSubScope("server"))
triggerHandler, err := NewTriggerEngine(ctx, storage, &coreService, scope.NewSubScope("triggers"))
if err != nil {
logger.Errorf(ctx, "Failed to create Admin client, stopping server. Error: %v", err)
logger.Errorf(ctx, "Failed to create Trigger engine, stopping server. Error: %v", err)
panic(err)
}

adminClientCfg := admin2.GetConfig(ctx)
clientSet, err := admin2.NewClientsetBuilder().WithConfig(adminClientCfg).Build(ctx)
if err != nil {
logger.Errorf(ctx, "Failed to create Admin client set, stopping server. Error: %v", err)
panic(err)
}

handler := processor.NewServiceCallHandler(ctx, &coreService, createdArtifacts, *clientSet)
eventsReceiverAndHandler := processor.NewBackgroundProcessor(ctx, *eventsCfg, &coreService, createdArtifacts, scope.NewSubScope("events"))
if eventsReceiverAndHandler != nil {
Expand Down
4 changes: 2 additions & 2 deletions flyteartifacts/pkg/server/trigger_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (e *TriggerEngine) evaluateAndHandleTrigger(ctx context.Context, trigger mo
// They must either both have no partitions, or both have the same partitions.
var thisIDPartitions = make(map[string]string)
if triggeringArtifactID.GetPartitions().GetValue() != nil {
for k, _ := range triggeringArtifactID.GetPartitions().GetValue() {
for k := range triggeringArtifactID.GetPartitions().GetValue() {
thisIDPartitions[k] = "placeholder"
}
}
Expand All @@ -72,7 +72,7 @@ func (e *TriggerEngine) evaluateAndHandleTrigger(ctx context.Context, trigger mo
// Build a query map of partitions for this triggering artifact while at it.
queryPartitions := map[string]*core.LabelValue{}
if len(thisIDPartitions) > 0 {
for k, _ := range thisIDPartitions {
for k := range thisIDPartitions {
if incomingValue, ok := incomingPartitions[k]; !ok {
return fmt.Errorf("trigger %s has different partitions [%v] [%+v]", trigger.Name, incoming.GetArtifactId(), triggeringArtifactID)
} else {
Expand Down

0 comments on commit 7ee22a0

Please sign in to comment.