Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix duplicate deployment names in klusterlet-agent availability message #671

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

RokibulHasan7
Copy link
Contributor

Summary

Related issue(s)

Fixes #

Signed-off-by: Rokibul Hasan <mdrokibulhasan@appscode.com>
Copy link
Contributor

openshift-ci bot commented Oct 25, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: RokibulHasan7
Once this PR has been reviewed and has the lgtm label, please assign dongbeiqing91 for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link

codecov bot commented Oct 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.05%. Comparing base (865ae06) to head (980cd44).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #671      +/-   ##
==========================================
+ Coverage   63.04%   63.05%   +0.01%     
==========================================
  Files         182      182              
  Lines       17606    17612       +6     
==========================================
+ Hits        11100    11106       +6     
  Misses       5594     5594              
  Partials      912      912              
Flag Coverage Δ
unit 63.05% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -78,24 +78,27 @@ func (k *klusterletStatusController) sync(ctx context.Context, controllerContext
registrationDeploymentName := fmt.Sprintf("%s-registration-agent", klusterlet.Name)
workDeploymentName := fmt.Sprintf("%s-work-agent", klusterlet.Name)

if helpers.IsSingleton(klusterlet.Spec.DeployOption.Mode) {
IsSingleton := helpers.IsSingleton(klusterlet.Spec.DeployOption.Mode)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
IsSingleton := helpers.IsSingleton(klusterlet.Spec.DeployOption.Mode)
isSingleton := helpers.IsSingleton(klusterlet.Spec.DeployOption.Mode)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

@zhujian7
Copy link
Member

Another option is to deduplicate the agents in the checkAgentsDeploymentAvailable func, like:

// Check agent deployments, if both of them have at least 1 available replicas, return available condition
func checkAgentsDeploymentAvailable(ctx context.Context, kubeClient kubernetes.Interface, agents []klusterletAgent) metav1.Condition {
	var availableMessages []string
	components := sets.Set[string]{}  ### import "k8s.io/apimachinery/pkg/util/sets"
	for _, agent := range agents {
		componentID := fmt.Sprintf("%s-%s", agent.namespace, agent.deploymentName)
		if components.Has(componentID) {
			continue
		}
		components.Insert(componentID)
		deployment, err := kubeClient.AppsV1().Deployments(agent.namespace).Get(ctx, agent.deploymentName, metav1.GetOptions{})
		...
}

Signed-off-by: Rokibul Hasan <mdrokibulhasan@appscode.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants