Skip to content

Commit

Permalink
Change VizierID type from string to uuidpb.UUID (#1677)
Browse files Browse the repository at this point in the history
Summary: This PR adjusts the cloud side to accept a type uuidpb.UUID for
the VizierID instead of a string.

Relevant Issues: #1632

Type of change: /kind bug

Test Plan: Skaffold the cloud changes on the testing cluster and then
skaffold the operator changes on a dev cluster. Manually trigger an
update on the operator side to send the VizierID to the config manager
service. Check the config manager service's logs to see that the new
logic is being executed as expected to handle the VizierID.

Signed-off-by: Kartik Pattaswamy <[email protected]>
  • Loading branch information
kpattaswamy authored Aug 16, 2023
1 parent 0e5d7d4 commit e5d83b7
Show file tree
Hide file tree
Showing 7 changed files with 471 additions and 442 deletions.
775 changes: 393 additions & 382 deletions src/api/proto/cloudpb/cloudapi.pb.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/api/proto/cloudpb/cloudapi.proto
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ message ConfigForVizierRequest {
// Kubernetes version of the cluster Vizier is running on.
string k8s_version = 3 [ (gogoproto.customname) = "K8sVersion" ];
// ID of the Vizier (Cluster ID).
string vizier_id = 4 [ (gogoproto.customname) = "VizierID" ];
uuidpb.UUID vizier_id = 4 [ (gogoproto.customname) = "VizierID" ];
}

// ConfigForVizierResponse is the response to a ConfigForVizierRequest.
Expand Down
2 changes: 2 additions & 0 deletions src/cloud/config_manager/configmanagerpb/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pl_proto_library(
srcs = ["service.proto"],
visibility = ["//src/cloud:__subpackages__"],
deps = [
"//src/api/proto/uuidpb:uuid_pl_proto",
"//src/api/proto/vizierconfigpb:vizier_pl_proto",
"@gogo_grpc_proto//github.com/gogo/protobuf/gogoproto:gogo_pl_proto",
],
Expand All @@ -32,6 +33,7 @@ pl_go_proto_library(
proto = ":service_pl_proto",
visibility = ["//src/cloud:__subpackages__"],
deps = [
"//src/api/proto/uuidpb:uuid_pl_go_proto",
"//src/api/proto/vizierconfigpb:vizier_pl_go_proto",
],
)
123 changes: 68 additions & 55 deletions src/cloud/config_manager/configmanagerpb/service.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/cloud/config_manager/configmanagerpb/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ package px.services;
option go_package = "configmanagerpb";

import "github.com/gogo/protobuf/gogoproto/gogo.proto";
import "src/api/proto/uuidpb/uuid.proto";
import "src/api/proto/vizierconfigpb/vizier_types.proto";

// ConfigManagerService provides configuration specs from the Cloud.
Expand All @@ -43,7 +44,7 @@ message ConfigForVizierRequest {
// Kubernetes version of the cluster Vizier is running on.
string k8s_version = 3 [ (gogoproto.customname) = "K8sVersion" ];
// ID of the Vizier (Cluster ID).
string vizier_id = 4 [ (gogoproto.customname) = "VizierID" ];
uuidpb.UUID vizier_id = 4 [ (gogoproto.customname) = "VizierID" ];
}

// ConfigForVizierResponse is the response to a ConfigForVizierRequest.
Expand Down
1 change: 1 addition & 0 deletions src/cloud/config_manager/controllers/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ go_library(
importpath = "px.dev/pixie/src/cloud/config_manager/controllers",
visibility = ["//visibility:public"],
deps = [
"//src/api/proto/uuidpb:uuid_pl_go_proto",
"//src/cloud/artifact_tracker/artifacttrackerpb:artifact_tracker_pl_go_proto",
"//src/cloud/config_manager/configmanagerpb:service_pl_go_proto",
"//src/cloud/vzmgr/vzmgrpb:service_pl_go_proto",
Expand Down
7 changes: 4 additions & 3 deletions src/cloud/config_manager/controllers/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"google.golang.org/grpc/metadata"
"k8s.io/apimachinery/pkg/api/resource"

"px.dev/pixie/src/api/proto/uuidpb"
atpb "px.dev/pixie/src/cloud/artifact_tracker/artifacttrackerpb"
cpb "px.dev/pixie/src/cloud/config_manager/configmanagerpb"
"px.dev/pixie/src/cloud/vzmgr/vzmgrpb"
Expand Down Expand Up @@ -101,7 +102,7 @@ func (s *Server) getOrgIDForDeployKey(deployKey string) (uuid.UUID, error) {
}

// Helper function that looks up the org ID based on the VizierID so we can use it to set feature flags.
func (s *Server) getOrgIDForVizier(vizierID string) (uuid.UUID, error) {
func (s *Server) getOrgIDForVizier(vizierID *uuidpb.UUID) (uuid.UUID, error) {
serviceAuthToken, err := getServiceCredentials(viper.GetString("jwt_signing_key"))
if err != nil {
return uuid.Nil, err
Expand All @@ -110,7 +111,7 @@ func (s *Server) getOrgIDForVizier(vizierID string) (uuid.UUID, error) {
ctx := metadata.AppendToOutgoingContext(context.Background(), "authorization",
fmt.Sprintf("bearer %s", serviceAuthToken))

resp, err := s.vzmgrClient.GetOrgFromVizier(ctx, utils.ProtoFromUUIDStrOrNil(vizierID))
resp, err := s.vzmgrClient.GetOrgFromVizier(ctx, vizierID)
if err != nil || resp == nil || resp.OrgID == nil {
return uuid.Nil, fmt.Errorf("Error fetching Vizier org ID: %s", err.Error())
}
Expand Down Expand Up @@ -244,7 +245,7 @@ func (s *Server) GetConfigForVizier(ctx context.Context,
if err != nil || orgID == uuid.Nil {
log.WithError(err).Error("Error getting org ID from deploy key")
}
if orgID == uuid.Nil && in.VizierID != "" {
if orgID == uuid.Nil && in.VizierID != nil {
orgID, err = s.getOrgIDForVizier(in.VizierID)
if err != nil || orgID == uuid.Nil {
log.WithError(err).Error("Error getting the org ID from Vizier")
Expand Down

0 comments on commit e5d83b7

Please sign in to comment.