From 281408c36956ae102b16f27bea878025ed63999e Mon Sep 17 00:00:00 2001 From: catttam Date: Fri, 23 Feb 2024 11:44:12 +0100 Subject: [PATCH 01/60] Public services test --- pkg/handlers/delete.go | 13 +++++++++---- pkg/handlers/list.go | 4 ++++ pkg/handlers/logs.go | 12 ++++++++---- pkg/handlers/read.go | 12 ++++++++---- pkg/utils/minio.go | 16 ++++++++++++---- 5 files changed, 41 insertions(+), 16 deletions(-) diff --git a/pkg/handlers/delete.go b/pkg/handlers/delete.go index d0920d99..d163b731 100644 --- a/pkg/handlers/delete.go +++ b/pkg/handlers/delete.go @@ -46,10 +46,15 @@ func MakeDeleteHandler(cfg *types.Config, back types.ServerlessBackend) gin.Hand c.String(http.StatusInternalServerError, fmt.Sprintln(err)) } - for _, id := range service.AllowedUsers { - if uid == id { - isAllowed = true - break + var isAllowed bool + if len(service.AllowedUsers) == 0 { + isAllowed = true + } else { + for _, id := range service.AllowedUsers { + if uid == id { + isAllowed = true + break + } } } diff --git a/pkg/handlers/list.go b/pkg/handlers/list.go index b4c47c3d..8f5d384e 100644 --- a/pkg/handlers/list.go +++ b/pkg/handlers/list.go @@ -46,6 +46,10 @@ func MakeListHandler(back types.ServerlessBackend) gin.HandlerFunc { var allowedServicesForUser []*types.Service for _, service := range services { + if len(service.AllowedUsers) == 0 { + allowedServicesForUser = append(allowedServicesForUser, service) + break + } for _, id := range service.AllowedUsers { if uid == id { allowedServicesForUser = append(allowedServicesForUser, service) diff --git a/pkg/handlers/logs.go b/pkg/handlers/logs.go index 17c0e328..5767af31 100644 --- a/pkg/handlers/logs.go +++ b/pkg/handlers/logs.go @@ -258,10 +258,14 @@ func isOIDCAuthorised(c *gin.Context, back types.ServerlessBackend, serviceName } var isAllowed bool - for _, id := range service.AllowedUsers { - if uid == id { - isAllowed = true - break + if len(service.AllowedUsers) == 0 { + isAllowed = true + } else { + for _, id := range service.AllowedUsers { + if uid == id { + isAllowed = true + break + } } } diff --git a/pkg/handlers/read.go b/pkg/handlers/read.go index ec3d071a..73a06407 100644 --- a/pkg/handlers/read.go +++ b/pkg/handlers/read.go @@ -49,10 +49,14 @@ func MakeReadHandler(back types.ServerlessBackend) gin.HandlerFunc { } var isAllowed bool - for _, id := range service.AllowedUsers { - if uid == id { - isAllowed = true - break + if len(service.AllowedUsers) == 0 { + isAllowed = true + } else { + for _, id := range service.AllowedUsers { + if uid == id { + isAllowed = true + break + } } } diff --git a/pkg/utils/minio.go b/pkg/utils/minio.go index 4fbfeec4..e987a49c 100644 --- a/pkg/utils/minio.go +++ b/pkg/utils/minio.go @@ -113,7 +113,7 @@ func (minIOAdminClient *MinIOAdminClient) CreateServiceGroup(bucketName string) return err } - err = createPolicy(minIOAdminClient.adminClient, bucketName) + err = createPolicy(minIOAdminClient.adminClient, bucketName, false) if err != nil { return err } @@ -123,7 +123,7 @@ func (minIOAdminClient *MinIOAdminClient) CreateServiceGroup(bucketName string) // AddServiceToAllUsersGroup associates policy of all users to a service func (minIOAdminClient *MinIOAdminClient) AddServiceToAllUsersGroup(bucketName string) error { - err := createPolicy(minIOAdminClient.adminClient, bucketName) + err := createPolicy(minIOAdminClient.adminClient, bucketName, true) if err != nil { return err } @@ -211,7 +211,15 @@ func (minIOAdminClient *MinIOAdminClient) RestartServer() error { return nil } -func createPolicy(adminClient *madmin.AdminClient, groupName string) error { +func createPolicy(adminClient *madmin.AdminClient, bucketName string, allUsers bool) error { + + var groupName string + if allUsers { + groupName = ALL_USERS_GROUP + } else { + groupName = bucketName + } + policy := `{ "Version": "2012-10-17", "Statement": [ @@ -221,7 +229,7 @@ func createPolicy(adminClient *madmin.AdminClient, groupName string) error { "s3:*" ], "Resource": [ - "arn:aws:s3:::` + groupName + `*" + "arn:aws:s3:::` + bucketName + `*" ] } ] From 36fa94e8d400fc06a2d8492afa43b0b533c52f0b Mon Sep 17 00:00:00 2001 From: catttam Date: Mon, 26 Feb 2024 09:39:15 +0100 Subject: [PATCH 02/60] Test several resources to a policy --- pkg/handlers/list.go | 2 +- pkg/utils/minio.go | 58 ++++++++++++++++++++++++++------------------ 2 files changed, 36 insertions(+), 24 deletions(-) diff --git a/pkg/handlers/list.go b/pkg/handlers/list.go index 8f5d384e..2a5cb130 100644 --- a/pkg/handlers/list.go +++ b/pkg/handlers/list.go @@ -48,7 +48,7 @@ func MakeListHandler(back types.ServerlessBackend) gin.HandlerFunc { for _, service := range services { if len(service.AllowedUsers) == 0 { allowedServicesForUser = append(allowedServicesForUser, service) - break + continue } for _, id := range service.AllowedUsers { if uid == id { diff --git a/pkg/utils/minio.go b/pkg/utils/minio.go index e987a49c..8ceb14d5 100644 --- a/pkg/utils/minio.go +++ b/pkg/utils/minio.go @@ -19,6 +19,7 @@ package utils import ( "context" "crypto/tls" + "encoding/json" "fmt" "net/http" "net/url" @@ -107,13 +108,13 @@ func (minIOAdminClient *MinIOAdminClient) CreateAllUsersGroup() error { } // CreateServiceGroup creates a MinIO group and its associated policy for a service -func (minIOAdminClient *MinIOAdminClient) CreateServiceGroup(bucketName string) error { - err := createGroup(minIOAdminClient.adminClient, bucketName) +func (minIOAdminClient *MinIOAdminClient) CreateServiceGroup(bucket []string) error { + err := createGroup(minIOAdminClient.adminClient, bucket[0]) if err != nil { return err } - err = createPolicy(minIOAdminClient.adminClient, bucketName, false) + err = createPolicy(minIOAdminClient.adminClient, bucket, false) if err != nil { return err } @@ -122,8 +123,8 @@ func (minIOAdminClient *MinIOAdminClient) CreateServiceGroup(bucketName string) } // AddServiceToAllUsersGroup associates policy of all users to a service -func (minIOAdminClient *MinIOAdminClient) AddServiceToAllUsersGroup(bucketName string) error { - err := createPolicy(minIOAdminClient.adminClient, bucketName, true) +func (minIOAdminClient *MinIOAdminClient) AddServiceToAllUsersGroup(buckets []string) error { + err := createPolicy(minIOAdminClient.adminClient, buckets, true) if err != nil { return err } @@ -163,12 +164,12 @@ func (minIOAdminClient *MinIOAdminClient) DeleteServiceGroup(groupName string) e err = minIOAdminClient.adminClient.UpdateGroupMembers(context.Background(), group) if err != nil { - return fmt.Errorf("Error emptying group: %v", err) + return fmt.Errorf("error emptying group: %v", err) } err = minIOAdminClient.adminClient.RemoveCannedPolicy(context.TODO(), groupName) if err != nil { - return fmt.Errorf("Error removing group's policy: %v", err) + return fmt.Errorf("error removing group's policy: %v", err) } return nil } @@ -211,31 +212,42 @@ func (minIOAdminClient *MinIOAdminClient) RestartServer() error { return nil } -func createPolicy(adminClient *madmin.AdminClient, bucketName string, allUsers bool) error { +func parseResources(resources []string) []string { + var arnStr = "arn:aws:s3:::" + if len(resources) > 1 { + for id, r := range resources { + resources[id] = arnStr + r + } + } + return resources +} +func createPolicy(adminClient *madmin.AdminClient, buckets []string, allUsers bool) error { var groupName string if allUsers { groupName = ALL_USERS_GROUP } else { - groupName = bucketName + groupName = buckets[0] } - policy := `{ + resources := parseResources(buckets) + + policy := map[string]interface{}{ "Version": "2012-10-17", - "Statement": [ + "Statement": []map[string]interface{}{ { - "Effect": "Allow", - "Action": [ - "s3:*" - ], - "Resource": [ - "arn:aws:s3:::` + bucketName + `*" - ] - } - ] - }` - - err := adminClient.AddCannedPolicy(context.TODO(), groupName, []byte(policy)) + "Effect": "Allow", + "Action": []string{"s3:*"}, + "Resource": resources, + }, + }, + } + policyJSON, parseErr := json.Marshal(policy) + if parseErr != nil { + return fmt.Errorf("error marshalling policy: %s", parseErr) + } + + err := adminClient.AddCannedPolicy(context.TODO(), groupName, policyJSON) if err != nil { return fmt.Errorf("error creating MinIO policy for group %s: %v", groupName, err) } From a958129ca5b8fe95a1e7c5c06d1164a763e7d95b Mon Sep 17 00:00:00 2001 From: catttam Date: Mon, 26 Feb 2024 13:57:38 +0100 Subject: [PATCH 03/60] Test add multiple policies --- pkg/utils/minio.go | 65 +++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 36 deletions(-) diff --git a/pkg/utils/minio.go b/pkg/utils/minio.go index 8ceb14d5..c96a1e44 100644 --- a/pkg/utils/minio.go +++ b/pkg/utils/minio.go @@ -19,7 +19,6 @@ package utils import ( "context" "crypto/tls" - "encoding/json" "fmt" "net/http" "net/url" @@ -108,13 +107,13 @@ func (minIOAdminClient *MinIOAdminClient) CreateAllUsersGroup() error { } // CreateServiceGroup creates a MinIO group and its associated policy for a service -func (minIOAdminClient *MinIOAdminClient) CreateServiceGroup(bucket []string) error { - err := createGroup(minIOAdminClient.adminClient, bucket[0]) +func (minIOAdminClient *MinIOAdminClient) CreateServiceGroup(bucketName string) error { + err := createGroup(minIOAdminClient.adminClient, bucketName) if err != nil { return err } - err = createPolicy(minIOAdminClient.adminClient, bucket, false) + err = createPolicy(minIOAdminClient.adminClient, bucketName, false) if err != nil { return err } @@ -123,8 +122,8 @@ func (minIOAdminClient *MinIOAdminClient) CreateServiceGroup(bucket []string) er } // AddServiceToAllUsersGroup associates policy of all users to a service -func (minIOAdminClient *MinIOAdminClient) AddServiceToAllUsersGroup(buckets []string) error { - err := createPolicy(minIOAdminClient.adminClient, buckets, true) +func (minIOAdminClient *MinIOAdminClient) AddServiceToAllUsersGroup(bucketName string) error { + err := createPolicy(minIOAdminClient.adminClient, bucketName, true) if err != nil { return err } @@ -212,42 +211,36 @@ func (minIOAdminClient *MinIOAdminClient) RestartServer() error { return nil } -func parseResources(resources []string) []string { - var arnStr = "arn:aws:s3:::" - if len(resources) > 1 { - for id, r := range resources { - resources[id] = arnStr + r - } - } - return resources -} -func createPolicy(adminClient *madmin.AdminClient, buckets []string, allUsers bool) error { - +func createPolicy(adminClient *madmin.AdminClient, bucketName string, allUsers bool) error { var groupName string + policy := `{ + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Action": [ + "s3:*" + ], + "Resource": [ + "arn:aws:s3:::` + bucketName + `*" + ] + } + ] + }` + if allUsers { groupName = ALL_USERS_GROUP - } else { - groupName = buckets[0] - } - - resources := parseResources(buckets) + groupDescription, errDescr := adminClient.GetGroupDescription(context.TODO(), ALL_USERS_GROUP) + if errDescr != nil { + return errDescr + } + policy = policy + groupDescription.Policy - policy := map[string]interface{}{ - "Version": "2012-10-17", - "Statement": []map[string]interface{}{ - { - "Effect": "Allow", - "Action": []string{"s3:*"}, - "Resource": resources, - }, - }, - } - policyJSON, parseErr := json.Marshal(policy) - if parseErr != nil { - return fmt.Errorf("error marshalling policy: %s", parseErr) + } else { + groupName = bucketName } - err := adminClient.AddCannedPolicy(context.TODO(), groupName, policyJSON) + err := adminClient.AddCannedPolicy(context.TODO(), groupName, []byte(policy)) if err != nil { return fmt.Errorf("error creating MinIO policy for group %s: %v", groupName, err) } From f90d110a47f46e99eae651f41c1fd185c3cacd6b Mon Sep 17 00:00:00 2001 From: catttam Date: Tue, 27 Feb 2024 12:18:36 +0100 Subject: [PATCH 04/60] Updating all users policy --- pkg/utils/minio.go | 59 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 15 deletions(-) diff --git a/pkg/utils/minio.go b/pkg/utils/minio.go index c96a1e44..b42a1fcf 100644 --- a/pkg/utils/minio.go +++ b/pkg/utils/minio.go @@ -19,6 +19,7 @@ package utils import ( "context" "crypto/tls" + "encoding/json" "fmt" "net/http" "net/url" @@ -36,6 +37,18 @@ type MinIOAdminClient struct { oscarEndpoint *url.URL } +// Define the policy structure using Go structs +type Statement struct { + Effect string `json:"Effect"` + Action []string `json:"Action"` + Resource []string `json:"Resource"` +} + +type Policy struct { + Version string `json:"Version"` + Statement []Statement `json:"Statement"` +} + // MakeMinIOAdminClient creates a new MinIO Admin client to configure webhook notifications func MakeMinIOAdminClient(cfg *types.Config) (*MinIOAdminClient, error) { // Parse minIO endpoint @@ -213,31 +226,47 @@ func (minIOAdminClient *MinIOAdminClient) RestartServer() error { func createPolicy(adminClient *madmin.AdminClient, bucketName string, allUsers bool) error { var groupName string - policy := `{ - "Version": "2012-10-17", - "Statement": [ - { - "Effect": "Allow", - "Action": [ - "s3:*" - ], - "Resource": [ - "arn:aws:s3:::` + bucketName + `*" - ] - } - ] - }` + var policy []byte + var jsonErr error if allUsers { + rs := "arn:aws:s3:::" + bucketName groupName = ALL_USERS_GROUP + + // Get policy from group groupDescription, errDescr := adminClient.GetGroupDescription(context.TODO(), ALL_USERS_GROUP) if errDescr != nil { return errDescr } - policy = policy + groupDescription.Policy + + actualPolicy := &Policy{} + json.Unmarshal([]byte(groupDescription.Policy), actualPolicy) + + // Add new resource and create policy + actualPolicy.Statement[0].Resource = append(actualPolicy.Statement[0].Resource, rs) + + policy, jsonErr = json.Marshal(actualPolicy) + if jsonErr != nil { + return jsonErr + } } else { groupName = bucketName + p := `{ + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Action": [ + "s3:*" + ], + "Resource": [ + "arn:aws:s3:::` + bucketName + `" + ] + } + ] + }` + policy = []byte(p) } err := adminClient.AddCannedPolicy(context.TODO(), groupName, []byte(policy)) From 4b939ceb7805d6434c6c0fb1bf2ed1c6112d8e80 Mon Sep 17 00:00:00 2001 From: catttam Date: Tue, 27 Feb 2024 12:46:34 +0100 Subject: [PATCH 05/60] Debug logs --- docs/fdl.md | 2 +- pkg/utils/minio.go | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/fdl.md b/docs/fdl.md index d8836c44..f6cd3fd4 100644 --- a/docs/fdl.md +++ b/docs/fdl.md @@ -77,7 +77,7 @@ storage_providers: | `alpine`
*boolean* | Alpine parameter to set if image is based on Alpine. If `true` a custom release of faas-supervisor will be used. Optional (default: false) | | `script`
*string* | Local path to the user script to be executed in the service container | | `file_stage_in`
*bool* | Parameter to skip the download of the input files by the FaaS Supervisor (default: false) | -| `image_pull_secrets`
*string array* | Array of Kubernetes secrets. Only needed to use private images located on private registries. | +| `image_pull_secrets`
*string array* | Array of Kubernetes secrets. Only needed to use private images located on private registries. | `allowed_users`
*string array* | Array of EGI UIDS to allow specific users to interact with the service. (Can be used since version of OSCAR v3.0.0) | | `memory`
*string* | Memory limit for the service following the [kubernetes format](https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#meaning-of-memory). Optional (default: 256Mi) | | `cpu`
*string* | CPU limit for the service following the [kubernetes format](https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#meaning-of-cpu). Optional (default: 0.2) | | `enable_gpu`
*bool* | Parameter to enable the use of GPU for the service. Requires a device plugin deployed on the cluster (More info: [Kubernetes device plugins](https://kubernetes.io/docs/tasks/manage-gpus/scheduling-gpus/#using-device-plugins)). Optional (default: false) | diff --git a/pkg/utils/minio.go b/pkg/utils/minio.go index b42a1fcf..cbb53205 100644 --- a/pkg/utils/minio.go +++ b/pkg/utils/minio.go @@ -21,8 +21,10 @@ import ( "crypto/tls" "encoding/json" "fmt" + "log" "net/http" "net/url" + "os" "time" "github.com/grycap/oscar/v3/pkg/types" @@ -31,6 +33,8 @@ import ( const ALL_USERS_GROUP = "all_users_group" +var minioLogger = log.New(os.Stdout, "[MINIO] ", log.Flags()) + // MinIOAdminClient struct to represent a MinIO Admin client to configure webhook notifications type MinIOAdminClient struct { adminClient *madmin.AdminClient @@ -239,8 +243,11 @@ func createPolicy(adminClient *madmin.AdminClient, bucketName string, allUsers b return errDescr } + minioLogger.Println("ALL_USERS_GROUP status: ", &groupDescription) + actualPolicy := &Policy{} json.Unmarshal([]byte(groupDescription.Policy), actualPolicy) + minioLogger.Println("Actual policy: ", &actualPolicy) // Add new resource and create policy actualPolicy.Statement[0].Resource = append(actualPolicy.Statement[0].Resource, rs) From 9d54ce23423a0eb37bfbae9e47a8b80a6f0d89a7 Mon Sep 17 00:00:00 2001 From: catttam Date: Tue, 27 Feb 2024 13:11:35 +0100 Subject: [PATCH 06/60] Debug logs --- pkg/utils/minio.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/utils/minio.go b/pkg/utils/minio.go index cbb53205..3241b624 100644 --- a/pkg/utils/minio.go +++ b/pkg/utils/minio.go @@ -243,11 +243,11 @@ func createPolicy(adminClient *madmin.AdminClient, bucketName string, allUsers b return errDescr } - minioLogger.Println("ALL_USERS_GROUP status: ", &groupDescription) + minioLogger.Println("ALL_USERS_GROUP status: ", groupDescription) actualPolicy := &Policy{} json.Unmarshal([]byte(groupDescription.Policy), actualPolicy) - minioLogger.Println("Actual policy: ", &actualPolicy) + minioLogger.Println("Actual policy: ", actualPolicy) // Add new resource and create policy actualPolicy.Statement[0].Resource = append(actualPolicy.Statement[0].Resource, rs) From 1c1d22d90789cee8a30216838060d135f5edf7c7 Mon Sep 17 00:00:00 2001 From: catttam Date: Tue, 27 Feb 2024 14:35:51 +0100 Subject: [PATCH 07/60] Fixed policy update for public services --- pkg/utils/minio.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/pkg/utils/minio.go b/pkg/utils/minio.go index 3241b624..4537bd64 100644 --- a/pkg/utils/minio.go +++ b/pkg/utils/minio.go @@ -237,17 +237,13 @@ func createPolicy(adminClient *madmin.AdminClient, bucketName string, allUsers b rs := "arn:aws:s3:::" + bucketName groupName = ALL_USERS_GROUP - // Get policy from group - groupDescription, errDescr := adminClient.GetGroupDescription(context.TODO(), ALL_USERS_GROUP) - if errDescr != nil { - return errDescr + policyInfo, errInfo := adminClient.InfoCannedPolicyV2(context.TODO(), ALL_USERS_GROUP) + if errInfo != nil { + return errInfo } - minioLogger.Println("ALL_USERS_GROUP status: ", groupDescription) - actualPolicy := &Policy{} - json.Unmarshal([]byte(groupDescription.Policy), actualPolicy) - minioLogger.Println("Actual policy: ", actualPolicy) + json.Unmarshal(policyInfo.Policy, actualPolicy) // Add new resource and create policy actualPolicy.Statement[0].Resource = append(actualPolicy.Statement[0].Resource, rs) From e5c46567def4c936bb380dd8a0fbe594cc2443bd Mon Sep 17 00:00:00 2001 From: catttam Date: Tue, 5 Mar 2024 12:36:18 +0100 Subject: [PATCH 08/60] ImagePullPolicy on services changed to always --- pkg/types/service.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/types/service.go b/pkg/types/service.go index fc4f04e9..68b9e8ff 100644 --- a/pkg/types/service.go +++ b/pkg/types/service.go @@ -257,9 +257,10 @@ func (service *Service) ToPodSpec(cfg *Config) (*v1.PodSpec, error) { ImagePullSecrets: SetImagePullSecrets(service.ImagePullSecrets), Containers: []v1.Container{ { - Name: ContainerName, - Image: service.Image, - Env: ConvertEnvVars(service.Environment.Vars), + Name: ContainerName, + Image: service.Image, + ImagePullPolicy: v1.PullAlways, + Env: ConvertEnvVars(service.Environment.Vars), VolumeMounts: []v1.VolumeMount{ { Name: VolumeName, From 9bf7316e9e19957e3485bae89048018ec7393984 Mon Sep 17 00:00:00 2001 From: vicente87 Date: Tue, 5 Mar 2024 13:08:17 +0100 Subject: [PATCH 09/60] Test commit --- pkg/handlers/health.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/handlers/health.go b/pkg/handlers/health.go index a24d0276..319ad75d 100644 --- a/pkg/handlers/health.go +++ b/pkg/handlers/health.go @@ -24,5 +24,6 @@ import ( // HealthHandler health handler for kubernetes deployment func HealthHandler(c *gin.Context) { + // cambio c.String(http.StatusOK, "Ok") } From eb2eb7614fdde8edc709bf1e5fa78b4a2ce3fa5e Mon Sep 17 00:00:00 2001 From: vicente87 Date: Tue, 5 Mar 2024 14:32:17 +0100 Subject: [PATCH 10/60] Create the metrics clientset --- main.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main.go b/main.go index 1c2ef532..c54aa408 100644 --- a/main.go +++ b/main.go @@ -29,6 +29,7 @@ import ( "github.com/grycap/oscar/v3/pkg/utils/auth" "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" + versioned "k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1" ) func main() { @@ -50,6 +51,9 @@ func main() { log.Fatal(err) } + //Create the metrics clientset + metricsClientset := versioned.NewForConfigOrDie(kubeConfig) + // Check if the cluster has available GPUs cfg.CheckAvailableGPUs(kubeClientset) From c247c19783c0bb00c768d0e84af1e30f13766a89 Mon Sep 17 00:00:00 2001 From: vicente87 Date: Tue, 5 Mar 2024 14:56:06 +0100 Subject: [PATCH 11/60] create /health function with new parameters --- main.go | 2 +- pkg/handlers/health.go | 67 +++++++++++++++++++++++++++++++++++++++--- 2 files changed, 64 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index c54aa408..54f624cb 100644 --- a/main.go +++ b/main.go @@ -120,7 +120,7 @@ func main() { }) // Health path for k8s health checks - r.GET("/health", handlers.HealthHandler) + r.GET("/health", handlers.HealthHandler(kubeClientset,metricsClientset,back)) // Define and start HTTP server s := &http.Server{ diff --git a/pkg/handlers/health.go b/pkg/handlers/health.go index 319ad75d..da9c52e9 100644 --- a/pkg/handlers/health.go +++ b/pkg/handlers/health.go @@ -18,12 +18,71 @@ package handlers import ( "net/http" + "github.com/gin-gonic/gin" - "github.com/gin-gonic/gin" + "strconv" + "fmt" + "os" + "encoding/json" + ) +type NodeInfo struct { + NodeName string `json:"nodeName"` + CPUCapacity string `json:"cpuCapacity"` + CPUUsage string `json:"cpuUsage"` + CPUPercentage string `json:"cpuPercentage"` + MemoryCapacity string `json:"memoryCapacity"` + MemoryUsage string `json:"memoryUsage"` + MemoryPercentage string `json:"memoryPercentage"` + +} + // HealthHandler health handler for kubernetes deployment -func HealthHandler(c *gin.Context) { - // cambio - c.String(http.StatusOK, "Ok") +func HealthHandler(c *gin.Context,kubeClientset,metricsClientset) { + + // Get nodes list + nodes, err := kubeClientset.CoreV1().Nodes().List(context.Background(), metav1.ListOptions{}) + if err != nil { + fmt.Fprintf(os.Stderr, "Error getting nodes list: %v\n", err) + os.Exit(1) + } + + // Get metrics nodes + nodeMetricsList, err := metricsClientset.NodeMetricses().List(context.Background(), metav1.ListOptions{}) + if err != nil { + fmt.Fprintf(os.Stderr, "Error getting metrics nodes: %v\n", err) + os.Exit(1) + } + + for id, _ := range nodes.Items{ + nodeName :=nodes.Items[id].Name + cpu_alloc :=nodes.Items[id].Status.Allocatable.Cpu().MilliValue() + cpu_usage :=nodeMetricsList.Items[id].Usage["cpu"] + cpu_usage_percent :=(float64(cpu_usage.MilliValue())/float64(cpu_alloc))*100 + + memory_alloc :=nodes.Items[id].Status.Allocatable.Memory().Value() + memory_usage :=nodeMetricsList.Items[id].Usage["memory"] + memory_usage_percent :=(float64(memory_usage.Value())/float64(memory_alloc))*100 + + nodeInfo := NodeInfo{ + NodeName: nodeName, + CPUCapacity: strconv.Itoa(int(cpu_alloc)), + CPUUsage: strconv.Itoa(int(cpu_usage.MilliValue())), + CPUPercentage: fmt.Sprintf("%.2f", cpu_usage_percent), + MemoryCapacity: strconv.Itoa(int(memory_alloc)), + MemoryUsage: strconv.Itoa(int(memory_usage.Value())), + MemoryPercentage: fmt.Sprintf("%.2f",memory_usage_percent), + } + + nodeInfoList = append(nodeInfoList, nodeInfo) + } + // Encode list of NodeInfo structures in json format + jsonData, err := json.MarshalIndent(nodeInfoList, "", " ") + if err != nil { + fmt.Fprintf(os.Stderr, "Error encoding json: %v\n", err) + os.Exit(1) + } + c.JSON(http.StatusOK, jsonData) + //c.String(http.StatusOK, "Ok") } From c8124a2fa5cb2bd34b672690614935131a0e19a2 Mon Sep 17 00:00:00 2001 From: vicente87 Date: Tue, 5 Mar 2024 15:22:53 +0100 Subject: [PATCH 12/60] Organization parameters --- main.go | 2 +- pkg/handlers/health.go | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index 54f624cb..3a26b4c8 100644 --- a/main.go +++ b/main.go @@ -120,7 +120,7 @@ func main() { }) // Health path for k8s health checks - r.GET("/health", handlers.HealthHandler(kubeClientset,metricsClientset,back)) + r.GET("/health", handlers.HealthHandler(kubeClientset, metricsClientset, back)) // Define and start HTTP server s := &http.Server{ diff --git a/pkg/handlers/health.go b/pkg/handlers/health.go index da9c52e9..c16bd5e2 100644 --- a/pkg/handlers/health.go +++ b/pkg/handlers/health.go @@ -17,14 +17,12 @@ limitations under the License. package handlers import ( - "net/http" + "net/http" "github.com/gin-gonic/gin" - "strconv" "fmt" "os" "encoding/json" - ) type NodeInfo struct { @@ -39,7 +37,7 @@ type NodeInfo struct { } // HealthHandler health handler for kubernetes deployment -func HealthHandler(c *gin.Context,kubeClientset,metricsClientset) { +func HealthHandler(c *gin.Context, kubeClientset, metricsClientset) { // Get nodes list nodes, err := kubeClientset.CoreV1().Nodes().List(context.Background(), metav1.ListOptions{}) @@ -55,6 +53,7 @@ func HealthHandler(c *gin.Context,kubeClientset,metricsClientset) { os.Exit(1) } + // Parameters for id, _ := range nodes.Items{ nodeName :=nodes.Items[id].Name cpu_alloc :=nodes.Items[id].Status.Allocatable.Cpu().MilliValue() From 4052973d1b79e7cbe4150a2f17f258c92576db07 Mon Sep 17 00:00:00 2001 From: vicente87 Date: Wed, 6 Mar 2024 08:55:14 +0100 Subject: [PATCH 13/60] Annotation --- pkg/handlers/health.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/handlers/health.go b/pkg/handlers/health.go index c16bd5e2..62a6cb26 100644 --- a/pkg/handlers/health.go +++ b/pkg/handlers/health.go @@ -37,7 +37,7 @@ type NodeInfo struct { } // HealthHandler health handler for kubernetes deployment -func HealthHandler(c *gin.Context, kubeClientset, metricsClientset) { +func HealthHandler(c *gin.Context, kubeClientset, metricsClientset, back) { // Get nodes list nodes, err := kubeClientset.CoreV1().Nodes().List(context.Background(), metav1.ListOptions{}) From 577a11229f2e894e01d61291e627a9d2b84153e5 Mon Sep 17 00:00:00 2001 From: vicente87 Date: Wed, 6 Mar 2024 09:55:51 +0100 Subject: [PATCH 14/60] Annotation parameters --- main.go | 2 +- pkg/handlers/health.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 3a26b4c8..16d4e627 100644 --- a/main.go +++ b/main.go @@ -109,7 +109,7 @@ func main() { } // System info path - system.GET("/info", handlers.MakeInfoHandler(kubeClientset, back)) + system.GET("/info", handlers.MakeInfoHandler(kubeClientset)) // Serve OSCAR User Interface r.Static("/ui", "./assets") diff --git a/pkg/handlers/health.go b/pkg/handlers/health.go index 62a6cb26..e766ebe0 100644 --- a/pkg/handlers/health.go +++ b/pkg/handlers/health.go @@ -18,10 +18,10 @@ package handlers import ( "net/http" - "github.com/gin-gonic/gin" + "github.com/gin-gonic/gin" "strconv" "fmt" - "os" + "os" "encoding/json" ) @@ -37,7 +37,7 @@ type NodeInfo struct { } // HealthHandler health handler for kubernetes deployment -func HealthHandler(c *gin.Context, kubeClientset, metricsClientset, back) { +func HealthHandler(c *gin.Context, kubeClientset, metricsClientset) { // Get nodes list nodes, err := kubeClientset.CoreV1().Nodes().List(context.Background(), metav1.ListOptions{}) From c86b90564aa641b5c72f2ca2f40fe8cccee02552 Mon Sep 17 00:00:00 2001 From: vicente87 Date: Wed, 6 Mar 2024 10:00:56 +0100 Subject: [PATCH 15/60] Annotation import --- pkg/handlers/health.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/handlers/health.go b/pkg/handlers/health.go index e766ebe0..9023c8a2 100644 --- a/pkg/handlers/health.go +++ b/pkg/handlers/health.go @@ -17,12 +17,12 @@ limitations under the License. package handlers import ( - "net/http" - "github.com/gin-gonic/gin" - "strconv" - "fmt" - "os" - "encoding/json" + "github.com/gin-gonic/gin" + "strconv" + "fmt" + "os" + "encoding/json" + "net/http" ) type NodeInfo struct { From 0dc380efacf34b24ea5291172e7ac3dc6d7abcb5 Mon Sep 17 00:00:00 2001 From: vicente87 Date: Wed, 6 Mar 2024 10:20:43 +0100 Subject: [PATCH 16/60] Annotation update --- pkg/handlers/health.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/handlers/health.go b/pkg/handlers/health.go index 9023c8a2..d4b18770 100644 --- a/pkg/handlers/health.go +++ b/pkg/handlers/health.go @@ -37,7 +37,7 @@ type NodeInfo struct { } // HealthHandler health handler for kubernetes deployment -func HealthHandler(c *gin.Context, kubeClientset, metricsClientset) { +func HealthHandler(c *gin.Context, kubeClientset *kubernetes.Clientset, metricsClientset) { // Get nodes list nodes, err := kubeClientset.CoreV1().Nodes().List(context.Background(), metav1.ListOptions{}) @@ -54,13 +54,13 @@ func HealthHandler(c *gin.Context, kubeClientset, metricsClientset) { } // Parameters - for id, _ := range nodes.Items{ - nodeName :=nodes.Items[id].Name - cpu_alloc :=nodes.Items[id].Status.Allocatable.Cpu().MilliValue() + for id, node := range nodes.Items{ + nodeName :=node.Name + cpu_alloc :=node.Status.Allocatable.Cpu().MilliValue() cpu_usage :=nodeMetricsList.Items[id].Usage["cpu"] cpu_usage_percent :=(float64(cpu_usage.MilliValue())/float64(cpu_alloc))*100 - memory_alloc :=nodes.Items[id].Status.Allocatable.Memory().Value() + memory_alloc :=node.Status.Allocatable.Memory().Value() memory_usage :=nodeMetricsList.Items[id].Usage["memory"] memory_usage_percent :=(float64(memory_usage.Value())/float64(memory_alloc))*100 From d9a4bf46362c20b07075abf6c1b8e4ea5f4bd8fe Mon Sep 17 00:00:00 2001 From: vicente87 Date: Wed, 6 Mar 2024 10:52:42 +0100 Subject: [PATCH 17/60] Create Status path --- main.go | 5 ++- pkg/handlers/health.go | 67 +++----------------------------- pkg/handlers/status.go | 87 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 63 deletions(-) create mode 100644 pkg/handlers/status.go diff --git a/main.go b/main.go index 16d4e627..ea41fbb9 100644 --- a/main.go +++ b/main.go @@ -120,7 +120,10 @@ func main() { }) // Health path for k8s health checks - r.GET("/health", handlers.HealthHandler(kubeClientset, metricsClientset, back)) + r.GET("/health", handlers.HealthHandler) + + // Status path for cluster status (Memory and CPU) checks + r.GET("/status", handlers.StatusHandler(kubeClientset, metricsClientset)) // Define and start HTTP server s := &http.Server{ diff --git a/pkg/handlers/health.go b/pkg/handlers/health.go index d4b18770..6ceff2ec 100644 --- a/pkg/handlers/health.go +++ b/pkg/handlers/health.go @@ -17,71 +17,14 @@ limitations under the License. package handlers import ( - "github.com/gin-gonic/gin" - "strconv" - "fmt" - "os" - "encoding/json" - "net/http" -) + "net/http" -type NodeInfo struct { - NodeName string `json:"nodeName"` - CPUCapacity string `json:"cpuCapacity"` - CPUUsage string `json:"cpuUsage"` - CPUPercentage string `json:"cpuPercentage"` - MemoryCapacity string `json:"memoryCapacity"` - MemoryUsage string `json:"memoryUsage"` - MemoryPercentage string `json:"memoryPercentage"` + "github.com/gin-gonic/gin" +) -} // HealthHandler health handler for kubernetes deployment -func HealthHandler(c *gin.Context, kubeClientset *kubernetes.Clientset, metricsClientset) { - - // Get nodes list - nodes, err := kubeClientset.CoreV1().Nodes().List(context.Background(), metav1.ListOptions{}) - if err != nil { - fmt.Fprintf(os.Stderr, "Error getting nodes list: %v\n", err) - os.Exit(1) - } +func HealthHandler(c *gin.Context) { - // Get metrics nodes - nodeMetricsList, err := metricsClientset.NodeMetricses().List(context.Background(), metav1.ListOptions{}) - if err != nil { - fmt.Fprintf(os.Stderr, "Error getting metrics nodes: %v\n", err) - os.Exit(1) - } - - // Parameters - for id, node := range nodes.Items{ - nodeName :=node.Name - cpu_alloc :=node.Status.Allocatable.Cpu().MilliValue() - cpu_usage :=nodeMetricsList.Items[id].Usage["cpu"] - cpu_usage_percent :=(float64(cpu_usage.MilliValue())/float64(cpu_alloc))*100 - - memory_alloc :=node.Status.Allocatable.Memory().Value() - memory_usage :=nodeMetricsList.Items[id].Usage["memory"] - memory_usage_percent :=(float64(memory_usage.Value())/float64(memory_alloc))*100 - - nodeInfo := NodeInfo{ - NodeName: nodeName, - CPUCapacity: strconv.Itoa(int(cpu_alloc)), - CPUUsage: strconv.Itoa(int(cpu_usage.MilliValue())), - CPUPercentage: fmt.Sprintf("%.2f", cpu_usage_percent), - MemoryCapacity: strconv.Itoa(int(memory_alloc)), - MemoryUsage: strconv.Itoa(int(memory_usage.Value())), - MemoryPercentage: fmt.Sprintf("%.2f",memory_usage_percent), - } - - nodeInfoList = append(nodeInfoList, nodeInfo) - } - // Encode list of NodeInfo structures in json format - jsonData, err := json.MarshalIndent(nodeInfoList, "", " ") - if err != nil { - fmt.Fprintf(os.Stderr, "Error encoding json: %v\n", err) - os.Exit(1) - } - c.JSON(http.StatusOK, jsonData) - //c.String(http.StatusOK, "Ok") + c.String(http.StatusOK, "Ok") } diff --git a/pkg/handlers/status.go b/pkg/handlers/status.go new file mode 100644 index 00000000..5e3ad8d2 --- /dev/null +++ b/pkg/handlers/status.go @@ -0,0 +1,87 @@ +/* +Copyright (C) GRyCAP - I3M - UPV + +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 handlers + +import ( + "github.com/gin-gonic/gin" + "strconv" + "fmt" + "os" + "encoding/json" + "net/http" +) + +type NodeInfo struct { + NodeName string `json:"nodeName"` + CPUCapacity string `json:"cpuCapacity"` + CPUUsage string `json:"cpuUsage"` + CPUPercentage string `json:"cpuPercentage"` + MemoryCapacity string `json:"memoryCapacity"` + MemoryUsage string `json:"memoryUsage"` + MemoryPercentage string `json:"memoryPercentage"` + +} + +// StatusHandler Status handler for kubernetes deployment +func StatusHandler(c *gin.Context, kubeClientset *kubernetes.Clientset, metricsClientset) { + + // Get nodes list + nodes, err := kubeClientset.CoreV1().Nodes().List(context.Background(), metav1.ListOptions{}) + if err != nil { + fmt.Fprintf(os.Stderr, "Error getting nodes list: %v\n", err) + os.Exit(1) + } + + // Get metrics nodes + nodeMetricsList, err := metricsClientset.NodeMetricses().List(context.Background(), metav1.ListOptions{}) + if err != nil { + fmt.Fprintf(os.Stderr, "Error getting metrics nodes: %v\n", err) + os.Exit(1) + } + + // Parameters + for id, node := range nodes.Items{ + nodeName :=node.Name + cpu_alloc :=node.Status.Allocatable.Cpu().MilliValue() + cpu_usage :=nodeMetricsList.Items[id].Usage["cpu"] + cpu_usage_percent :=(float64(cpu_usage.MilliValue())/float64(cpu_alloc))*100 + + memory_alloc :=node.Status.Allocatable.Memory().Value() + memory_usage :=nodeMetricsList.Items[id].Usage["memory"] + memory_usage_percent :=(float64(memory_usage.Value())/float64(memory_alloc))*100 + + nodeInfo := NodeInfo{ + NodeName: nodeName, + CPUCapacity: strconv.Itoa(int(cpu_alloc)), + CPUUsage: strconv.Itoa(int(cpu_usage.MilliValue())), + CPUPercentage: fmt.Sprintf("%.2f", cpu_usage_percent), + MemoryCapacity: strconv.Itoa(int(memory_alloc)), + MemoryUsage: strconv.Itoa(int(memory_usage.Value())), + MemoryPercentage: fmt.Sprintf("%.2f",memory_usage_percent), + } + + nodeInfoList = append(nodeInfoList, nodeInfo) + } + // Encode list of NodeInfo structures in json format + jsonData, err := json.MarshalIndent(nodeInfoList, "", " ") + if err != nil { + fmt.Fprintf(os.Stderr, "Error encoding json: %v\n", err) + os.Exit(1) + } + c.JSON(http.StatusOK, jsonData) + //c.String(http.StatusOK, "Ok") +} From 6734d3d1ff7cd21676be472cdc5d535bfd433a56 Mon Sep 17 00:00:00 2001 From: vicente87 Date: Wed, 6 Mar 2024 10:59:47 +0100 Subject: [PATCH 18/60] Annotqation status --- pkg/handlers/health.go | 2 +- pkg/handlers/status.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/handlers/health.go b/pkg/handlers/health.go index 6ceff2ec..577f4c19 100644 --- a/pkg/handlers/health.go +++ b/pkg/handlers/health.go @@ -18,7 +18,7 @@ package handlers import ( "net/http" - + "github.com/gin-gonic/gin" ) diff --git a/pkg/handlers/status.go b/pkg/handlers/status.go index 5e3ad8d2..fa46a5dc 100644 --- a/pkg/handlers/status.go +++ b/pkg/handlers/status.go @@ -37,7 +37,7 @@ type NodeInfo struct { } // StatusHandler Status handler for kubernetes deployment -func StatusHandler(c *gin.Context, kubeClientset *kubernetes.Clientset, metricsClientset) { +func StatusHandler(c *gin.Context, kubeClientset *kubernetes.Clientset, metricsClientset *versioned.MetricsV1beta1Interface) { // Get nodes list nodes, err := kubeClientset.CoreV1().Nodes().List(context.Background(), metav1.ListOptions{}) From 00c600b7c1f72fdf9c1ce283e01f0f134dd6096c Mon Sep 17 00:00:00 2001 From: vicente87 Date: Wed, 6 Mar 2024 11:47:57 +0100 Subject: [PATCH 19/60] Annotation error --- pkg/handlers/status.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/handlers/status.go b/pkg/handlers/status.go index fa46a5dc..f7d52d41 100644 --- a/pkg/handlers/status.go +++ b/pkg/handlers/status.go @@ -23,6 +23,8 @@ import ( "os" "encoding/json" "net/http" + "k8s.io/client-go/kubernetes" + versioned "k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1" ) type NodeInfo struct { @@ -53,6 +55,7 @@ func StatusHandler(c *gin.Context, kubeClientset *kubernetes.Clientset, metricsC os.Exit(1) } + var nodeInfoList []NodeInfo // Parameters for id, node := range nodes.Items{ nodeName :=node.Name From 74587ab1c8667181180590c8b9abdbb4169935e2 Mon Sep 17 00:00:00 2001 From: vicente87 Date: Wed, 6 Mar 2024 11:52:35 +0100 Subject: [PATCH 20/60] Annotation error --- pkg/handlers/status.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/handlers/status.go b/pkg/handlers/status.go index f7d52d41..fb0db714 100644 --- a/pkg/handlers/status.go +++ b/pkg/handlers/status.go @@ -39,7 +39,7 @@ type NodeInfo struct { } // StatusHandler Status handler for kubernetes deployment -func StatusHandler(c *gin.Context, kubeClientset *kubernetes.Clientset, metricsClientset *versioned.MetricsV1beta1Interface) { +func StatusHandler(c *gin.Context, kubeClientset *kubernetes.Clientset, metricsClientset *versioned.MetricsV1beta1Client) { // Get nodes list nodes, err := kubeClientset.CoreV1().Nodes().List(context.Background(), metav1.ListOptions{}) From 6266e4c5d93e21fb99686505a28b096e6db9725c Mon Sep 17 00:00:00 2001 From: vicente87 Date: Wed, 6 Mar 2024 16:18:50 +0100 Subject: [PATCH 21/60] annotation error --- pkg/handlers/status.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/handlers/status.go b/pkg/handlers/status.go index fb0db714..a760f2a3 100644 --- a/pkg/handlers/status.go +++ b/pkg/handlers/status.go @@ -56,7 +56,7 @@ func StatusHandler(c *gin.Context, kubeClientset *kubernetes.Clientset, metricsC } var nodeInfoList []NodeInfo - // Parameters + // Parameters CPU and Memory for id, node := range nodes.Items{ nodeName :=node.Name cpu_alloc :=node.Status.Allocatable.Cpu().MilliValue() From cdcd848470b1fd4d2ffab489d11fcbec975f5cd4 Mon Sep 17 00:00:00 2001 From: vicente87 Date: Wed, 6 Mar 2024 16:21:06 +0100 Subject: [PATCH 22/60] annotation import --- pkg/handlers/status.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/handlers/status.go b/pkg/handlers/status.go index a760f2a3..f5e44c71 100644 --- a/pkg/handlers/status.go +++ b/pkg/handlers/status.go @@ -24,7 +24,7 @@ import ( "encoding/json" "net/http" "k8s.io/client-go/kubernetes" - versioned "k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1" +// versioned "k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1" ) type NodeInfo struct { From cd7b8eeed58c25b35b6fdbdc22b4e9df79b447f5 Mon Sep 17 00:00:00 2001 From: vicente87 Date: Wed, 6 Mar 2024 16:25:08 +0100 Subject: [PATCH 23/60] annotation error1 --- pkg/handlers/status.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/handlers/status.go b/pkg/handlers/status.go index f5e44c71..877492a6 100644 --- a/pkg/handlers/status.go +++ b/pkg/handlers/status.go @@ -22,8 +22,10 @@ import ( "fmt" "os" "encoding/json" + "context" "net/http" "k8s.io/client-go/kubernetes" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" // versioned "k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1" ) From c0ee54a5754f02e20ba33af921fa0186dc116d64 Mon Sep 17 00:00:00 2001 From: vicente87 Date: Wed, 6 Mar 2024 16:28:22 +0100 Subject: [PATCH 24/60] annotation versioned --- pkg/handlers/status.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/handlers/status.go b/pkg/handlers/status.go index 877492a6..27747531 100644 --- a/pkg/handlers/status.go +++ b/pkg/handlers/status.go @@ -26,7 +26,7 @@ import ( "net/http" "k8s.io/client-go/kubernetes" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -// versioned "k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1" + versioned "k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1" ) type NodeInfo struct { From d928a83e689ea036a718889621ccafc7fbca58d2 Mon Sep 17 00:00:00 2001 From: vicente87 Date: Wed, 6 Mar 2024 16:32:14 +0100 Subject: [PATCH 25/60] annotation import1 --- pkg/handlers/status.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/handlers/status.go b/pkg/handlers/status.go index 27747531..b5949973 100644 --- a/pkg/handlers/status.go +++ b/pkg/handlers/status.go @@ -40,7 +40,7 @@ type NodeInfo struct { } -// StatusHandler Status handler for kubernetes deployment +// StatusHandler Status handler for kubernetes deployment. func StatusHandler(c *gin.Context, kubeClientset *kubernetes.Clientset, metricsClientset *versioned.MetricsV1beta1Client) { // Get nodes list @@ -58,7 +58,7 @@ func StatusHandler(c *gin.Context, kubeClientset *kubernetes.Clientset, metricsC } var nodeInfoList []NodeInfo - // Parameters CPU and Memory + // Parameters CPU and Memory. for id, node := range nodes.Items{ nodeName :=node.Name cpu_alloc :=node.Status.Allocatable.Cpu().MilliValue() @@ -81,7 +81,7 @@ func StatusHandler(c *gin.Context, kubeClientset *kubernetes.Clientset, metricsC nodeInfoList = append(nodeInfoList, nodeInfo) } - // Encode list of NodeInfo structures in json format + // Encode list of NodeInfo structures in json format. jsonData, err := json.MarshalIndent(nodeInfoList, "", " ") if err != nil { fmt.Fprintf(os.Stderr, "Error encoding json: %v\n", err) From 933e642d52d6f83ba0b891d19b50d1d7b0540df4 Mon Sep 17 00:00:00 2001 From: vicente87 Date: Thu, 7 Mar 2024 10:02:30 +0100 Subject: [PATCH 26/60] annotation update go version --- go.mod | 34 ++++++------ go.sum | 172 ++++++++++++++++++++++----------------------------------- 2 files changed, 84 insertions(+), 122 deletions(-) diff --git a/go.mod b/go.mod index 90313cd6..2409e4d6 100644 --- a/go.mod +++ b/go.mod @@ -1,11 +1,13 @@ module github.com/grycap/oscar/v3 -go 1.18 +go 1.21 + +toolchain go1.22.1 require ( github.com/aws/aws-sdk-go v1.44.189 github.com/gin-gonic/gin v1.9.1 - github.com/go-logr/logr v1.2.3 // indirect + github.com/go-logr/logr v1.3.0 // indirect github.com/go-playground/validator/v10 v10.14.0 // indirect github.com/goccy/go-yaml v1.9.8 github.com/google/gofuzz v1.2.0 // indirect @@ -20,23 +22,23 @@ require ( github.com/shirou/gopsutil/v3 v3.22.12 // indirect github.com/tinylib/msgp v1.1.8 // indirect golang.org/x/crypto v0.17.0 // indirect - golang.org/x/net v0.17.0 // indirect - golang.org/x/oauth2 v0.8.0 + golang.org/x/net v0.19.0 // indirect + golang.org/x/oauth2 v0.10.0 gopkg.in/ini.v1 v1.67.0 // indirect - k8s.io/api v0.26.1 - k8s.io/apimachinery v0.26.1 - k8s.io/client-go v0.26.1 - k8s.io/klog/v2 v2.90.0 // indirect - k8s.io/utils v0.0.0-20230115233650-391b47cb4029 // indirect + k8s.io/api v0.29.2 + k8s.io/apimachinery v0.29.2 + k8s.io/client-go v0.29.2 + k8s.io/klog/v2 v2.110.1 // indirect + k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect ) require ( github.com/fatih/color v1.14.1 // indirect - github.com/google/go-cmp v0.5.9 // indirect + github.com/google/go-cmp v0.6.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/rs/xid v1.4.0 // indirect golang.org/x/time v0.3.0 // indirect - k8s.io/kube-openapi v0.0.0-20230127205639-68031ae9242a // indirect + k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect sigs.k8s.io/yaml v1.3.0 // indirect ) @@ -44,6 +46,7 @@ require ( github.com/apache/yunikorn-core v1.1.0 github.com/barkimedes/go-deepcopy v0.0.0-20220514131651-17c30cfc62df github.com/coreos/go-oidc/v3 v3.5.0 + k8s.io/metrics v0.29.2 knative.dev/serving v0.36.0 ) @@ -53,7 +56,7 @@ require ( github.com/bytedance/sonic v1.9.1 // indirect github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/emicklei/go-restful/v3 v3.9.0 // indirect + github.com/emicklei/go-restful/v3 v3.11.0 // indirect github.com/evanphx/json-patch v5.6.0+incompatible // indirect github.com/evanphx/json-patch/v5 v5.6.0 // indirect github.com/gabriel-vasile/mimetype v1.4.2 // indirect @@ -68,13 +71,12 @@ require ( github.com/goccy/go-json v0.10.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.3 // indirect - github.com/google/gnostic v0.6.9 // indirect + github.com/google/gnostic-models v0.6.8 // indirect github.com/google/go-containerregistry v0.13.0 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/kr/pretty v0.3.1 // indirect github.com/leodido/go-urn v1.2.4 // indirect github.com/lufia/plan9stats v0.0.0-20230110061619-bbe2e5e100de // indirect github.com/mailru/easyjson v0.7.7 // indirect @@ -109,12 +111,12 @@ require ( google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect google.golang.org/grpc v1.56.3 // indirect - google.golang.org/protobuf v1.30.0 // indirect + google.golang.org/protobuf v1.31.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect knative.dev/networking v0.0.0-20230123233838-db2bcbea2560 // indirect knative.dev/pkg v0.0.0-20230125083639-408ad0773f47 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect ) diff --git a/go.sum b/go.sum index 3aa9d586..8a96bb36 100644 --- a/go.sum +++ b/go.sum @@ -1,14 +1,13 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go/compute/metadata v0.2.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= contrib.go.opencensus.io/exporter/ocagent v0.7.1-0.20200907061046-05415f1de66d h1:LblfooH1lKOpp1hIhukktmSAxFkqMPFk9KR6iZ0MJNI= +contrib.go.opencensus.io/exporter/ocagent v0.7.1-0.20200907061046-05415f1de66d/go.mod h1:IshRmMJBhDfFj5Y67nVhMYTTIze91RUeT73ipWKs/GY= contrib.go.opencensus.io/exporter/prometheus v0.4.0 h1:0QfIkj9z/iVZgK31D9H9ohjjIDApI2GOPScCKwxedbs= +contrib.go.opencensus.io/exporter/prometheus v0.4.0/go.mod h1:o7cosnyfuPVK0tB8q0QmaQNhGnptITnPQB+z1+qeFB0= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/HdrHistogram/hdrhistogram-go v1.0.1/go.mod h1:BWJ+nMSHY3L41Zj7CA3uXnloDp7xxV0YvstAE7nKTaM= -github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/apache/yunikorn-core v1.1.0 h1:FnmDB3nj+YNL58kF75/St+perWP/RzOB17y2Ch63DB8= github.com/apache/yunikorn-core v1.1.0/go.mod h1:XszRAUODosjF1R9E+9ekuIzO4rl7aL5znFD1Iesn0X4= github.com/apache/yunikorn-scheduler-interface v0.0.0-20220818152917-b140f6b90fc4/go.mod h1:VpJqm5k7wjPvoEdgAVHRU2rlbs3LLGJaz2d9F39hmGs= @@ -19,42 +18,34 @@ github.com/aws/aws-sdk-go v1.44.189/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8 github.com/barkimedes/go-deepcopy v0.0.0-20220514131651-17c30cfc62df h1:GSoSVRLoBaFpOOds6QyY1L8AX7uoY+Ln3BHc22W40X0= github.com/barkimedes/go-deepcopy v0.0.0-20220514131651-17c30cfc62df/go.mod h1:hiVxq5OP2bUGBRNS3Z/bt/reCLFNbdcST6gISi1fiOM= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= +github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/blendle/zapdriver v1.3.1 h1:C3dydBOWYRiOk+B8X9IVZ5IOe+7cl+tGOexN4QqHfpE= github.com/blendle/zapdriver v1.3.1/go.mod h1:mdXfREi6u5MArG4j9fewC+FGnXaBR+T4Ox4J2u4eHCc= -github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= github.com/bytedance/sonic v1.9.1 h1:6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s= github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.4.1 h1:iKLQ0xPNFxR/2hzXZMrBo8f1j86j5WHzznCCQxV/b8g= -github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= -github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= +github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= +github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams= github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/coreos/go-oidc/v3 v3.5.0 h1:VxKtbccHZxs8juq7RdJntSqtXFtde9YpNpGn0yqgEHw= github.com/coreos/go-oidc/v3 v3.5.0/go.mod h1:ecXRtV4romGPeO6ieExAsUK9cb/3fp9hXNz1tlv8PIM= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= -github.com/emicklei/go-restful/v3 v3.9.0 h1:XwGDlfxEnQZzuopoqxwSEllNcCOM9DhhFyhFIIGKwxE= -github.com/emicklei/go-restful/v3 v3.9.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= -github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= +github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/evanphx/json-patch v0.5.2/go.mod h1:ZWS5hhDbVDyob71nXKNL0+PWn6ToqBHMikGIFbs31qQ= github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U= @@ -64,10 +55,8 @@ github.com/evanphx/json-patch/v5 v5.6.0/go.mod h1:G79N1coSVB93tBe7j6PhzjmR3/2Vvl github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= github.com/fatih/color v1.14.1 h1:qfhVLaG5s+nCROl1zJsZRxFeYrHLqWroPOQ8BWiNb4w= github.com/fatih/color v1.14.1/go.mod h1:2oHN61fhTpgcxD3TSWCgKDiH1+x4OiDVVGH8WlgGZGg= -github.com/flowstack/go-jsonschema v0.1.1/go.mod h1:yL7fNggx1o8rm9RlgXv7hTBWxdBM0rVwpMwimd3F3N0= github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= -github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= @@ -77,11 +66,12 @@ github.com/go-jose/go-jose/v3 v3.0.1 h1:pWmKFVtt+Jl0vBZTIpz/eAKwsm6LkIxDVVbFHKkc github.com/go-jose/go-jose/v3 v3.0.1/go.mod h1:RNkWWRld676jZEYoV3+XK8L2ZnNSvIsxFMht0mSX+u8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= +github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA= -github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= -github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= +github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= +github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= @@ -92,6 +82,7 @@ github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/ github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= +github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= @@ -102,6 +93,8 @@ github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg/+t63MyGU2n5js= github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/goccy/go-yaml v1.9.8 h1:5gMyLUeU1/6zl+WFfR1hN7D2kf+1/eRGa7DFtToiBvQ= @@ -111,49 +104,40 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA= -github.com/google/gnostic v0.6.9 h1:ZK/5VhkoX835RikCHpSUJV9a+S3e1zLh59YnyWeBW+0= -github.com/google/gnostic v0.6.9/go.mod h1:Nm8234We1lq6iB9OmlgNv3nH91XLLVZHCDayfA3xq+E= +github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= +github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-containerregistry v0.13.0 h1:y1C7Z3e149OJbOPDBxLYR8ITPz8dTKqQwjErKVHJC8k= github.com/google/go-containerregistry v0.13.0/go.mod h1:J9FQ+eSS4a1aC2GNZxvNpbWhgp0487v+cgiilB4FqDo= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec= +github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= -github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 h1:YBftPWNWd4WwGqtY2yeZL2ef8rHAxPBD8KFhJpmcqms= github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0/go.mod h1:YN5jB8ie0yfIUg6VvR9Kz84aCaG7AsGZnLjhHbUqwPg= github.com/grycap/cdmi-client-go v0.1.1 h1:kHIrrLhvaCD0VyzEa5HOg7d/VgRE11yh9Ztdyoqii0o= @@ -166,6 +150,7 @@ github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfC github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA= +github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= @@ -179,7 +164,6 @@ github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8t github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= @@ -205,6 +189,7 @@ github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APP github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= +github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/minio/madmin-go v1.7.5 h1:IF8j2HR0jWc7msiOcy0KJ8EyY7Q3z+j+lsmSDksQm+I= github.com/minio/madmin-go v1.7.5/go.mod h1:3SO8SROxHN++tF6QxdTii2SSUaYSrr8lnE9EJWjvz0k= github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34= @@ -212,6 +197,7 @@ github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEp github.com/minio/minio-go/v7 v7.0.47 h1:sLiuCKGSIcn/MI6lREmTzX91DX/oRau4ia0j6e6eOSs= github.com/minio/minio-go/v7 v7.0.47/go.mod h1:nCrRzjoSUQh8hgKKtu3Y708OLvRLtuASMg2/nvmbarw= github.com/minio/sha256-simd v1.0.0 h1:v1ta+49hkWZyvaKwrQB8elexRqm6Y0aMLjCNsrYxo6g= +github.com/minio/sha256-simd v1.0.0/go.mod h1:OuYzVNI5vcoYIAmbIvHPl3N3jUzVedXbKy5RFepssQM= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -222,10 +208,13 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU= +github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc= -github.com/onsi/ginkgo/v2 v2.4.0 h1:+Ig9nvqgS5OBSACXNk15PLdp0U9XPYROt9CFzVdFGIs= -github.com/onsi/gomega v1.23.0 h1:/oxKu9c2HVap+F3PfKort2Hw5DEU+HGlW8n+tguWsys= +github.com/onsi/ginkgo/v2 v2.13.0 h1:0jY9lJquiL8fcf3M4LAXN5aMlS/b2BV86HFFPCPMgE4= +github.com/onsi/ginkgo/v2 v2.13.0/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o= +github.com/onsi/gomega v1.29.0 h1:KIA/t2t5UBzoirT4H9tsML45GEbo3ouUnBHsCfD2tVg= +github.com/onsi/gomega v1.29.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/openfaas/faas-netes v0.0.0-20230128105321-d45bc4d2a2b1 h1:qhMHfkaiqCE7wdx7p7OA6J3U6/QJzN9gxtYeem6QNFI= @@ -235,7 +224,6 @@ github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZ github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= github.com/philhofer/fwd v1.1.2 h1:bnDivRJ1EWPjUIRXV5KfORO897HTbpFAQddBdE8t7Gw= github.com/philhofer/fwd v1.1.2/go.mod h1:qkPdfjR2SIEbspLqpe1tO4n5yICnr2DY7mqEx2tUTP0= -github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -255,6 +243,7 @@ github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1: github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= +github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.39.0 h1:oOyhkDq05hPZKItWVBkJ6g6AtGxi+fy7F4JvUV8uhsI= github.com/prometheus/common v0.39.0/go.mod h1:6XBZ7lYdLCbkAVhwRsWTZn+IN5AB9F/NXd5w0BbEX0Y= @@ -264,10 +253,10 @@ github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+Gx github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= github.com/prometheus/statsd_exporter v0.21.0 h1:hA05Q5RFeIjgwKIYEdFd59xu5Wwaznf33yKI+pyX6T8= -github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= +github.com/prometheus/statsd_exporter v0.21.0/go.mod h1:rbT83sZq2V+p73lHhPZfMc3MLCHmSHelCh9hSGYNLTQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= -github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/rs/xid v1.4.0 h1:qd7wPTDkN6KQx2VmMBLrpHkiyQwgFXRnkOLacUiaSNY= github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/secure-io/sio-go v0.3.1 h1:dNvY9awjabXTYGsTF1PiCySl9Ltofk9GA3VdWlo7rRc= @@ -275,9 +264,8 @@ github.com/secure-io/sio-go v0.3.1/go.mod h1:+xbkjDzPjwh4Axd07pRKSNriS9SCiYksWnZ github.com/shirou/gopsutil/v3 v3.22.12 h1:oG0ns6poeUSxf78JtOsfygNWuEHYYz8hnnNg7P04TJs= github.com/shirou/gopsutil/v3 v3.22.12/go.mod h1:Xd7P1kwZcp5VW52+9XsirIKd/BROzbb2wdX3Kqlz9uI= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= -github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= @@ -285,15 +273,15 @@ github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpE github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/tinylib/msgp v1.1.8 h1:FCXC1xanKO4I8plpHGH2P7koL/RzZs12l/+r7vakfm0= github.com/tinylib/msgp v1.1.8/go.mod h1:qkpG+2ldGg4xRFmx+jfTvZPxfGFhi64BcnL9vkCm/Tw= github.com/tklauser/go-sysconf v0.3.11 h1:89WgdJhk5SNwJfu+GKyYveZ4IaJ7xAkecBo+KdJV0CM= @@ -306,22 +294,20 @@ github.com/uber/jaeger-client-go v2.25.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMW github.com/uber/jaeger-lib v2.4.0+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U= github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= -github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= -github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= -github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg= github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M= -go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= +go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.5.1/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= +go.uber.org/goleak v1.2.0/go.mod h1:XJYK+MuIchqpmGmUSAzotztawfKvYLUIgg7guXrwVUo= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.4.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= @@ -357,35 +343,31 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= +golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= +golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220812174116-3211cb980234/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.3.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= -golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= -golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= +golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.3.0/go.mod h1:rQrIauxkUhJ6CuwEXwymO2/eh4xz2ZWF1nBkcxS+tGk= -golang.org/x/oauth2 v0.8.0 h1:6dkIjl3j3LtZ/O3sTgZTMsLKSftL/B8Zgq4huOIIUu8= -golang.org/x/oauth2 v0.8.0/go.mod h1:yr7u4HXZRm1R1kBWqr/xKNqewf0plRYoB7sla+BCIXE= +golang.org/x/oauth2 v0.10.0 h1:zHCpF2Khkwy4mMB4bv0U37YtJdTGW8jI0glAApi0Kh8= +golang.org/x/oauth2 v0.10.0/go.mod h1:kTpgurOux7LqtuxjuyZa4Gj2gdezIt/jQtGnNFfypQI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -404,13 +386,9 @@ golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220406163625-3f8b81556e12/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -435,8 +413,6 @@ golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= @@ -459,7 +435,8 @@ golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.4.0/go.mod h1:UE5sM2OK9E/d67R0ANs2xJizIymRP5gJU295PvKXxjQ= -golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= +golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA= +golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -469,49 +446,32 @@ golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNq gomodules.xyz/jsonpatch/v2 v2.2.0 h1:4pT439QV83L+G9FkcCriY6EkpcK6r6bK+A5FBUMI7qY= gomodules.xyz/jsonpatch/v2 v2.2.0/go.mod h1:WXp+iVDkoLQqPudfQ9GBlwB2eZ5DKOnjQZCYdOS8GPY= google.golang.org/api v0.70.0 h1:67zQnAE0T2rB0A3CwLSas0K+SbVzSxP+zTLkQLexeiw= +google.golang.org/api v0.70.0/go.mod h1:Bs4ZM2HGifEvXwd50TtW70ovgJffJYw2oRCOFU/SkfA= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20220107163113-42d7afdf6368/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20230526203410-71b5a4ffd15e h1:Ao9GzfUMPH3zjVfzXG5rlWlk+Q8MXWKwWpwVQE1MXfw= google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc h1:kVKPf/IiYSBWEWtkIn6wZXwWGCnLKcC8oWfZvXjsGnM= +google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc/go.mod h1:vHYtlOoi6TsQ3Uk2yxR7NI5z8uoV+3pZtR4jmHIkRig= google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc h1:XSJ8Vk1SWuNr8S18z1NZSziL0CPIXLCCMDOEFtHBOFc= google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= -google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= google.golang.org/grpc v1.56.3 h1:8I4C0Yq1EjstUzUJzpcRVbuYA2mODtEmpWiQoN/b2nc= google.golang.org/grpc v1.56.3/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= -google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= @@ -523,12 +483,10 @@ gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= @@ -537,18 +495,20 @@ honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -k8s.io/api v0.26.1 h1:f+SWYiPd/GsiWwVRz+NbFyCgvv75Pk9NK6dlkZgpCRQ= -k8s.io/api v0.26.1/go.mod h1:xd/GBNgR0f707+ATNyPmQ1oyKSgndzXij81FzWGsejg= -k8s.io/apimachinery v0.26.1 h1:8EZ/eGJL+hY/MYCNwhmDzVqq2lPl3N3Bo8rvweJwXUQ= -k8s.io/apimachinery v0.26.1/go.mod h1:tnPmbONNJ7ByJNz9+n9kMjNP8ON+1qoAIIC70lztu74= -k8s.io/client-go v0.26.1 h1:87CXzYJnAMGaa/IDDfRdhTzxk/wzGZ+/HUQpqgVSZXU= -k8s.io/client-go v0.26.1/go.mod h1:IWNSglg+rQ3OcvDkhY6+QLeasV4OYHDjdqeWkDQZwGE= -k8s.io/klog/v2 v2.90.0 h1:VkTxIV/FjRXn1fgNNcKGM8cfmL1Z33ZjXRTVxKCoF5M= -k8s.io/klog/v2 v2.90.0/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= -k8s.io/kube-openapi v0.0.0-20230127205639-68031ae9242a h1:ucju6V3yLQxqxGFVzFQLDNcfwegGDUXQikcrOqJqrP0= -k8s.io/kube-openapi v0.0.0-20230127205639-68031ae9242a/go.mod h1:/BYxry62FuDzmI+i9B+X2pqfySRmSOW2ARmj5Zbqhj0= -k8s.io/utils v0.0.0-20230115233650-391b47cb4029 h1:L8zDtT4jrxj+TaQYD0k8KNlr556WaVQylDXswKmX+dE= -k8s.io/utils v0.0.0-20230115233650-391b47cb4029/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +k8s.io/api v0.29.2 h1:hBC7B9+MU+ptchxEqTNW2DkUosJpp1P+Wn6YncZ474A= +k8s.io/api v0.29.2/go.mod h1:sdIaaKuU7P44aoyyLlikSLayT6Vb7bvJNCX105xZXY0= +k8s.io/apimachinery v0.29.2 h1:EWGpfJ856oj11C52NRCHuU7rFDwxev48z+6DSlGNsV8= +k8s.io/apimachinery v0.29.2/go.mod h1:6HVkd1FwxIagpYrHSwJlQqZI3G9LfYWRPAkUvLnXTKU= +k8s.io/client-go v0.29.2 h1:FEg85el1TeZp+/vYJM7hkDlSTFZ+c5nnK44DJ4FyoRg= +k8s.io/client-go v0.29.2/go.mod h1:knlvFZE58VpqbQpJNbCbctTVXcd35mMyAAwBdpt4jrA= +k8s.io/klog/v2 v2.110.1 h1:U/Af64HJf7FcwMcXyKm2RPM22WZzyR7OSpYj5tg3cL0= +k8s.io/klog/v2 v2.110.1/go.mod h1:YGtd1984u+GgbuZ7e08/yBuAfKLSO0+uR1Fhi6ExXjo= +k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 h1:aVUu9fTY98ivBPKR9Y5w/AuzbMm96cd3YHRTU83I780= +k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00/go.mod h1:AsvuZPBlUDVuCdzJ87iajxtXuR9oktsTctW/R9wwouA= +k8s.io/metrics v0.29.2 h1:oLSTHEr40V7c7C8wDRRhiAefjGRHROK5zeV8NT0tpzc= +k8s.io/metrics v0.29.2/go.mod h1:cWzACDpKElWhm0CElwfK+7I39wDNbmDDCX7hywjvgR4= +k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI= +k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= knative.dev/networking v0.0.0-20230123233838-db2bcbea2560 h1:iprdS5tKTXtgV9dGryuwJJJTTdl5LusCHOelKdezR3I= knative.dev/networking v0.0.0-20230123233838-db2bcbea2560/go.mod h1:rn1yRurhkxmSFkpqs/YdG7b9DiYj0VlmLFzBdOQjpOo= knative.dev/pkg v0.0.0-20230125083639-408ad0773f47 h1:zlRO7wXOHVYgKvsC3nIaYGqeQGlLJL8EIUY30Rh37Is= @@ -558,7 +518,7 @@ knative.dev/serving v0.36.0/go.mod h1:ueqMvTqzZE0GFfPqSsc+ZjX20Z8XxCuX86+S+TI7B3 rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= -sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE= -sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E= +sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= +sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= From b4186ca2409a3e36bfd4c51d2a070032a2c423c9 Mon Sep 17 00:00:00 2001 From: vicente87 Date: Thu, 7 Mar 2024 13:07:10 +0100 Subject: [PATCH 27/60] annotation fix error --- pkg/handlers/status.go | 102 ++++++++++++++++++++--------------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/pkg/handlers/status.go b/pkg/handlers/status.go index b5949973..8d3bbd63 100644 --- a/pkg/handlers/status.go +++ b/pkg/handlers/status.go @@ -17,76 +17,76 @@ limitations under the License. package handlers import ( - "github.com/gin-gonic/gin" - "strconv" - "fmt" - "os" - "encoding/json" - "context" + "context" + "encoding/json" + "fmt" "net/http" - "k8s.io/client-go/kubernetes" + "os" + "strconv" + + "github.com/gin-gonic/gin" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - versioned "k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1" + "k8s.io/client-go/kubernetes" + versioned "k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1" ) type NodeInfo struct { - NodeName string `json:"nodeName"` - CPUCapacity string `json:"cpuCapacity"` - CPUUsage string `json:"cpuUsage"` - CPUPercentage string `json:"cpuPercentage"` - MemoryCapacity string `json:"memoryCapacity"` - MemoryUsage string `json:"memoryUsage"` - MemoryPercentage string `json:"memoryPercentage"` - + NodeName string `json:"nodeName"` + CPUCapacity string `json:"cpuCapacity"` + CPUUsage string `json:"cpuUsage"` + CPUPercentage string `json:"cpuPercentage"` + MemoryCapacity string `json:"memoryCapacity"` + MemoryUsage string `json:"memoryUsage"` + MemoryPercentage string `json:"memoryPercentage"` } // StatusHandler Status handler for kubernetes deployment. -func StatusHandler(c *gin.Context, kubeClientset *kubernetes.Clientset, metricsClientset *versioned.MetricsV1beta1Client) { - +func StatusHandler(c *gin.Context, kubeClientset kubernetes.Clientset, metricsClientset versioned.MetricsV1beta1Client) { + // Get nodes list nodes, err := kubeClientset.CoreV1().Nodes().List(context.Background(), metav1.ListOptions{}) if err != nil { - fmt.Fprintf(os.Stderr, "Error getting nodes list: %v\n", err) - os.Exit(1) + fmt.Fprintf(os.Stderr, "Error getting nodes list: %v\n", err) + os.Exit(1) } - + // Get metrics nodes nodeMetricsList, err := metricsClientset.NodeMetricses().List(context.Background(), metav1.ListOptions{}) if err != nil { - fmt.Fprintf(os.Stderr, "Error getting metrics nodes: %v\n", err) - os.Exit(1) + fmt.Fprintf(os.Stderr, "Error getting metrics nodes: %v\n", err) + os.Exit(1) } - + var nodeInfoList []NodeInfo // Parameters CPU and Memory. - for id, node := range nodes.Items{ - nodeName :=node.Name - cpu_alloc :=node.Status.Allocatable.Cpu().MilliValue() - cpu_usage :=nodeMetricsList.Items[id].Usage["cpu"] - cpu_usage_percent :=(float64(cpu_usage.MilliValue())/float64(cpu_alloc))*100 - - memory_alloc :=node.Status.Allocatable.Memory().Value() - memory_usage :=nodeMetricsList.Items[id].Usage["memory"] - memory_usage_percent :=(float64(memory_usage.Value())/float64(memory_alloc))*100 - - nodeInfo := NodeInfo{ - NodeName: nodeName, - CPUCapacity: strconv.Itoa(int(cpu_alloc)), - CPUUsage: strconv.Itoa(int(cpu_usage.MilliValue())), - CPUPercentage: fmt.Sprintf("%.2f", cpu_usage_percent), - MemoryCapacity: strconv.Itoa(int(memory_alloc)), - MemoryUsage: strconv.Itoa(int(memory_usage.Value())), - MemoryPercentage: fmt.Sprintf("%.2f",memory_usage_percent), - } - - nodeInfoList = append(nodeInfoList, nodeInfo) - } - // Encode list of NodeInfo structures in json format. + for id, node := range nodes.Items { + nodeName := node.Name + cpu_alloc := node.Status.Allocatable.Cpu().MilliValue() + cpu_usage := nodeMetricsList.Items[id].Usage["cpu"] + cpu_usage_percent := (float64(cpu_usage.MilliValue()) / float64(cpu_alloc)) * 100 + + memory_alloc := node.Status.Allocatable.Memory().Value() + memory_usage := nodeMetricsList.Items[id].Usage["memory"] + memory_usage_percent := (float64(memory_usage.Value()) / float64(memory_alloc)) * 100 + + nodeInfo := NodeInfo{ + NodeName: nodeName, + CPUCapacity: strconv.Itoa(int(cpu_alloc)), + CPUUsage: strconv.Itoa(int(cpu_usage.MilliValue())), + CPUPercentage: fmt.Sprintf("%.2f", cpu_usage_percent), + MemoryCapacity: strconv.Itoa(int(memory_alloc)), + MemoryUsage: strconv.Itoa(int(memory_usage.Value())), + MemoryPercentage: fmt.Sprintf("%.2f", memory_usage_percent), + } + + nodeInfoList = append(nodeInfoList, nodeInfo) + } + // Encode list of NodeInfo structures in json format. jsonData, err := json.MarshalIndent(nodeInfoList, "", " ") - if err != nil { - fmt.Fprintf(os.Stderr, "Error encoding json: %v\n", err) - os.Exit(1) - } + if err != nil { + fmt.Fprintf(os.Stderr, "Error encoding json: %v\n", err) + os.Exit(1) + } c.JSON(http.StatusOK, jsonData) //c.String(http.StatusOK, "Ok") } From 08185c792746d32a2046bc82217edf5b6df06f6e Mon Sep 17 00:00:00 2001 From: catttam Date: Thu, 7 Mar 2024 15:52:40 +0100 Subject: [PATCH 28/60] Fixed code --- main.go | 8 ++-- pkg/handlers/health.go | 6 +-- pkg/handlers/status.go | 85 +++++++++++++++++++++--------------------- 3 files changed, 49 insertions(+), 50 deletions(-) diff --git a/main.go b/main.go index ea41fbb9..cb6481f8 100644 --- a/main.go +++ b/main.go @@ -99,6 +99,9 @@ func main() { system.GET("/logs/:serviceName/:jobName", handlers.MakeGetLogsHandler(back, kubeClientset, cfg.ServicesNamespace)) system.DELETE("/logs/:serviceName/:jobName", handlers.MakeDeleteJobHandler(back, kubeClientset, cfg.ServicesNamespace)) + // Status path for cluster status (Memory and CPU) checks + system.GET("/status", handlers.MakeStatusHandler(kubeClientset, metricsClientset)) + // Job path for async invocations r.POST("/job/:serviceName", handlers.MakeJobHandler(cfg, kubeClientset, back, resMan)) @@ -109,7 +112,7 @@ func main() { } // System info path - system.GET("/info", handlers.MakeInfoHandler(kubeClientset)) + system.GET("/info", handlers.MakeInfoHandler(kubeClientset, back)) // Serve OSCAR User Interface r.Static("/ui", "./assets") @@ -122,9 +125,6 @@ func main() { // Health path for k8s health checks r.GET("/health", handlers.HealthHandler) - // Status path for cluster status (Memory and CPU) checks - r.GET("/status", handlers.StatusHandler(kubeClientset, metricsClientset)) - // Define and start HTTP server s := &http.Server{ Addr: fmt.Sprintf(":%d", cfg.ServicePort), diff --git a/pkg/handlers/health.go b/pkg/handlers/health.go index 577f4c19..a24d0276 100644 --- a/pkg/handlers/health.go +++ b/pkg/handlers/health.go @@ -17,14 +17,12 @@ limitations under the License. package handlers import ( - "net/http" - + "net/http" + "github.com/gin-gonic/gin" ) - // HealthHandler health handler for kubernetes deployment func HealthHandler(c *gin.Context) { - c.String(http.StatusOK, "Ok") } diff --git a/pkg/handlers/status.go b/pkg/handlers/status.go index 8d3bbd63..c8411e26 100644 --- a/pkg/handlers/status.go +++ b/pkg/handlers/status.go @@ -40,53 +40,54 @@ type NodeInfo struct { MemoryPercentage string `json:"memoryPercentage"` } -// StatusHandler Status handler for kubernetes deployment. -func StatusHandler(c *gin.Context, kubeClientset kubernetes.Clientset, metricsClientset versioned.MetricsV1beta1Client) { +// MakeStatusHandler Status handler for kubernetes deployment. +func MakeStatusHandler(kubeClientset *kubernetes.Clientset, metricsClientset *versioned.MetricsV1beta1Client) gin.HandlerFunc { + return func(c *gin.Context) { + // Get nodes list + nodes, err := kubeClientset.CoreV1().Nodes().List(context.Background(), metav1.ListOptions{}) + if err != nil { + fmt.Fprintf(os.Stderr, "Error getting nodes list: %v\n", err) + os.Exit(1) + } - // Get nodes list - nodes, err := kubeClientset.CoreV1().Nodes().List(context.Background(), metav1.ListOptions{}) - if err != nil { - fmt.Fprintf(os.Stderr, "Error getting nodes list: %v\n", err) - os.Exit(1) - } + // Get metrics nodes + nodeMetricsList, err := metricsClientset.NodeMetricses().List(context.Background(), metav1.ListOptions{}) + if err != nil { + fmt.Fprintf(os.Stderr, "Error getting metrics nodes: %v\n", err) + os.Exit(1) + } - // Get metrics nodes - nodeMetricsList, err := metricsClientset.NodeMetricses().List(context.Background(), metav1.ListOptions{}) - if err != nil { - fmt.Fprintf(os.Stderr, "Error getting metrics nodes: %v\n", err) - os.Exit(1) - } + var nodeInfoList []NodeInfo + // Parameters CPU and Memory. + for id, node := range nodes.Items { + nodeName := node.Name + cpu_alloc := node.Status.Allocatable.Cpu().MilliValue() + cpu_usage := nodeMetricsList.Items[id].Usage["cpu"] + cpu_usage_percent := (float64(cpu_usage.MilliValue()) / float64(cpu_alloc)) * 100 - var nodeInfoList []NodeInfo - // Parameters CPU and Memory. - for id, node := range nodes.Items { - nodeName := node.Name - cpu_alloc := node.Status.Allocatable.Cpu().MilliValue() - cpu_usage := nodeMetricsList.Items[id].Usage["cpu"] - cpu_usage_percent := (float64(cpu_usage.MilliValue()) / float64(cpu_alloc)) * 100 + memory_alloc := node.Status.Allocatable.Memory().Value() + memory_usage := nodeMetricsList.Items[id].Usage["memory"] + memory_usage_percent := (float64(memory_usage.Value()) / float64(memory_alloc)) * 100 - memory_alloc := node.Status.Allocatable.Memory().Value() - memory_usage := nodeMetricsList.Items[id].Usage["memory"] - memory_usage_percent := (float64(memory_usage.Value()) / float64(memory_alloc)) * 100 + nodeInfo := NodeInfo{ + NodeName: nodeName, + CPUCapacity: strconv.Itoa(int(cpu_alloc)), + CPUUsage: strconv.Itoa(int(cpu_usage.MilliValue())), + CPUPercentage: fmt.Sprintf("%.2f", cpu_usage_percent), + MemoryCapacity: strconv.Itoa(int(memory_alloc)), + MemoryUsage: strconv.Itoa(int(memory_usage.Value())), + MemoryPercentage: fmt.Sprintf("%.2f", memory_usage_percent), + } - nodeInfo := NodeInfo{ - NodeName: nodeName, - CPUCapacity: strconv.Itoa(int(cpu_alloc)), - CPUUsage: strconv.Itoa(int(cpu_usage.MilliValue())), - CPUPercentage: fmt.Sprintf("%.2f", cpu_usage_percent), - MemoryCapacity: strconv.Itoa(int(memory_alloc)), - MemoryUsage: strconv.Itoa(int(memory_usage.Value())), - MemoryPercentage: fmt.Sprintf("%.2f", memory_usage_percent), + nodeInfoList = append(nodeInfoList, nodeInfo) } - - nodeInfoList = append(nodeInfoList, nodeInfo) - } - // Encode list of NodeInfo structures in json format. - jsonData, err := json.MarshalIndent(nodeInfoList, "", " ") - if err != nil { - fmt.Fprintf(os.Stderr, "Error encoding json: %v\n", err) - os.Exit(1) + // Encode list of NodeInfo structures in json format. + jsonData, err := json.MarshalIndent(nodeInfoList, "", " ") + if err != nil { + fmt.Fprintf(os.Stderr, "Error encoding json: %v\n", err) + os.Exit(1) + } + c.JSON(http.StatusOK, jsonData) + //c.String(http.StatusOK, "Ok") } - c.JSON(http.StatusOK, jsonData) - //c.String(http.StatusOK, "Ok") } From b35e012e2683255d55d6d8f9943cd96dd0f62b89 Mon Sep 17 00:00:00 2001 From: catttam Date: Thu, 7 Mar 2024 15:55:10 +0100 Subject: [PATCH 29/60] Fixed go.mod --- go.mod | 2 -- 1 file changed, 2 deletions(-) diff --git a/go.mod b/go.mod index 2409e4d6..350c5a2d 100644 --- a/go.mod +++ b/go.mod @@ -2,8 +2,6 @@ module github.com/grycap/oscar/v3 go 1.21 -toolchain go1.22.1 - require ( github.com/aws/aws-sdk-go v1.44.189 github.com/gin-gonic/gin v1.9.1 From 11d8c1622c2bb994b0fcd51dffb3042e93e34bbd Mon Sep 17 00:00:00 2001 From: vicente87 Date: Thu, 7 Mar 2024 16:21:01 +0100 Subject: [PATCH 30/60] annotation description --- pkg/handlers/status.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/handlers/status.go b/pkg/handlers/status.go index c8411e26..e10361ed 100644 --- a/pkg/handlers/status.go +++ b/pkg/handlers/status.go @@ -58,7 +58,7 @@ func MakeStatusHandler(kubeClientset *kubernetes.Clientset, metricsClientset *ve } var nodeInfoList []NodeInfo - // Parameters CPU and Memory. + // GET Parameters CPU and Memory. for id, node := range nodes.Items { nodeName := node.Name cpu_alloc := node.Status.Allocatable.Cpu().MilliValue() From a867421575836a6d99fbd3ed5cf8dc5c08fe0e4a Mon Sep 17 00:00:00 2001 From: vicente87 Date: Thu, 7 Mar 2024 16:24:42 +0100 Subject: [PATCH 31/60] Annotation parameters --- pkg/handlers/status.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/handlers/status.go b/pkg/handlers/status.go index e10361ed..c8411e26 100644 --- a/pkg/handlers/status.go +++ b/pkg/handlers/status.go @@ -58,7 +58,7 @@ func MakeStatusHandler(kubeClientset *kubernetes.Clientset, metricsClientset *ve } var nodeInfoList []NodeInfo - // GET Parameters CPU and Memory. + // Parameters CPU and Memory. for id, node := range nodes.Items { nodeName := node.Name cpu_alloc := node.Status.Allocatable.Cpu().MilliValue() From 903272443dad835635621b582c42349dcc75a924 Mon Sep 17 00:00:00 2001 From: vicente87 Date: Fri, 8 Mar 2024 09:32:44 +0100 Subject: [PATCH 32/60] Verification --- pkg/handlers/status.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/handlers/status.go b/pkg/handlers/status.go index c8411e26..b6d9e9d1 100644 --- a/pkg/handlers/status.go +++ b/pkg/handlers/status.go @@ -88,6 +88,6 @@ func MakeStatusHandler(kubeClientset *kubernetes.Clientset, metricsClientset *ve os.Exit(1) } c.JSON(http.StatusOK, jsonData) - //c.String(http.StatusOK, "Ok") + } } From aaf34861fbc083bd5dd3255219707444a306dbbe Mon Sep 17 00:00:00 2001 From: catttam Date: Fri, 8 Mar 2024 09:52:25 +0100 Subject: [PATCH 33/60] Go mod tidy --- go.mod | 2 ++ 1 file changed, 2 insertions(+) diff --git a/go.mod b/go.mod index 350c5a2d..bca6e3e3 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,8 @@ module github.com/grycap/oscar/v3 go 1.21 +toolchain go1.21.4 + require ( github.com/aws/aws-sdk-go v1.44.189 github.com/gin-gonic/gin v1.9.1 From caf742858fa7954446a4462f13a0d6fae0055062 Mon Sep 17 00:00:00 2001 From: Caterina <36919673+catttam@users.noreply.github.com> Date: Fri, 8 Mar 2024 09:53:55 +0100 Subject: [PATCH 34/60] Update tests.yaml --- .github/workflows/tests.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 73a1fde4..3017a1ad 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -13,7 +13,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v3 with: - go-version: '1.18' + go-version: '1.21' - name: Run tests run: go test ./pkg/... -cover -coverprofile=profile.cov @@ -23,4 +23,4 @@ jobs: with: project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} coverage-reports: profile.cov - force-coverage-parser: go \ No newline at end of file + force-coverage-parser: go From 725803554a0eb96112792e7367d6daec96770886 Mon Sep 17 00:00:00 2001 From: vicente87 Date: Fri, 8 Mar 2024 10:03:27 +0100 Subject: [PATCH 35/60] Actualization go test --- pkg/handlers/status.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/handlers/status.go b/pkg/handlers/status.go index b6d9e9d1..c92258a5 100644 --- a/pkg/handlers/status.go +++ b/pkg/handlers/status.go @@ -50,7 +50,7 @@ func MakeStatusHandler(kubeClientset *kubernetes.Clientset, metricsClientset *ve os.Exit(1) } - // Get metrics nodes + // Get metrics nodes. nodeMetricsList, err := metricsClientset.NodeMetricses().List(context.Background(), metav1.ListOptions{}) if err != nil { fmt.Fprintf(os.Stderr, "Error getting metrics nodes: %v\n", err) From ca606231d3e1174f174b83d0f66b1bae7aaf9e94 Mon Sep 17 00:00:00 2001 From: catttam Date: Fri, 8 Mar 2024 11:31:24 +0100 Subject: [PATCH 36/60] Changed go version on Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e45716a6..a7345f10 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.18 as build +FROM golang:1.21 as build ARG VERSION ARG GIT_COMMIT From 6748b02bf16449f8dc9d389e9419ebffbc5f62f5 Mon Sep 17 00:00:00 2001 From: catttam Date: Mon, 11 Mar 2024 10:01:03 +0100 Subject: [PATCH 37/60] Deleted duplicated JSON encoding --- pkg/handlers/status.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/pkg/handlers/status.go b/pkg/handlers/status.go index c92258a5..231669f9 100644 --- a/pkg/handlers/status.go +++ b/pkg/handlers/status.go @@ -18,7 +18,6 @@ package handlers import ( "context" - "encoding/json" "fmt" "net/http" "os" @@ -81,13 +80,8 @@ func MakeStatusHandler(kubeClientset *kubernetes.Clientset, metricsClientset *ve nodeInfoList = append(nodeInfoList, nodeInfo) } - // Encode list of NodeInfo structures in json format. - jsonData, err := json.MarshalIndent(nodeInfoList, "", " ") - if err != nil { - fmt.Fprintf(os.Stderr, "Error encoding json: %v\n", err) - os.Exit(1) - } - c.JSON(http.StatusOK, jsonData) + + c.JSON(http.StatusOK, nodeInfoList) } } From 28b8d81858cc3d6d418ddb9198220dc1d57dfdbf Mon Sep 17 00:00:00 2001 From: catttam Date: Thu, 11 Apr 2024 12:16:47 +0200 Subject: [PATCH 38/60] Minor change on MinIO policies --- pkg/utils/minio.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/utils/minio.go b/pkg/utils/minio.go index 4537bd64..b705848e 100644 --- a/pkg/utils/minio.go +++ b/pkg/utils/minio.go @@ -264,7 +264,7 @@ func createPolicy(adminClient *madmin.AdminClient, bucketName string, allUsers b "s3:*" ], "Resource": [ - "arn:aws:s3:::` + bucketName + `" + "arn:aws:s3:::` + bucketName + `/*" ] } ] From 9092219ba613b690dd39a85fc9191c9c369f1496 Mon Sep 17 00:00:00 2001 From: catttam Date: Wed, 17 Apr 2024 12:31:13 +0200 Subject: [PATCH 39/60] fixed minio public service policy --- pkg/utils/minio.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/utils/minio.go b/pkg/utils/minio.go index b705848e..7d491383 100644 --- a/pkg/utils/minio.go +++ b/pkg/utils/minio.go @@ -234,7 +234,7 @@ func createPolicy(adminClient *madmin.AdminClient, bucketName string, allUsers b var jsonErr error if allUsers { - rs := "arn:aws:s3:::" + bucketName + rs := "arn:aws:s3:::" + bucketName + "/*" groupName = ALL_USERS_GROUP policyInfo, errInfo := adminClient.InfoCannedPolicyV2(context.TODO(), ALL_USERS_GROUP) From 9dd793e01696c6e6687c812b823dc7e3837035c5 Mon Sep 17 00:00:00 2001 From: catttam Date: Thu, 25 Apr 2024 16:40:27 +0200 Subject: [PATCH 40/60] Added owner label to service and fixed multitenancy bugs --- pkg/handlers/create.go | 23 +++++++++++++++++-- pkg/handlers/delete.go | 30 ++++++------------------ pkg/handlers/read.go | 2 +- pkg/handlers/update.go | 42 ++++++++++++++++++++++------------ pkg/types/service.go | 4 ++++ pkg/utils/auth/multitenancy.go | 16 +++++++++---- pkg/utils/auth/oidc.go | 5 ++-- 7 files changed, 75 insertions(+), 47 deletions(-) diff --git a/pkg/handlers/create.go b/pkg/handlers/create.go index 8c8f04eb..d64d1748 100644 --- a/pkg/handlers/create.go +++ b/pkg/handlers/create.go @@ -75,6 +75,9 @@ func MakeCreateHandler(cfg *types.Config, back types.ServerlessBackend) gin.Hand c.String(http.StatusInternalServerError, fmt.Sprintln(err)) } + // Set UID from owner + service.Owner = uid + mc, err := auth.GetMultitenancyConfigFromContext(c) if err != nil { c.String(http.StatusInternalServerError, fmt.Sprintln(err)) @@ -97,7 +100,20 @@ func MakeCreateHandler(cfg *types.Config, back types.ServerlessBackend) gin.Hand if len(service.AllowedUsers) > 0 { // If AllowedUsers is empty don't add uid service.Labels["uid"] = full_uid[0:8] - service.AllowedUsers = append(service.AllowedUsers, uid) + + // If the uid of the owner is not on the allowed_users list append it + ownerOnList := false + for _, user := range service.AllowedUsers { + if user == service.Owner { + ownerOnList = true + break + } + } + if !ownerOnList { + service.AllowedUsers = append(service.AllowedUsers, uid) + } + // Check if the uid's from allowed_users have and asociated MinIO user + // and create it if not uids := mc.CheckUsersInCache(service.AllowedUsers) if len(uids) > 0 { for _, uid := range uids { @@ -144,7 +160,7 @@ func MakeCreateHandler(cfg *types.Config, back types.ServerlessBackend) gin.Hand log.Println(err.Error()) } } - + createLogger.Println("Service created with name: ", service.Name) c.Status(http.StatusCreated) } } @@ -268,6 +284,9 @@ func createBuckets(service *types.Service, cfg *types.Config, minIOAdminClient * if !isAdminUser { if len(allowed_users) == 0 { err = minIOAdminClient.AddServiceToAllUsersGroup(splitPath[0]) + if err != nil { + return fmt.Errorf("error adding service %s to all users group: %v", splitPath[0], err) + } } else { if !isUpdate { err = minIOAdminClient.CreateServiceGroup(splitPath[0]) diff --git a/pkg/handlers/delete.go b/pkg/handlers/delete.go index d163b731..c060dc9c 100644 --- a/pkg/handlers/delete.go +++ b/pkg/handlers/delete.go @@ -39,26 +39,13 @@ func MakeDeleteHandler(cfg *types.Config, back types.ServerlessBackend) gin.Hand service, _ := back.ReadService(c.Param("serviceName")) authHeader := c.GetHeader("Authorization") - var isAllowed bool if len(strings.Split(authHeader, "Bearer")) > 1 { uid, err := auth.GetUIDFromContext(c) if err != nil { c.String(http.StatusInternalServerError, fmt.Sprintln(err)) } - var isAllowed bool - if len(service.AllowedUsers) == 0 { - isAllowed = true - } else { - for _, id := range service.AllowedUsers { - if uid == id { - isAllowed = true - break - } - } - } - - if !isAllowed { + if service.Owner != uid { c.String(http.StatusForbidden, "User %s doesn't have permision to get this service", uid) return } @@ -78,15 +65,12 @@ func MakeDeleteHandler(cfg *types.Config, back types.ServerlessBackend) gin.Hand log.Printf("the provided MinIO configuration is not valid: %v", err) } - if isAllowed { - // Delete the group and policy - for _, in := range service.Input { - path := strings.Trim(in.Path, " /") - // Split buckets and folders from path - bucket := strings.SplitN(path, "/", 2) - minIOAdminClient.DeleteServiceGroup(bucket[0]) - } - + // Delete the group and policy + for _, in := range service.Input { + path := strings.Trim(in.Path, " /") + // Split buckets and folders from path + bucket := strings.SplitN(path, "/", 2) + minIOAdminClient.DeleteServiceGroup(bucket[0]) } // Disable input notifications diff --git a/pkg/handlers/read.go b/pkg/handlers/read.go index 73a06407..713a2329 100644 --- a/pkg/handlers/read.go +++ b/pkg/handlers/read.go @@ -49,7 +49,7 @@ func MakeReadHandler(back types.ServerlessBackend) gin.HandlerFunc { } var isAllowed bool - if len(service.AllowedUsers) == 0 { + if len(service.AllowedUsers) == 0 || service.Owner == uid { isAllowed = true } else { for _, id := range service.AllowedUsers { diff --git a/pkg/handlers/update.go b/pkg/handlers/update.go index 6cbf751d..b98c9fa3 100644 --- a/pkg/handlers/update.go +++ b/pkg/handlers/update.go @@ -44,6 +44,7 @@ func MakeUpdateHandler(cfg *types.Config, back types.ServerlessBackend) gin.Hand // Read the current service oldService, err := back.ReadService(newService.Name) + if err != nil { // Check if error is caused because the service is not found if errors.IsNotFound(err) || errors.IsGone(err) { @@ -54,6 +55,17 @@ func MakeUpdateHandler(cfg *types.Config, back types.ServerlessBackend) gin.Hand return } + uid, err := auth.GetUIDFromContext(c) + if err != nil { + c.String(http.StatusInternalServerError, fmt.Sprintln("Couldn't get UID from context")) + } + + if oldService.Owner != uid { + c.String(http.StatusForbidden, "User %s doesn't have permision to modify this service", uid) + return + } + + // If the service has changed VO check permisions again if newService.VO != "" && newService.VO != oldService.VO { for _, vo := range cfg.OIDCGroups { if vo == newService.VO { @@ -69,27 +81,29 @@ func MakeUpdateHandler(cfg *types.Config, back types.ServerlessBackend) gin.Hand minIOAdminClient, _ := utils.MakeMinIOAdminClient(cfg) if !isAdminUser { - mc, err := auth.GetMultitenancyConfigFromContext(c) if err != nil { c.String(http.StatusInternalServerError, fmt.Sprintln(err)) } // Check if users in allowed_users have a MinIO associated user - if len(newService.AllowedUsers) == 0 { - uids := mc.CheckUsersInCache(newService.AllowedUsers) - if len(uids) == 0 { - for _, uid := range uids { - sk, _ := auth.GenerateRandomKey(8) - minIOAdminClient.CreateMinIOUser(uid, sk) - mc.CreateSecretForOIDC(uid, sk) - } + // If new allowed users list is empty the service becames public + bucketName := newService.Input[0].Path + if len(newService.AllowedUsers) < 1 { + // Delete service policy and add bucket to all_users_group + err := minIOAdminClient.DeleteServiceGroup(bucketName) + if err != nil { + c.String(http.StatusInternalServerError, fmt.Sprintln(err)) + } + err = minIOAdminClient.AddServiceToAllUsersGroup(bucketName) + if err != nil { + c.String(http.StatusInternalServerError, fmt.Sprintln(err)) } - } - - if len(newService.AllowedUsers) != len(oldService.AllowedUsers) { - //Update users group list - minIOAdminClient.AddUserToGroup(newService.AllowedUsers, "") + } else { + if len(newService.AllowedUsers) != len(oldService.AllowedUsers) { + //Update users group list + minIOAdminClient.AddUserToGroup(newService.AllowedUsers, bucketName) + } } } diff --git a/pkg/types/service.go b/pkg/types/service.go index 68b9e8ff..10c20820 100644 --- a/pkg/types/service.go +++ b/pkg/types/service.go @@ -241,6 +241,10 @@ type Service struct { // Optional Clusters map[string]Cluster `json:"clusters,omitempty"` + // EGI UID of the user that created the service + // If the service is created through basic auth the default owner is "cluster_admin" + Owner string `json:"owner" default:"cluster_admin"` + // List of EGI UID's identifying the users that will have visibility of the service and its MinIO storage provider // Optional (If the list is empty we asume the visibility is public for all cluster users) AllowedUsers []string `json:"allowed_users"` diff --git a/pkg/utils/auth/multitenancy.go b/pkg/utils/auth/multitenancy.go index 405ac91e..d6b487cd 100644 --- a/pkg/utils/auth/multitenancy.go +++ b/pkg/utils/auth/multitenancy.go @@ -62,15 +62,21 @@ func (mc *MultitenancyConfig) ClearCache() { mc.usersCache = nil } +// UserExists checks if a MinIO user has been created and stored on cache. func (mc *MultitenancyConfig) UserExists(uid string) bool { if len(mc.usersCache) < 1 { // If the cache is empty check if a secret for the uid exists - secret_name := FormatUID(uid) - _, err := mc.kubeClientset.CoreV1().Secrets(ServicesNamespace).Get(context.TODO(), secret_name, metav1.GetOptions{}) + secretName := FormatUID(uid) + secret, err := mc.kubeClientset.CoreV1().Secrets(ServicesNamespace).Get(context.TODO(), secretName, metav1.GetOptions{}) if err != nil { return false } - return true + // If the container has been restarted a user can exist + // but not be on the cache due to lack of persistence + if secret != nil { + mc.UpdateCache(uid) + return true + } } else { for _, id := range mc.usersCache { if id == uid { @@ -92,7 +98,7 @@ func (mc *MultitenancyConfig) CheckUsersInCache(uids []string) []string { break } } - if found == false { + if !found { notFoundUsers = append(notFoundUsers, uid) } } @@ -138,7 +144,7 @@ func (mc *MultitenancyConfig) GetUserCredentials(uid string) (string, string, er if access_key != "" && secret_key != "" { return access_key, secret_key, nil } - return "", "", fmt.Errorf("Error decoding secret data") + return "", "", fmt.Errorf("error decoding secret data") } func GenerateRandomKey(length int) (string, error) { diff --git a/pkg/utils/auth/oidc.go b/pkg/utils/auth/oidc.go index 718eb0d4..9fb2a21f 100644 --- a/pkg/utils/auth/oidc.go +++ b/pkg/utils/auth/oidc.go @@ -109,8 +109,9 @@ func getOIDCMiddleware(kubeClientset *kubernetes.Clientset, minIOAdminClient *ut uid := ui.subject // Check if exist MinIO user in cached users list - exists := mc.UserExists(uid) - if !exists { + minioUserExists := mc.UserExists(uid) + + if !minioUserExists { sk, err := GenerateRandomKey(SecretKeyLength) if err != nil { oidcLogger.Println("Error generating random key for MinIO user") From 589d4400aac4e168382cc9727ffceccffca86af7 Mon Sep 17 00:00:00 2001 From: catttam Date: Thu, 9 May 2024 18:58:15 +0200 Subject: [PATCH 41/60] Added validation of images --- pkg/handlers/create.go | 28 ++++++++++++++++++++++++++++ pkg/types/config.go | 10 ++++++++++ pkg/utils/auth/multitenancy.go | 28 ++++++++++++++-------------- 3 files changed, 52 insertions(+), 14 deletions(-) diff --git a/pkg/handlers/create.go b/pkg/handlers/create.go index ef4edc9e..810a3669 100644 --- a/pkg/handlers/create.go +++ b/pkg/handlers/create.go @@ -29,6 +29,7 @@ import ( "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/service/s3" "github.com/gin-gonic/gin" + "github.com/goccy/go-yaml" "github.com/grycap/cdmi-client-go" "github.com/grycap/oscar/v3/pkg/types" "github.com/grycap/oscar/v3/pkg/utils" @@ -65,6 +66,11 @@ func MakeCreateHandler(cfg *types.Config, back types.ServerlessBackend) gin.Hand // Check service values and set defaults checkValues(&service, cfg) + err := checkAdditionalConfig(&service, cfg) + if err != nil { + c.String(http.StatusInternalServerError, fmt.Sprintln(err)) + } + // Check if users in allowed_users have a MinIO associated user minIOAdminClient, _ := utils.MakeMinIOAdminClient(cfg) @@ -217,6 +223,28 @@ func checkValues(service *types.Service, cfg *types.Config) { service.Token = utils.GenerateToken() } +func checkAdditionalConfig(service *types.Service, cfg *types.Config) error { + + additionalConfig := &types.AdditionalConfig{} + configFile, err := os.ReadFile(cfg.AdditionalConfigPath) + if err != nil { + return fmt.Errorf("failed to read the YAML file of additional config: %v", err) + } + if err := yaml.Unmarshal(configFile, additionalConfig); err != nil { + return nil + } + + if len(additionalConfig.Images.AllowedPrefixes) > 0 { + for _, prefix := range additionalConfig.Images.AllowedPrefixes { + if !strings.Contains(service.Image, prefix) { + return fmt.Errorf("image %s is not allowed for pull on the cluster. Check the additional configuration file on '%s'.", service.Image, cfg.AdditionalConfigPath) + } + } + } + + return nil +} + func createBuckets(service *types.Service, cfg *types.Config, minIOAdminClient *utils.MinIOAdminClient, allowed_users []string, isUpdate bool) error { var s3Client *s3.S3 var cdmiClient *cdmi.Client diff --git a/pkg/types/config.go b/pkg/types/config.go index 11f5ed05..2b08c122 100644 --- a/pkg/types/config.go +++ b/pkg/types/config.go @@ -54,6 +54,12 @@ type configVar struct { defaultValue string } +type AdditionalConfig struct { + Images struct { + AllowedPrefixes []string `yaml:"allowed_prefixes"` + } `yaml:"images"` +} + // Config stores the configuration for the OSCAR server type Config struct { // MinIOProvider access info @@ -184,6 +190,9 @@ type Config struct { // Github path of FaaS Supervisor (needed for Interlink config) SupervisorURL string `json:"-"` + + //Path to additional OSCAR configuration setted by users + AdditionalConfigPath string `json:"-"` } var configVars = []configVar{ @@ -230,6 +239,7 @@ var configVars = []configVar{ {"OIDCGroups", "OIDC_GROUPS", false, stringSliceType, ""}, {"IngressHost", "INGRESS_HOST", false, stringType, ""}, {"SupervisorURL", "SUPERVISOR_URL", false, stringType, "https://github.com/grycap/faas-supervisor/releases/download/1.5.8/supervisor"}, + {"AdditionalConfigPath", "ADDITIONAL_CONFIG_PATH", false, stringType, "/var/opt/oscar_config/config.yaml"}, } func readConfigVar(cfgVar configVar) (string, error) { diff --git a/pkg/utils/auth/multitenancy.go b/pkg/utils/auth/multitenancy.go index d6b487cd..c92b9af6 100644 --- a/pkg/utils/auth/multitenancy.go +++ b/pkg/utils/auth/multitenancy.go @@ -64,26 +64,26 @@ func (mc *MultitenancyConfig) ClearCache() { // UserExists checks if a MinIO user has been created and stored on cache. func (mc *MultitenancyConfig) UserExists(uid string) bool { - if len(mc.usersCache) < 1 { - // If the cache is empty check if a secret for the uid exists - secretName := FormatUID(uid) - secret, err := mc.kubeClientset.CoreV1().Secrets(ServicesNamespace).Get(context.TODO(), secretName, metav1.GetOptions{}) - if err != nil { - return false - } - // If the container has been restarted a user can exist - // but not be on the cache due to lack of persistence - if secret != nil { - mc.UpdateCache(uid) - return true - } - } else { + if len(mc.usersCache) > 1 { + // If the cache has users search for the uid for _, id := range mc.usersCache { if id == uid { return true } } } + // If the container has been restarted a user can exist + // but not be on the cache due to lack of persistence + secretName := FormatUID(uid) + secret, err := mc.kubeClientset.CoreV1().Secrets(ServicesNamespace).Get(context.TODO(), secretName, metav1.GetOptions{}) + if err != nil { + return false + } + if secret != nil { + mc.UpdateCache(uid) + return true + } + return false } From c0f011707e1267b1b7dfc2e5fc14c9c5e6af555e Mon Sep 17 00:00:00 2001 From: catttam Date: Fri, 10 May 2024 09:05:14 +0200 Subject: [PATCH 42/60] Fixed additional settings --- pkg/handlers/create.go | 4 +++- pkg/handlers/update.go | 7 +++++++ pkg/types/config.go | 2 +- pkg/types/service_test.go | 1 + 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/handlers/create.go b/pkg/handlers/create.go index 810a3669..c07535ee 100644 --- a/pkg/handlers/create.go +++ b/pkg/handlers/create.go @@ -66,9 +66,11 @@ func MakeCreateHandler(cfg *types.Config, back types.ServerlessBackend) gin.Hand // Check service values and set defaults checkValues(&service, cfg) + // Check if additional config matches err := checkAdditionalConfig(&service, cfg) if err != nil { c.String(http.StatusInternalServerError, fmt.Sprintln(err)) + return } // Check if users in allowed_users have a MinIO associated user @@ -237,7 +239,7 @@ func checkAdditionalConfig(service *types.Service, cfg *types.Config) error { if len(additionalConfig.Images.AllowedPrefixes) > 0 { for _, prefix := range additionalConfig.Images.AllowedPrefixes { if !strings.Contains(service.Image, prefix) { - return fmt.Errorf("image %s is not allowed for pull on the cluster. Check the additional configuration file on '%s'.", service.Image, cfg.AdditionalConfigPath) + return fmt.Errorf("image %s is not allowed for pull on the cluster. Check the additional configuration file on '%s'", service.Image, cfg.AdditionalConfigPath) } } } diff --git a/pkg/handlers/update.go b/pkg/handlers/update.go index b98c9fa3..714afc6f 100644 --- a/pkg/handlers/update.go +++ b/pkg/handlers/update.go @@ -42,6 +42,13 @@ func MakeUpdateHandler(cfg *types.Config, back types.ServerlessBackend) gin.Hand // Check service values and set defaults checkValues(&newService, cfg) + // Check if additional config matches + err := checkAdditionalConfig(&newService, cfg) + if err != nil { + c.String(http.StatusInternalServerError, fmt.Sprintln(err)) + return + } + // Read the current service oldService, err := back.ReadService(newService.Name) diff --git a/pkg/types/config.go b/pkg/types/config.go index 2b08c122..3777791e 100644 --- a/pkg/types/config.go +++ b/pkg/types/config.go @@ -239,7 +239,7 @@ var configVars = []configVar{ {"OIDCGroups", "OIDC_GROUPS", false, stringSliceType, ""}, {"IngressHost", "INGRESS_HOST", false, stringType, ""}, {"SupervisorURL", "SUPERVISOR_URL", false, stringType, "https://github.com/grycap/faas-supervisor/releases/download/1.5.8/supervisor"}, - {"AdditionalConfigPath", "ADDITIONAL_CONFIG_PATH", false, stringType, "/var/opt/oscar_config/config.yaml"}, + {"AdditionalConfigPath", "ADDITIONAL_CONFIG_PATH", false, stringType, "config.yaml"}, } func readConfigVar(cfgVar configVar) (string, error) { diff --git a/pkg/types/service_test.go b/pkg/types/service_test.go index 0a4bfd5e..97d4ad14 100644 --- a/pkg/types/service_test.go +++ b/pkg/types/service_test.go @@ -271,6 +271,7 @@ clusters: auth_user: testuser auth_password: testpass ssl_verify: true +owner: "" interlink_node_name: "" allowed_users: [] ` From f85b6bdde94fd88db6705dec9c0238907eb92a2c Mon Sep 17 00:00:00 2001 From: catttam Date: Fri, 10 May 2024 10:48:22 +0200 Subject: [PATCH 43/60] Changed additional config to a ConfigMap --- pkg/backends/k8s.go | 36 +++++++++++++++++++++++++++++++++++- pkg/backends/knative.go | 15 ++++++++++++++- pkg/handlers/create.go | 30 ------------------------------ pkg/handlers/update.go | 7 ------- 4 files changed, 49 insertions(+), 39 deletions(-) diff --git a/pkg/backends/k8s.go b/pkg/backends/k8s.go index 78e47582..3c43088b 100644 --- a/pkg/backends/k8s.go +++ b/pkg/backends/k8s.go @@ -20,6 +20,7 @@ import ( "context" "fmt" "log" + "strings" "github.com/goccy/go-yaml" "github.com/grycap/oscar/v3/pkg/imagepuller" @@ -29,6 +30,8 @@ import ( "k8s.io/client-go/kubernetes" ) +const ConfigMapNameOSCAR = "additional-oscar-config" + // KubeBackend struct to represent a Kubernetes client to store services as podTemplates type KubeBackend struct { kubeClientset kubernetes.Interface @@ -76,8 +79,15 @@ func (k *KubeBackend) ListServices() ([]*types.Service, error) { // CreateService creates a new service as a k8s podTemplate func (k *KubeBackend) CreateService(service types.Service) error { + + // Check if there is some user defined settings for OSCAR + err := checkAdditionalConfig(ConfigMapNameOSCAR, k.namespace, service, k.config, k.kubeClientset) + if err != nil { + return err + } + // Create the configMap with FDL and user-script - err := createServiceConfigMap(&service, k.namespace, k.kubeClientset) + err = createServiceConfigMap(&service, k.namespace, k.kubeClientset) if err != nil { return err } @@ -251,6 +261,30 @@ func getServiceFromFDL(name string, namespace string, kubeClientset kubernetes.I return service, nil } +func checkAdditionalConfig(configName string, configNamespace string, service types.Service, cfg *types.Config, kubeClientset kubernetes.Interface) error { + // Get the configMapwith the service additional settings + cm, err := kubeClientset.CoreV1().ConfigMaps(configNamespace).Get(context.TODO(), configName, metav1.GetOptions{}) + if err != nil { + return nil + } + + additionalConfig := &types.AdditionalConfig{} + // Unmarshal the FDL stored in the configMap + if err = yaml.Unmarshal([]byte(cm.Data[cfg.AdditionalConfigPath]), additionalConfig); err != nil { + return nil + } + + if len(additionalConfig.Images.AllowedPrefixes) > 0 { + for _, prefix := range additionalConfig.Images.AllowedPrefixes { + if !strings.Contains(service.Image, prefix) { + return fmt.Errorf("image %s is not allowed for pull on the cluster. Check the additional configuration file on '%s'", service.Image, cfg.AdditionalConfigPath) + } + } + } + + return nil +} + func createServiceConfigMap(service *types.Service, namespace string, kubeClientset kubernetes.Interface) error { // Copy script from service script := service.Script diff --git a/pkg/backends/knative.go b/pkg/backends/knative.go index 3053597c..9e1391e9 100644 --- a/pkg/backends/knative.go +++ b/pkg/backends/knative.go @@ -97,8 +97,14 @@ func (kn *KnativeBackend) ListServices() ([]*types.Service, error) { // CreateService creates a new service as a Knative service func (kn *KnativeBackend) CreateService(service types.Service) error { + + // Check if there is some user defined settings for OSCAR + err := checkAdditionalConfig(ConfigMapNameOSCAR, kn.namespace, service, kn.config, kn.kubeClientset) + if err != nil { + return err + } // Create the configMap with FDL and user-script - err := createServiceConfigMap(&service, kn.namespace, kn.kubeClientset) + err = createServiceConfigMap(&service, kn.namespace, kn.kubeClientset) if err != nil { return err } @@ -156,6 +162,13 @@ func (kn *KnativeBackend) ReadService(name string) (*types.Service, error) { // UpdateService updates an existent service func (kn *KnativeBackend) UpdateService(service types.Service) error { + + // Check if there is some user defined settings for OSCAR + err := checkAdditionalConfig(ConfigMapNameOSCAR, kn.namespace, service, kn.config, kn.kubeClientset) + if err != nil { + return err + } + // Get the old knative service oldSvc, err := kn.knClientset.ServingV1().Services(kn.namespace).Get(context.TODO(), service.Name, metav1.GetOptions{}) if err != nil { diff --git a/pkg/handlers/create.go b/pkg/handlers/create.go index c07535ee..ef4edc9e 100644 --- a/pkg/handlers/create.go +++ b/pkg/handlers/create.go @@ -29,7 +29,6 @@ import ( "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/service/s3" "github.com/gin-gonic/gin" - "github.com/goccy/go-yaml" "github.com/grycap/cdmi-client-go" "github.com/grycap/oscar/v3/pkg/types" "github.com/grycap/oscar/v3/pkg/utils" @@ -66,13 +65,6 @@ func MakeCreateHandler(cfg *types.Config, back types.ServerlessBackend) gin.Hand // Check service values and set defaults checkValues(&service, cfg) - // Check if additional config matches - err := checkAdditionalConfig(&service, cfg) - if err != nil { - c.String(http.StatusInternalServerError, fmt.Sprintln(err)) - return - } - // Check if users in allowed_users have a MinIO associated user minIOAdminClient, _ := utils.MakeMinIOAdminClient(cfg) @@ -225,28 +217,6 @@ func checkValues(service *types.Service, cfg *types.Config) { service.Token = utils.GenerateToken() } -func checkAdditionalConfig(service *types.Service, cfg *types.Config) error { - - additionalConfig := &types.AdditionalConfig{} - configFile, err := os.ReadFile(cfg.AdditionalConfigPath) - if err != nil { - return fmt.Errorf("failed to read the YAML file of additional config: %v", err) - } - if err := yaml.Unmarshal(configFile, additionalConfig); err != nil { - return nil - } - - if len(additionalConfig.Images.AllowedPrefixes) > 0 { - for _, prefix := range additionalConfig.Images.AllowedPrefixes { - if !strings.Contains(service.Image, prefix) { - return fmt.Errorf("image %s is not allowed for pull on the cluster. Check the additional configuration file on '%s'", service.Image, cfg.AdditionalConfigPath) - } - } - } - - return nil -} - func createBuckets(service *types.Service, cfg *types.Config, minIOAdminClient *utils.MinIOAdminClient, allowed_users []string, isUpdate bool) error { var s3Client *s3.S3 var cdmiClient *cdmi.Client diff --git a/pkg/handlers/update.go b/pkg/handlers/update.go index 714afc6f..b98c9fa3 100644 --- a/pkg/handlers/update.go +++ b/pkg/handlers/update.go @@ -42,13 +42,6 @@ func MakeUpdateHandler(cfg *types.Config, back types.ServerlessBackend) gin.Hand // Check service values and set defaults checkValues(&newService, cfg) - // Check if additional config matches - err := checkAdditionalConfig(&newService, cfg) - if err != nil { - c.String(http.StatusInternalServerError, fmt.Sprintln(err)) - return - } - // Read the current service oldService, err := back.ReadService(newService.Name) From 1f7310ca5906de37562e7afbf4fbd5c25dd9404e Mon Sep 17 00:00:00 2001 From: catttam Date: Tue, 14 May 2024 13:01:43 +0200 Subject: [PATCH 44/60] Logs to debug --- pkg/handlers/create.go | 3 +++ pkg/types/service.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/handlers/create.go b/pkg/handlers/create.go index ef4edc9e..a6007e4b 100644 --- a/pkg/handlers/create.go +++ b/pkg/handlers/create.go @@ -55,6 +55,8 @@ func MakeCreateHandler(cfg *types.Config, back types.ServerlessBackend) gin.Hand authHeader := c.GetHeader("Authorization") if len(strings.Split(authHeader, "Bearer")) == 1 { isAdminUser = true + service.Owner = "cluster_admin" + createLogger.Printf("Creating service for user: %s", service.Owner) } if err := c.ShouldBindJSON(&service); err != nil { @@ -77,6 +79,7 @@ func MakeCreateHandler(cfg *types.Config, back types.ServerlessBackend) gin.Hand // Set UID from owner service.Owner = uid + createLogger.Printf("Creating service for user: %s", service.Owner) mc, err := auth.GetMultitenancyConfigFromContext(c) if err != nil { diff --git a/pkg/types/service.go b/pkg/types/service.go index 59307fa2..9d38a7a5 100644 --- a/pkg/types/service.go +++ b/pkg/types/service.go @@ -247,7 +247,7 @@ type Service struct { // EGI UID of the user that created the service // If the service is created through basic auth the default owner is "cluster_admin" - Owner string `json:"owner" default:"cluster_admin"` + Owner string `json:"owner"` InterLinkNodeName string `json:"interlink_node_name"` // List of EGI UID's identifying the users that will have visibility of the service and its MinIO storage provider From c96921763361bcf721320e90a01df2a5e7ab0b0c Mon Sep 17 00:00:00 2001 From: catttam Date: Tue, 14 May 2024 16:04:36 +0200 Subject: [PATCH 45/60] Changed update of MinIO users --- pkg/handlers/create.go | 4 +++- pkg/handlers/update.go | 34 ++++++---------------------------- 2 files changed, 9 insertions(+), 29 deletions(-) diff --git a/pkg/handlers/create.go b/pkg/handlers/create.go index a6007e4b..519a1780 100644 --- a/pkg/handlers/create.go +++ b/pkg/handlers/create.go @@ -45,7 +45,7 @@ const ( var errInput = errors.New("unrecognized input (valid inputs are MinIO and dCache)") // Custom logger -var createLogger = log.New(os.Stdout, "[CREATE] ", log.Flags()) +var createLogger = log.New(os.Stdout, "[CREATE-HANDLER] ", log.Flags()) var isAdminUser = false // MakeCreateHandler makes a handler for creating services @@ -284,6 +284,8 @@ func createBuckets(service *types.Service, cfg *types.Config, minIOAdminClient * } // Create group for the service and add users + // Check if users in allowed_users have a MinIO associated user + // If new allowed users list is empty the service becames public if !isAdminUser { if len(allowed_users) == 0 { err = minIOAdminClient.AddServiceToAllUsersGroup(splitPath[0]) diff --git a/pkg/handlers/update.go b/pkg/handlers/update.go index b98c9fa3..5c4c82e3 100644 --- a/pkg/handlers/update.go +++ b/pkg/handlers/update.go @@ -80,33 +80,6 @@ func MakeUpdateHandler(cfg *types.Config, back types.ServerlessBackend) gin.Hand } minIOAdminClient, _ := utils.MakeMinIOAdminClient(cfg) - if !isAdminUser { - if err != nil { - c.String(http.StatusInternalServerError, fmt.Sprintln(err)) - } - - // Check if users in allowed_users have a MinIO associated user - // If new allowed users list is empty the service becames public - bucketName := newService.Input[0].Path - if len(newService.AllowedUsers) < 1 { - // Delete service policy and add bucket to all_users_group - err := minIOAdminClient.DeleteServiceGroup(bucketName) - if err != nil { - c.String(http.StatusInternalServerError, fmt.Sprintln(err)) - } - err = minIOAdminClient.AddServiceToAllUsersGroup(bucketName) - if err != nil { - c.String(http.StatusInternalServerError, fmt.Sprintln(err)) - } - - } else { - if len(newService.AllowedUsers) != len(oldService.AllowedUsers) { - //Update users group list - minIOAdminClient.AddUserToGroup(newService.AllowedUsers, bucketName) - } - } - } - // Update the service if err := back.UpdateService(newService); err != nil { c.String(http.StatusInternalServerError, fmt.Sprintf("Error updating the service: %v", err)) @@ -161,6 +134,11 @@ func updateBuckets(newService, oldService *types.Service, minIOAdminClient *util return fmt.Errorf("error disabling MinIO input notifications: %v", err) } + updateMinIOUsers := false + if len(newService.AllowedUsers) != len(oldService.AllowedUsers) { + updateMinIOUsers = true + } + // Create the input and output buckets/folders from newService - return createBuckets(newService, cfg, minIOAdminClient, newService.AllowedUsers, true) + return createBuckets(newService, cfg, minIOAdminClient, newService.AllowedUsers, updateMinIOUsers) } From 0d25a861fd00908c88a1ba1c6a7f2f48de2d1698 Mon Sep 17 00:00:00 2001 From: catttam Date: Tue, 14 May 2024 18:20:57 +0200 Subject: [PATCH 46/60] Fixed owner on update --- pkg/handlers/update.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/handlers/update.go b/pkg/handlers/update.go index 5c4c82e3..ca82c67f 100644 --- a/pkg/handlers/update.go +++ b/pkg/handlers/update.go @@ -65,6 +65,9 @@ func MakeUpdateHandler(cfg *types.Config, back types.ServerlessBackend) gin.Hand return } + // Set the owner on the new service definition + newService.Owner = oldService.Owner + // If the service has changed VO check permisions again if newService.VO != "" && newService.VO != oldService.VO { for _, vo := range cfg.OIDCGroups { From 15e910d1926493b6c50ae637a4e53dc39e851fc8 Mon Sep 17 00:00:00 2001 From: catttam Date: Wed, 15 May 2024 10:26:48 +0200 Subject: [PATCH 47/60] Changed update policies implementation --- pkg/handlers/create.go | 27 ++++++++------- pkg/handlers/update.go | 28 ++++++++++++---- pkg/utils/minio.go | 76 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+), 20 deletions(-) diff --git a/pkg/handlers/create.go b/pkg/handlers/create.go index 519a1780..df54a280 100644 --- a/pkg/handlers/create.go +++ b/pkg/handlers/create.go @@ -286,24 +286,23 @@ func createBuckets(service *types.Service, cfg *types.Config, minIOAdminClient * // Create group for the service and add users // Check if users in allowed_users have a MinIO associated user // If new allowed users list is empty the service becames public - if !isAdminUser { - if len(allowed_users) == 0 { - err = minIOAdminClient.AddServiceToAllUsersGroup(splitPath[0]) - if err != nil { - return fmt.Errorf("error adding service %s to all users group: %v", splitPath[0], err) - } - } else { - if !isUpdate { + if !isUpdate { + if !isAdminUser { + if len(allowed_users) == 0 { + err = minIOAdminClient.AddServiceToAllUsersGroup(splitPath[0]) + if err != nil { + return fmt.Errorf("error adding service %s to all users group: %v", splitPath[0], err) + } + } else { err = minIOAdminClient.CreateServiceGroup(splitPath[0]) if err != nil { return fmt.Errorf("error creating service group for bucket %s: %v", splitPath[0], err) } - } else { - minIOAdminClient.DeleteServiceGroup(splitPath[0]) - } - err = minIOAdminClient.AddUserToGroup(allowed_users, splitPath[0]) - if err != nil { - return err + + err = minIOAdminClient.AddUserToGroup(allowed_users, splitPath[0]) + if err != nil { + return err + } } } } diff --git a/pkg/handlers/update.go b/pkg/handlers/update.go index ca82c67f..e7ef84d7 100644 --- a/pkg/handlers/update.go +++ b/pkg/handlers/update.go @@ -99,6 +99,27 @@ func MakeUpdateHandler(cfg *types.Config, back types.ServerlessBackend) gin.Hand } if provName == types.MinIOName { + // Get bucket name + path := strings.Trim(in.Path, " /") + // Split buckets and folders from path + splitPath := strings.SplitN(path, "/", 2) + oldAllowedLength := len(oldService.AllowedUsers) + newAllowedLength := len(newService.AllowedUsers) + if newAllowedLength > oldAllowedLength && oldAllowedLength != 0 { + // Update list of allowed users + minIOAdminClient.AddUserToGroup(newService.AllowedUsers, splitPath[0]) + } + + if newAllowedLength > oldAllowedLength && oldAllowedLength == 0 { + // Make bucket private + minIOAdminClient.PublicToPrivateBucket(splitPath[0], newService.AllowedUsers) + } + + if newAllowedLength < oldAllowedLength && newAllowedLength == 0 { + // Make bucket public + minIOAdminClient.PrivateToPublicBucket(splitPath[0]) + } + // Register minio webhook and restart the server if err := registerMinIOWebhook(newService.Name, newService.Token, newService.StorageProviders.MinIO[types.DefaultProvider], cfg); err != nil { back.UpdateService(*oldService) @@ -137,11 +158,6 @@ func updateBuckets(newService, oldService *types.Service, minIOAdminClient *util return fmt.Errorf("error disabling MinIO input notifications: %v", err) } - updateMinIOUsers := false - if len(newService.AllowedUsers) != len(oldService.AllowedUsers) { - updateMinIOUsers = true - } - // Create the input and output buckets/folders from newService - return createBuckets(newService, cfg, minIOAdminClient, newService.AllowedUsers, updateMinIOUsers) + return createBuckets(newService, cfg, minIOAdminClient, newService.AllowedUsers, true) } diff --git a/pkg/utils/minio.go b/pkg/utils/minio.go index 7d491383..8da47014 100644 --- a/pkg/utils/minio.go +++ b/pkg/utils/minio.go @@ -114,6 +114,72 @@ func (minIOAdminClient *MinIOAdminClient) CreateMinIOUser(ak string, sk string) return nil } +func (minIOAdminClient *MinIOAdminClient) PrivateToPublicBucket(bucketName string) error { + // Delete policy and group + err := minIOAdminClient.DeleteServiceGroup(bucketName) + if err != nil { + return err + } + // Add bucket to all_users_group policy + err = minIOAdminClient.AddServiceToAllUsersGroup(bucketName) + if err != nil { + return err + } + return nil +} + +// TODO refactor to delete duplicated code +func (minIOAdminClient *MinIOAdminClient) PublicToPrivateBucket(bucketName string, allowedUsers []string) error { + // Delete bucket from all_users_group + rs := "arn:aws:s3:::" + bucketName + "/*" + groupName := ALL_USERS_GROUP + + policyInfo, errInfo := minIOAdminClient.adminClient.InfoCannedPolicyV2(context.TODO(), ALL_USERS_GROUP) + if errInfo != nil { + return errInfo + } + + actualPolicy := &Policy{} + json.Unmarshal(policyInfo.Policy, actualPolicy) + index := 0 + // Search for the resource index + resources := actualPolicy.Statement[0].Resource + for i, resource := range resources { + if resource == rs { + index = i + break + } + } + // Add new resource and create policy + actualPolicy.Statement[0].Resource = append(resources[:index], resources[index+1:]...) + + policy, jsonErr := json.Marshal(actualPolicy) + if jsonErr != nil { + return jsonErr + } + + err := minIOAdminClient.adminClient.AddCannedPolicy(context.TODO(), groupName, []byte(policy)) + if err != nil { + return fmt.Errorf("error creating MinIO policy for group %s: %v", groupName, err) + } + + err = minIOAdminClient.adminClient.SetPolicy(context.TODO(), groupName, groupName, true) + if err != nil { + return fmt.Errorf("error setting MinIO policy for group %s: %v", groupName, err) + } + + err = minIOAdminClient.CreateServiceGroup(bucketName) + if err != nil { + return err + } + // Add bucket to all_users_group policy + err = minIOAdminClient.AddUserToGroup(allowedUsers, bucketName) + if err != nil { + return err + } + return nil +} + // CreateAllUsersGroup creates a group used for public services func (minIOAdminClient *MinIOAdminClient) CreateAllUsersGroup() error { err := createGroup(minIOAdminClient.adminClient, ALL_USERS_GROUP) @@ -148,6 +214,16 @@ func (minIOAdminClient *MinIOAdminClient) AddServiceToAllUsersGroup(bucketName s return nil } +// AddServiceToAllUsersGroup associates policy of all users to a service +func (minIOAdminClient *MinIOAdminClient) RemovedServiceFromAllUsersGroup(bucketName string) error { + err := createPolicy(minIOAdminClient.adminClient, bucketName, true) + if err != nil { + return err + } + + return nil +} + // AddUserToGroup adds user/users to a group func (minIOAdminClient *MinIOAdminClient) AddUserToGroup(users []string, groupName string) error { group := madmin.GroupAddRemove{ From fa064982f862de25b5885318c122ec36a2fcaf26 Mon Sep 17 00:00:00 2001 From: catttam Date: Wed, 15 May 2024 13:23:14 +0200 Subject: [PATCH 48/60] Error control --- pkg/handlers/update.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/pkg/handlers/update.go b/pkg/handlers/update.go index e7ef84d7..bd02e306 100644 --- a/pkg/handlers/update.go +++ b/pkg/handlers/update.go @@ -107,17 +107,29 @@ func MakeUpdateHandler(cfg *types.Config, back types.ServerlessBackend) gin.Hand newAllowedLength := len(newService.AllowedUsers) if newAllowedLength > oldAllowedLength && oldAllowedLength != 0 { // Update list of allowed users - minIOAdminClient.AddUserToGroup(newService.AllowedUsers, splitPath[0]) + err = minIOAdminClient.AddUserToGroup(newService.AllowedUsers, splitPath[0]) + if err != nil { + c.String(http.StatusInternalServerError, err.Error()) + return + } } if newAllowedLength > oldAllowedLength && oldAllowedLength == 0 { // Make bucket private - minIOAdminClient.PublicToPrivateBucket(splitPath[0], newService.AllowedUsers) + err = minIOAdminClient.PublicToPrivateBucket(splitPath[0], newService.AllowedUsers) + if err != nil { + c.String(http.StatusInternalServerError, err.Error()) + return + } } if newAllowedLength < oldAllowedLength && newAllowedLength == 0 { // Make bucket public - minIOAdminClient.PrivateToPublicBucket(splitPath[0]) + err = minIOAdminClient.PrivateToPublicBucket(splitPath[0]) + if err != nil { + c.String(http.StatusInternalServerError, err.Error()) + return + } } // Register minio webhook and restart the server From ca277c0157302398b0e1237a813c18e7ea819658 Mon Sep 17 00:00:00 2001 From: catttam Date: Thu, 16 May 2024 14:39:15 +0200 Subject: [PATCH 49/60] Fixed checkUsersInCache --- pkg/utils/auth/multitenancy.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/utils/auth/multitenancy.go b/pkg/utils/auth/multitenancy.go index c92b9af6..8e5a8118 100644 --- a/pkg/utils/auth/multitenancy.go +++ b/pkg/utils/auth/multitenancy.go @@ -66,8 +66,8 @@ func (mc *MultitenancyConfig) ClearCache() { func (mc *MultitenancyConfig) UserExists(uid string) bool { if len(mc.usersCache) > 1 { // If the cache has users search for the uid - for _, id := range mc.usersCache { - if id == uid { + for _, cacheUID := range mc.usersCache { + if cacheUID == uid { return true } } @@ -90,6 +90,16 @@ func (mc *MultitenancyConfig) UserExists(uid string) bool { func (mc *MultitenancyConfig) CheckUsersInCache(uids []string) []string { var notFoundUsers []string var found bool + + if len(mc.usersCache) == 0 { + secrets, _ := mc.kubeClientset.CoreV1().Secrets(ServicesNamespace).List(context.TODO(), metav1.ListOptions{}) + if secrets != nil { + for _, s := range secrets.Items { + mc.UpdateCache(s.Name) + } + } + } + for _, uid := range uids { found = false for _, cacheUID := range mc.usersCache { From 58874195e9149bdae3058f6d8d5776e11d07a046 Mon Sep 17 00:00:00 2001 From: catttam Date: Thu, 16 May 2024 14:52:34 +0200 Subject: [PATCH 50/60] Fixed change MinIO policies on service update --- pkg/handlers/update.go | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/pkg/handlers/update.go b/pkg/handlers/update.go index bd02e306..337507ad 100644 --- a/pkg/handlers/update.go +++ b/pkg/handlers/update.go @@ -105,27 +105,26 @@ func MakeUpdateHandler(cfg *types.Config, back types.ServerlessBackend) gin.Hand splitPath := strings.SplitN(path, "/", 2) oldAllowedLength := len(oldService.AllowedUsers) newAllowedLength := len(newService.AllowedUsers) - if newAllowedLength > oldAllowedLength && oldAllowedLength != 0 { - // Update list of allowed users - err = minIOAdminClient.AddUserToGroup(newService.AllowedUsers, splitPath[0]) + + if newAllowedLength < oldAllowedLength && newAllowedLength == 0 { + // If the new allowed users is empty make service public + err = minIOAdminClient.PrivateToPublicBucket(splitPath[0]) if err != nil { c.String(http.StatusInternalServerError, err.Error()) return } } - - if newAllowedLength > oldAllowedLength && oldAllowedLength == 0 { - // Make bucket private - err = minIOAdminClient.PublicToPrivateBucket(splitPath[0], newService.AllowedUsers) + // If allowed users list changed update policies on bucket + if oldAllowedLength != 0 && newAllowedLength > oldAllowedLength || newAllowedLength < oldAllowedLength { + err = minIOAdminClient.AddUserToGroup(newService.AllowedUsers, splitPath[0]) if err != nil { c.String(http.StatusInternalServerError, err.Error()) return } } - - if newAllowedLength < oldAllowedLength && newAllowedLength == 0 { - // Make bucket public - err = minIOAdminClient.PrivateToPublicBucket(splitPath[0]) + // If the service was public and now has a list of allowed users make its buckets private + if newAllowedLength > oldAllowedLength && oldAllowedLength == 0 { + err = minIOAdminClient.PublicToPrivateBucket(splitPath[0], newService.AllowedUsers) if err != nil { c.String(http.StatusInternalServerError, err.Error()) return From cbdc57cf4fddb1a06a1aca945f4a66ea1f2414bc Mon Sep 17 00:00:00 2001 From: catttam Date: Thu, 16 May 2024 15:09:34 +0200 Subject: [PATCH 51/60] Refactored update code --- pkg/handlers/update.go | 47 +++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/pkg/handlers/update.go b/pkg/handlers/update.go index 337507ad..d8bbf750 100644 --- a/pkg/handlers/update.go +++ b/pkg/handlers/update.go @@ -105,29 +105,30 @@ func MakeUpdateHandler(cfg *types.Config, back types.ServerlessBackend) gin.Hand splitPath := strings.SplitN(path, "/", 2) oldAllowedLength := len(oldService.AllowedUsers) newAllowedLength := len(newService.AllowedUsers) - - if newAllowedLength < oldAllowedLength && newAllowedLength == 0 { - // If the new allowed users is empty make service public - err = minIOAdminClient.PrivateToPublicBucket(splitPath[0]) - if err != nil { - c.String(http.StatusInternalServerError, err.Error()) - return - } - } - // If allowed users list changed update policies on bucket - if oldAllowedLength != 0 && newAllowedLength > oldAllowedLength || newAllowedLength < oldAllowedLength { - err = minIOAdminClient.AddUserToGroup(newService.AllowedUsers, splitPath[0]) - if err != nil { - c.String(http.StatusInternalServerError, err.Error()) - return - } - } - // If the service was public and now has a list of allowed users make its buckets private - if newAllowedLength > oldAllowedLength && oldAllowedLength == 0 { - err = minIOAdminClient.PublicToPrivateBucket(splitPath[0], newService.AllowedUsers) - if err != nil { - c.String(http.StatusInternalServerError, err.Error()) - return + if newAllowedLength != oldAllowedLength { + if newAllowedLength == 0 { + // If the new allowed users is empty make service public + err = minIOAdminClient.PrivateToPublicBucket(splitPath[0]) + if err != nil { + c.String(http.StatusInternalServerError, err.Error()) + return + } + } else { + // If the service was public and now has a list of allowed users make its buckets private + if oldAllowedLength == 0 { + err = minIOAdminClient.PublicToPrivateBucket(splitPath[0], newService.AllowedUsers) + if err != nil { + c.String(http.StatusInternalServerError, err.Error()) + return + } + } else { + // If allowed users list changed update policies on bucket + err = minIOAdminClient.AddUserToGroup(newService.AllowedUsers, splitPath[0]) + if err != nil { + c.String(http.StatusInternalServerError, err.Error()) + return + } + } } } From 25d90de29d8cb84ec87e68e7cccb700a8bb7fc8a Mon Sep 17 00:00:00 2001 From: catttam Date: Thu, 16 May 2024 15:30:46 +0200 Subject: [PATCH 52/60] Update debug --- pkg/handlers/update.go | 7 +++++++ pkg/utils/minio.go | 9 +++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/pkg/handlers/update.go b/pkg/handlers/update.go index d8bbf750..7830880b 100644 --- a/pkg/handlers/update.go +++ b/pkg/handlers/update.go @@ -20,6 +20,7 @@ import ( "fmt" "log" "net/http" + "os" "strings" "github.com/gin-gonic/gin" @@ -29,6 +30,9 @@ import ( "k8s.io/apimachinery/pkg/api/errors" ) +// Custom logger +var updateLogger = log.New(os.Stdout, "[CREATE-HANDLER] ", log.Flags()) + // MakeUpdateHandler makes a handler for updating services func MakeUpdateHandler(cfg *types.Config, back types.ServerlessBackend) gin.HandlerFunc { return func(c *gin.Context) { @@ -107,6 +111,7 @@ func MakeUpdateHandler(cfg *types.Config, back types.ServerlessBackend) gin.Hand newAllowedLength := len(newService.AllowedUsers) if newAllowedLength != oldAllowedLength { if newAllowedLength == 0 { + updateLogger.Printf("Updating service with public policies") // If the new allowed users is empty make service public err = minIOAdminClient.PrivateToPublicBucket(splitPath[0]) if err != nil { @@ -116,6 +121,7 @@ func MakeUpdateHandler(cfg *types.Config, back types.ServerlessBackend) gin.Hand } else { // If the service was public and now has a list of allowed users make its buckets private if oldAllowedLength == 0 { + updateLogger.Printf("Updating service with private policies") err = minIOAdminClient.PublicToPrivateBucket(splitPath[0], newService.AllowedUsers) if err != nil { c.String(http.StatusInternalServerError, err.Error()) @@ -123,6 +129,7 @@ func MakeUpdateHandler(cfg *types.Config, back types.ServerlessBackend) gin.Hand } } else { // If allowed users list changed update policies on bucket + updateLogger.Printf("Updating service policies") err = minIOAdminClient.AddUserToGroup(newService.AllowedUsers, splitPath[0]) if err != nil { c.String(http.StatusInternalServerError, err.Error()) diff --git a/pkg/utils/minio.go b/pkg/utils/minio.go index 8da47014..68aa154c 100644 --- a/pkg/utils/minio.go +++ b/pkg/utils/minio.go @@ -259,10 +259,11 @@ func (minIOAdminClient *MinIOAdminClient) DeleteServiceGroup(groupName string) e return fmt.Errorf("error emptying group: %v", err) } - err = minIOAdminClient.adminClient.RemoveCannedPolicy(context.TODO(), groupName) - if err != nil { - return fmt.Errorf("error removing group's policy: %v", err) - } + // FIX Group updates but doesn't get deleted so delete policy doesn't work + // err = minIOAdminClient.adminClient.RemoveCannedPolicy(context.TODO(), groupName) + // if err != nil { + // return fmt.Errorf("error removing group's policy: %v", err) + // } return nil } From 4dc4114b579fdf4a60c1ff44528a08a11eb3b467 Mon Sep 17 00:00:00 2001 From: catttam Date: Thu, 16 May 2024 17:00:36 +0200 Subject: [PATCH 53/60] Refactored updateGroups --- pkg/handlers/create.go | 2 +- pkg/handlers/delete.go | 3 ++- pkg/handlers/update.go | 6 ++++- pkg/utils/auth/auth.go | 2 +- pkg/utils/minio.go | 56 +++++++++++++++--------------------------- 5 files changed, 29 insertions(+), 40 deletions(-) diff --git a/pkg/handlers/create.go b/pkg/handlers/create.go index df54a280..ad7de67b 100644 --- a/pkg/handlers/create.go +++ b/pkg/handlers/create.go @@ -299,7 +299,7 @@ func createBuckets(service *types.Service, cfg *types.Config, minIOAdminClient * return fmt.Errorf("error creating service group for bucket %s: %v", splitPath[0], err) } - err = minIOAdminClient.AddUserToGroup(allowed_users, splitPath[0]) + err = minIOAdminClient.UpdateUsersInGroup(allowed_users, splitPath[0], false) if err != nil { return err } diff --git a/pkg/handlers/delete.go b/pkg/handlers/delete.go index 73761e14..593fd673 100644 --- a/pkg/handlers/delete.go +++ b/pkg/handlers/delete.go @@ -73,7 +73,8 @@ func MakeDeleteHandler(cfg *types.Config, back types.ServerlessBackend) gin.Hand path := strings.Trim(in.Path, " /") // Split buckets and folders from path bucket := strings.SplitN(path, "/", 2) - minIOAdminClient.DeleteServiceGroup(bucket[0]) + var users []string + minIOAdminClient.UpdateUsersInGroup(users, bucket[0], true) } // Disable input notifications diff --git a/pkg/handlers/update.go b/pkg/handlers/update.go index 7830880b..92cffc80 100644 --- a/pkg/handlers/update.go +++ b/pkg/handlers/update.go @@ -130,7 +130,11 @@ func MakeUpdateHandler(cfg *types.Config, back types.ServerlessBackend) gin.Hand } else { // If allowed users list changed update policies on bucket updateLogger.Printf("Updating service policies") - err = minIOAdminClient.AddUserToGroup(newService.AllowedUsers, splitPath[0]) + if oldAllowedLength < newAllowedLength { + err = minIOAdminClient.UpdateUsersInGroup(newService.AllowedUsers, splitPath[0], false) + } else { + err = minIOAdminClient.UpdateUsersInGroup(newService.AllowedUsers, splitPath[0], true) + } if err != nil { c.String(http.StatusInternalServerError, err.Error()) return diff --git a/pkg/utils/auth/auth.go b/pkg/utils/auth/auth.go index 812e617c..40883f7c 100644 --- a/pkg/utils/auth/auth.go +++ b/pkg/utils/auth/auth.go @@ -49,7 +49,7 @@ func CustomAuth(cfg *types.Config, kubeClientset *kubernetes.Clientset) gin.Hand var oscarUser = []string{"console"} minIOAdminClient.CreateAllUsersGroup() - minIOAdminClient.AddUserToGroup(oscarUser, "all_users_group") + minIOAdminClient.UpdateUsersInGroup(oscarUser, "all_users_group", false) oidcHandler := getOIDCMiddleware(kubeClientset, minIOAdminClient, cfg.OIDCIssuer, cfg.OIDCSubject, cfg.OIDCGroups) return func(c *gin.Context) { diff --git a/pkg/utils/minio.go b/pkg/utils/minio.go index 68aa154c..8a71b6e7 100644 --- a/pkg/utils/minio.go +++ b/pkg/utils/minio.go @@ -107,7 +107,7 @@ func (minIOAdminClient *MinIOAdminClient) CreateMinIOUser(ak string, sk string) } users = append(users, ak) - err2 := minIOAdminClient.AddUserToGroup(users, ALL_USERS_GROUP) + err2 := minIOAdminClient.UpdateUsersInGroup(users, ALL_USERS_GROUP, false) if err2 != nil { return err2 } @@ -115,8 +115,9 @@ func (minIOAdminClient *MinIOAdminClient) CreateMinIOUser(ak string, sk string) } func (minIOAdminClient *MinIOAdminClient) PrivateToPublicBucket(bucketName string) error { - // Delete policy and group - err := minIOAdminClient.DeleteServiceGroup(bucketName) + // Delete policy and group"" + var users []string + err := minIOAdminClient.UpdateUsersInGroup(users, bucketName, true) if err != nil { return err } @@ -173,7 +174,7 @@ func (minIOAdminClient *MinIOAdminClient) PublicToPrivateBucket(bucketName strin return err } // Add bucket to all_users_group policy - err = minIOAdminClient.AddUserToGroup(allowedUsers, bucketName) + err = minIOAdminClient.UpdateUsersInGroup(allowedUsers, bucketName, false) if err != nil { return err } @@ -224,46 +225,29 @@ func (minIOAdminClient *MinIOAdminClient) RemovedServiceFromAllUsersGroup(bucket return nil } -// AddUserToGroup adds user/users to a group -func (minIOAdminClient *MinIOAdminClient) AddUserToGroup(users []string, groupName string) error { - group := madmin.GroupAddRemove{ - Group: groupName, - Members: users, - Status: "enable", - IsRemove: false, - } - - err := minIOAdminClient.adminClient.UpdateGroupMembers(context.TODO(), group) - if err != nil { - return fmt.Errorf("error adding users to group: %v", err) - } - - return nil -} - -// DeleteServiceGroup empty the service group and policy -func (minIOAdminClient *MinIOAdminClient) DeleteServiceGroup(groupName string) error { - description, err := minIOAdminClient.adminClient.GetGroupDescription(context.Background(), groupName) - if err != nil { - return err +// UpdateUsersGroup +func (minIOAdminClient *MinIOAdminClient) UpdateUsersInGroup(users []string, groupName string, remove bool) error { + var members []string + if len(users) < 1 { + description, err := minIOAdminClient.adminClient.GetGroupDescription(context.Background(), groupName) + if err != nil { + return err + } + members = description.Members + } else { + members = users } group := madmin.GroupAddRemove{ Group: groupName, - Members: description.Members, + Members: members, Status: "enable", - IsRemove: true, + IsRemove: remove, } - err = minIOAdminClient.adminClient.UpdateGroupMembers(context.Background(), group) + err := minIOAdminClient.adminClient.UpdateGroupMembers(context.TODO(), group) if err != nil { - return fmt.Errorf("error emptying group: %v", err) + return fmt.Errorf("error updating users on group: %v", err) } - - // FIX Group updates but doesn't get deleted so delete policy doesn't work - // err = minIOAdminClient.adminClient.RemoveCannedPolicy(context.TODO(), groupName) - // if err != nil { - // return fmt.Errorf("error removing group's policy: %v", err) - // } return nil } From 4e0f36e95591102ffeea0eed20344fc902e58b64 Mon Sep 17 00:00:00 2001 From: catttam Date: Thu, 16 May 2024 17:48:48 +0200 Subject: [PATCH 54/60] Update fix --- pkg/handlers/update.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pkg/handlers/update.go b/pkg/handlers/update.go index 92cffc80..203a51d7 100644 --- a/pkg/handlers/update.go +++ b/pkg/handlers/update.go @@ -130,11 +130,8 @@ func MakeUpdateHandler(cfg *types.Config, back types.ServerlessBackend) gin.Hand } else { // If allowed users list changed update policies on bucket updateLogger.Printf("Updating service policies") - if oldAllowedLength < newAllowedLength { - err = minIOAdminClient.UpdateUsersInGroup(newService.AllowedUsers, splitPath[0], false) - } else { - err = minIOAdminClient.UpdateUsersInGroup(newService.AllowedUsers, splitPath[0], true) - } + err = minIOAdminClient.UpdateUsersInGroup(oldService.AllowedUsers, splitPath[0], true) + err = minIOAdminClient.UpdateUsersInGroup(newService.AllowedUsers, splitPath[0], false) if err != nil { c.String(http.StatusInternalServerError, err.Error()) return From 6f94319a72c7a1dea6d95f67e66f08903ec2b31d Mon Sep 17 00:00:00 2001 From: catttam Date: Thu, 16 May 2024 18:21:29 +0200 Subject: [PATCH 55/60] Updated dependencies --- go.mod | 2 +- go.sum | 3 --- pkg/handlers/update.go | 4 ++++ 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 4634324c..d7d0495f 100644 --- a/go.mod +++ b/go.mod @@ -46,6 +46,7 @@ require ( github.com/apache/yunikorn-core v1.1.0 github.com/barkimedes/go-deepcopy v0.0.0-20220514131651-17c30cfc62df github.com/coreos/go-oidc/v3 v3.5.0 + github.com/foomo/htpasswd v0.0.0-20200116085101-e3a90e78da9c k8s.io/metrics v0.29.2 knative.dev/serving v0.36.0 ) @@ -60,7 +61,6 @@ require ( github.com/emicklei/go-restful/v3 v3.11.0 // indirect github.com/evanphx/json-patch v5.6.0+incompatible // indirect github.com/evanphx/json-patch/v5 v5.6.0 // indirect - github.com/foomo/htpasswd v0.0.0-20200116085101-e3a90e78da9c // indirect github.com/gabriel-vasile/mimetype v1.4.2 // indirect github.com/gin-contrib/sse v0.1.0 // indirect github.com/go-jose/go-jose/v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index bbb6ef4e..0db678da 100644 --- a/go.sum +++ b/go.sum @@ -57,7 +57,6 @@ github.com/evanphx/json-patch/v5 v5.6.0/go.mod h1:G79N1coSVB93tBe7j6PhzjmR3/2Vvl github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= github.com/fatih/color v1.14.1 h1:qfhVLaG5s+nCROl1zJsZRxFeYrHLqWroPOQ8BWiNb4w= github.com/fatih/color v1.14.1/go.mod h1:2oHN61fhTpgcxD3TSWCgKDiH1+x4OiDVVGH8WlgGZGg= -github.com/flowstack/go-jsonschema v0.1.1/go.mod h1:yL7fNggx1o8rm9RlgXv7hTBWxdBM0rVwpMwimd3F3N0= github.com/foomo/htpasswd v0.0.0-20200116085101-e3a90e78da9c h1:DBGU7zCwrrPPDsD6+gqKG8UfMxenWg9BOJE/Nmfph+4= github.com/foomo/htpasswd v0.0.0-20200116085101-e3a90e78da9c/go.mod h1:SHawtolbB0ZOFoRWgDwakX5WpwuIWAK88bUXVZqK0Ss= github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= @@ -148,8 +147,6 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0/go.mod h1:YN5jB8ie0yfIUg6VvR9K github.com/grycap/cdmi-client-go v0.1.1 h1:kHIrrLhvaCD0VyzEa5HOg7d/VgRE11yh9Ztdyoqii0o= github.com/grycap/cdmi-client-go v0.1.1/go.mod h1:ZqWeQS3YBJVXxg3HOIkAu1MLNJ4+7s848CyIPMFT5Gc= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/jimstudt/http-authentication v0.0.0-20140401203705-3eca13d6893a h1:BcF8coBl0QFVhe8vAMMlD+CV8EISiu9MGKLoj6ZEyJA= -github.com/jimstudt/http-authentication v0.0.0-20140401203705-3eca13d6893a/go.mod h1:wK6yTYYcgjHE1Z1QtXACPDjcFJyBskHEdagmnq3vsP8= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= diff --git a/pkg/handlers/update.go b/pkg/handlers/update.go index 203a51d7..6a5a96f0 100644 --- a/pkg/handlers/update.go +++ b/pkg/handlers/update.go @@ -131,6 +131,10 @@ func MakeUpdateHandler(cfg *types.Config, back types.ServerlessBackend) gin.Hand // If allowed users list changed update policies on bucket updateLogger.Printf("Updating service policies") err = minIOAdminClient.UpdateUsersInGroup(oldService.AllowedUsers, splitPath[0], true) + if err != nil { + c.String(http.StatusInternalServerError, err.Error()) + return + } err = minIOAdminClient.UpdateUsersInGroup(newService.AllowedUsers, splitPath[0], false) if err != nil { c.String(http.StatusInternalServerError, err.Error()) From 780950a63e0f300dce611eb97dd66742be5c964d Mon Sep 17 00:00:00 2001 From: catttam Date: Thu, 16 May 2024 18:24:10 +0200 Subject: [PATCH 56/60] Updated ui reference --- ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui b/ui index 93ff48e9..83ce2547 160000 --- a/ui +++ b/ui @@ -1 +1 @@ -Subproject commit 93ff48e949a40ff1803a4d86057ec53ae45bcfea +Subproject commit 83ce2547ca7e072eadb7d0446219d90ebbc12690 From 3d59fa4cd634ba5f264cd428d2498067a3eefcbb Mon Sep 17 00:00:00 2001 From: catttam Date: Thu, 16 May 2024 18:56:20 +0200 Subject: [PATCH 57/60] Fixed dependency error --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index dc307ae2..ddb974fc 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/tinylib/msgp v1.1.8 // indirect golang.org/x/crypto v0.21.0 // indirect golang.org/x/net v0.23.0 // indirect - golang.org/x/oauth2 v0.8.0 + golang.org/x/oauth2 v0.10.0 gopkg.in/ini.v1 v1.67.0 // indirect k8s.io/api v0.29.2 k8s.io/apimachinery v0.29.2 From 2d1a9bdf55db540f4a487143d07ec08a66fce28f Mon Sep 17 00:00:00 2001 From: catttam Date: Mon, 20 May 2024 10:19:18 +0200 Subject: [PATCH 58/60] Minor fix on exposed services --- pkg/handlers/delete.go | 5 +---- pkg/types/expose.go | 3 +-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/pkg/handlers/delete.go b/pkg/handlers/delete.go index 593fd673..2f453e4a 100644 --- a/pkg/handlers/delete.go +++ b/pkg/handlers/delete.go @@ -38,9 +38,6 @@ func MakeDeleteHandler(cfg *types.Config, back types.ServerlessBackend) gin.Hand // First get the Service service, _ := back.ReadService(c.Param("serviceName")) authHeader := c.GetHeader("Authorization") - if service.Expose.APIPort != 0 { - // Delete exposed service - } if len(strings.Split(authHeader, "Bearer")) > 1 { uid, err := auth.GetUIDFromContext(c) @@ -49,7 +46,7 @@ func MakeDeleteHandler(cfg *types.Config, back types.ServerlessBackend) gin.Hand } if service.Owner != uid { - c.String(http.StatusForbidden, "User %s doesn't have permision to get this service", uid) + c.String(http.StatusForbidden, "User %s doesn't have permision to delete this service", uid) return } } diff --git a/pkg/types/expose.go b/pkg/types/expose.go index 87cbddd4..fba06b37 100644 --- a/pkg/types/expose.go +++ b/pkg/types/expose.go @@ -534,8 +534,7 @@ func listIngress(kubeClientset kubernetes.Interface, cfg *Config) (*net.IngressL // Delete a kubernetes ingress func deleteIngress(name string, kubeClientset kubernetes.Interface, cfg *Config) error { // if secret exist, delete - ingress := getIngressName(name) - err := kubeClientset.NetworkingV1().Ingresses(cfg.ServicesNamespace).Delete(context.TODO(), ingress, metav1.DeleteOptions{}) + err := kubeClientset.NetworkingV1().Ingresses(cfg.ServicesNamespace).Delete(context.TODO(), name, metav1.DeleteOptions{}) if err != nil { return err } From 66435aadcdd82a5bf0f92e4d4f12b696272aec2a Mon Sep 17 00:00:00 2001 From: catttam Date: Mon, 20 May 2024 11:59:41 +0200 Subject: [PATCH 59/60] Minor fix on exposed services --- pkg/types/expose.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/types/expose.go b/pkg/types/expose.go index fba06b37..6d4f1c4f 100644 --- a/pkg/types/expose.go +++ b/pkg/types/expose.go @@ -117,12 +117,12 @@ func UpdateExpose(service Service, kubeClientset kubernetes.Interface, cfg *Conf if err != nil { log.Printf("error deleting ingress service: %v\n", err) return err - } else { - err = updateIngress(service, kubeClientset, cfg) - if err != nil { - log.Printf("error updating ingress service: %v\n", err) - return err - } + } + } else { + err = updateIngress(service, kubeClientset, cfg) + if err != nil { + log.Printf("error updating ingress service: %v\n", err) + return err } } } else { From 5c74c9e75d88bda023c50212d95be43d314644f5 Mon Sep 17 00:00:00 2001 From: catttam Date: Mon, 20 May 2024 12:28:32 +0200 Subject: [PATCH 60/60] Last ui updates --- ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui b/ui index 83ce2547..b64d9452 160000 --- a/ui +++ b/ui @@ -1 +1 @@ -Subproject commit 83ce2547ca7e072eadb7d0446219d90ebbc12690 +Subproject commit b64d94529ea18799faec87cfbd6030aa81af998a