Skip to content
This repository was archived by the owner on Jun 11, 2025. It is now read-only.

feat: tenant-agent now syncs Cluster Gateway resource prior to streaming#386

Merged
nxtcoder17 merged 2 commits into
release-v1.1.1from
fix/agent-gateway-exchange
Oct 24, 2024
Merged

feat: tenant-agent now syncs Cluster Gateway resource prior to streaming#386
nxtcoder17 merged 2 commits into
release-v1.1.1from
fix/agent-gateway-exchange

Conversation

@nxtcoder17
Copy link
Copy Markdown
Member

@nxtcoder17 nxtcoder17 commented Oct 24, 2024

Resolves kloudlite/kloudlite#299
Resolves kloudlite/kloudlite#300
Resolves kloudlite/kloudlite#301

Resolves kloudlite/kloudlite#298

Summary by Sourcery

Add functionality to sync Cluster Gateway resources in the tenant-agent before streaming, and enhance the infrastructure service with a new gRPC method for retrieving these resources.

New Features:

  • Introduce the ability for the tenant-agent to sync the Cluster Gateway resource before streaming, enhancing the synchronization process.

Enhancements:

  • Add a new gRPC method to handle the retrieval of Cluster Gateway resources, improving the infrastructure service capabilities.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Oct 24, 2024

Reviewer's Guide by Sourcery

This PR implements functionality for tenant-agent to sync Cluster Gateway resources before streaming. The changes include adding new gRPC service methods for gateway resource management and modifying the tenant-agent to fetch gateway resources during initialization.

Sequence diagram for syncing Cluster Gateway resource

sequenceDiagram
    participant TenantAgent
    participant MessageOffice
    participant InfraService
    participant Domain

    TenantAgent->>MessageOffice: SendClusterGatewayResource request
    MessageOffice->>InfraService: GetClusterGatewayResource request
    InfraService->>Domain: GetGatewayResource(accountName, clusterName)
    Domain-->>InfraService: GatewayResource
    InfraService-->>MessageOffice: GatewayResource
    MessageOffice-->>TenantAgent: GatewayResource
    TenantAgent->>TenantAgent: Apply GatewayResource YAML
Loading

Class diagram for new gRPC service methods

classDiagram
    class GetClusterGatewayResourceIn {
        +string AccountName
        +string ClusterName
    }
    class GetClusterGatewayResourceOut {
        +byte[] Gateway
    }
    class grpcServer {
        +GetClusterGatewayResource(ctx, in GetClusterGatewayResourceIn) GetClusterGatewayResourceOut
    }
    class Domain {
        +GetGatewayResource(ctx, accountName, clusterName) Gateway
    }
    grpcServer --> GetClusterGatewayResourceIn
    grpcServer --> GetClusterGatewayResourceOut
    grpcServer --> Domain
    Domain --> GetClusterGatewayResourceOut
Loading

File-Level Changes

Change Details Files
Added new gRPC service methods for Cluster Gateway resource management
  • Added GetClusterGatewayResourceIn and GetClusterGatewayResourceOut message types
  • Added GetClusterGatewayResource method to Infra service
  • Implemented GetClusterGatewayResource server handler
apps/infra/protobufs/infra/infra.pb.go
apps/infra/protobufs/infra/infra_grpc.pb.go
apps/infra/internal/app/grpc-server.go
Enhanced tenant-agent to fetch and sync gateway resources
  • Added askForGatewayResource function to fetch gateway resource during initialization
  • Modified main loop to handle gateway resource syncing
  • Added error handling and retry logic for gateway resource fetching
  • Added new kubeApiAddr flag for development environment
apps/tenant-agent/main.go
Updated domain layer to support gateway resource operations
  • Added GetGatewayResource method to Domain interface
  • Implemented GetGatewayResource in domain implementation
  • Added necessary imports for networking types
apps/infra/internal/domain/api.go
apps/infra/internal/domain/global-vpn-cluster-connection.go
Updated message-office server implementation
  • Added SendClusterGatewayResource implementation
  • Updated imports to use new protobuf package paths
  • Added placeholder for ReceiveIotConsoleResourceUpdate
apps/message-office/internal/app/grpc-server.go
apps/message-office/internal/app/app.go

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @nxtcoder17 - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread apps/tenant-agent/main.go
return errors.NewE(err)
}

if _, err := g.yamlClient.ApplyYAML(ctx, out.Gateway); err != nil {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (bug_risk): Consider returning the error from ApplyYAML instead of just logging it

Since this is initialization code for the gateway resource, failing to apply it should probably trigger a retry of the whole connection setup.

	result, err := g.yamlClient.ApplyYAML(ctx, out.Gateway)
	if err != nil {
		return fmt.Errorf("failed to apply gateway YAML: %w", err)
	}

@kloudlite kloudlite deleted a comment from sourcery-ai Bot Oct 24, 2024
@nxtcoder17 nxtcoder17 force-pushed the fix/agent-gateway-exchange branch from d13084f to d87efdd Compare October 24, 2024 18:11
@nxtcoder17 nxtcoder17 merged commit ba4315f into release-v1.1.1 Oct 24, 2024
@nxtcoder17 nxtcoder17 deleted the fix/agent-gateway-exchange branch October 24, 2024 18:26
@nxtcoder17 nxtcoder17 self-assigned this Oct 24, 2024
abdheshnayak pushed a commit that referenced this pull request Nov 5, 2024
…ange

feat: tenant-agent now syncs Cluster Gateway resource prior to streaming
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

1 participant