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

Feat/owned cluster#373

Merged
abdheshnayak merged 8 commits into
release-v1.0.8from
feat/owned-cluster
Sep 27, 2024
Merged

Feat/owned cluster#373
abdheshnayak merged 8 commits into
release-v1.0.8from
feat/owned-cluster

Conversation

@abdheshnayak
Copy link
Copy Markdown
Contributor

@abdheshnayak abdheshnayak commented Sep 27, 2024

  • added feature-owned cluster
  • added app rollout on image push (webhook)

Summary by Sourcery

Add support for owned clusters and implement application rollouts on image push. Enhance the infrastructure to handle BYOK clusters and improve volume management capabilities.

New Features:

  • Introduce the concept of 'owned clusters' by adding an 'OwnedBy' field to cluster-related data structures.
  • Implement a new method to handle application rollouts triggered by image pushes via webhooks.

Enhancements:

  • Add support for handling 'BYOK' (Bring Your Own Key) clusters in the gRPC server and client interfaces.
  • Enhance volume management by introducing new fields and types related to volume attributes and modification statuses.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Sep 27, 2024

Reviewer's Guide by Sourcery

This pull request introduces a new feature for owned clusters and implements app rollout on image push using a webhook. The changes span across multiple files in the infra and console applications, affecting cluster management, environment creation, and image registry functionality.

Sequence Diagram

sequenceDiagram
    participant W as Webhook
    participant C as WebhookConsumer
    participant D as Domain
    participant R as RegistryImageRepo
    participant A as AppRepo

    W->>C: Image Push Event
    C->>D: UpsertRegistryImage
    D->>R: Upsert Image
    C->>D: RolloutAppsByImage
    D->>A: Find Apps by Image
    D->>D: Resync K8s Resources
Loading

File-Level Changes

Change Details Files
Added 'owned cluster' feature
  • Introduced 'OwnedBy' field in Cluster and BYOKCluster entities
  • Modified cluster listing to filter based on ownership
  • Updated environment creation to check for cluster ownership
  • Added new constants for cluster ownership labels
apps/infra/internal/entities/cluster.go
apps/infra/internal/entities/byok-cluster.go
apps/infra/internal/domain/clusters.go
apps/infra/internal/domain/byok-clusters.go
apps/console/internal/domain/environment.go
constants/constants.go
Implemented app rollout on image push using webhook
  • Added RolloutAppsByImage function in console domain
  • Modified webhook consumer to trigger app rollout on image push
  • Updated registry image creation to upsert instead of create
apps/console/internal/domain/app.go
apps/console/internal/app/webhook-consumer.go
apps/console/internal/domain/registry-image.go
Updated gRPC and protobuf definitions
  • Added GetByokCluster method to Infra service
  • Updated GetClusterOut message to include OwnedBy field
  • Modified protobuf compilation settings
apps/infra/protobufs/infra/infra.pb.go
apps/infra/protobufs/infra/infra_grpc.pb.go
apps/infra/internal/app/grpc-server.go
Updated Kubernetes resource definitions
  • Added new fields to PersistentVolumeClaimSpec and PersistentVolumeClaimStatus
  • Introduced ModifyVolumeStatus type
  • Updated PersistentVolumeSpec with new fields
apps/infra/internal/app/graph/model/models_gen.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.

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

@abdheshnayak abdheshnayak merged commit 92a337c into release-v1.0.8 Sep 27, 2024
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 @abdheshnayak - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider adding logging or auditing for cluster ownership changes and access attempts to aid in debugging and security monitoring.
  • Ensure that ownership checks in cluster creation and listing operations are performed atomically to prevent race conditions.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 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 to tell me if it was helpful.

return nil, ErrClusterAlreadyExists{ClusterName: cluster.Name, AccountName: ctx.AccountName}
}

if s, ok := cluster.GetLabels()[constants.ClusterLabelOwnedBy]; ok {
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: New cluster ownership validation in CreateCluster

The ownership validation here is good. Consider extracting this logic into a separate function for reusability, as it might be needed in other parts of the codebase dealing with cluster operations.

func validateClusterOwnership(cluster *v1alpha1.Cluster, userId string) error {
	if s, ok := cluster.GetLabels()[constants.ClusterLabelOwnedBy]; ok {
		if s != userId {
			return errors.Newf("provided wrong owner for cluster %q, expected %q", cluster.Name, userId)
		}
	}
	return nil
}

if err := validateClusterOwnership(cluster, string(ctx.UserId)); err != nil {
	return nil, err
}

@abdheshnayak abdheshnayak deleted the feat/owned-cluster branch September 27, 2024 07:11
abdheshnayak added a commit that referenced this pull request Nov 5, 2024
* ✨ Added checks for owned cluster

added checks for owned cluster, while creating and listing

* 🚧 Added owner checks to model

* 🚧 Changed label key for owned by

* 🐛 Fixed issues

* 🚧 Changed to byok

* ✨ Added app rollout

* ✨ Added app rollout on image push
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant