-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Added a cloud-based module, responsible for message notifications, license issuance and validation, information collection, and monitoring functions. #3409
Conversation
Whoa! Easy there, Partner!This PR is too big. Please break it up into smaller PRs. |
🤖 Generated by lychee actionSummary
Full action output |
Codecov ReportPatch and project coverage have no change.
Additional details and impacted files@@ Coverage Diff @@
## main #3409 +/- ##
=======================================
Coverage 72.97% 72.97%
=======================================
Files 8 8
Lines 618 618
=======================================
Hits 451 451
Misses 132 132
Partials 35 35 ☔ View full report in Codecov by Sentry. |
bc11d6d
to
869b069
Compare
) | ||
|
||
// CloudClientReconciler reconciles a CloudClient object | ||
type CloudClientReconciler struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
命名头疼。。。。
// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.14.4/pkg/reconcile | ||
func (r *CloudClientReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { | ||
r.logger.Info("Enter CloudClientReconcile", "namespace:", req.Namespace, "name", req.Name) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
注意格式
} | ||
|
||
r.logger.Info("Try to get the cloud secret resource...") | ||
resource := util.NewImportanctResource(&clusterSecret, types.NamespacedName{Namespace: cloud.Namespace, Name: cloud.SecretName}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
何为 Importenct Resource?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some resources related to Licenses contain important information that needs to be stored persistently. If these resources are deleted, it could lead to unforeseen consequences. Therefore, related callback functions are triggered in GetImportanceResource to detect intrusion behavior, and appropriate actions will be taken when such behavior is discovered.
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. | ||
|
||
// CloudClientSpec defines the desired state of CloudClient | ||
type CloudClientSpec struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CR is a resource not a Client
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The purpose of the CloudClient Custom Resource (CR) is to serve as the startup resource for the entire module controller. All reconcile functions need to listen to the CloudClient resource to initiate the interaction process with the cloud. The name CloudClient is indeed quite apt...
FALSE = "false" | ||
) | ||
|
||
func ReadConfigFile(filepath string, logger logr.Logger) (cloud.Config, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Read config form configmap or ENV is better than config file.
3198f3a
to
b4bae28
Compare
4750d14
to
2ef7cab
Compare
…fferent scenarios.
r.logger.Info("Enter LauncherReconcile", "namespace:", req.Namespace, "name", req.Name) | ||
if r.Retries > 5 { | ||
return ctrl.Result{}, nil | ||
} | ||
r.Retries++ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return ctrl.Result{ Requeue: false}, err
config, err = util.ReadConfigFromConfigMap(string(cloud.ConfigName), &configMap) | ||
if err != nil { | ||
r.logger.Error(err, "failed to read config") | ||
return ctrl.Result{}, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicate code: config, err = util.ReadConfigFromConfigMap(string(cloud.ConfigName), &configMap)
} | ||
} | ||
|
||
func NotificationResponseToNotification(resp NotificationResponse) ntf.Notification { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return *ntf.Notification
return err | ||
} else { | ||
return err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else {
return err
}
return err
…cense issuance and validation, information collection, and monitoring functions. (labring#3409) * add a notification controller * fix notification controller bugs, add RWMutex * Add cloudclient reconcile * add license controller and cloudsync controller * add cloudsync controller and fix bugs * fix go mod * fix gitignore bugs * Enhanced the coding standards * add cloud collector controller, fix some bugs * add license monitor * add license monitor * init encrypt account * fix bugs * fix bugs * fix bugs * Simplified the code logic and unified the abstract logic under two different scenarios. * fix bugs * fix bugs * fix bugs * modify the name and fix bugs --------- Co-authored-by: jiahui <bxy4543@gmail.com>
🤖 Generated by Copilot at 4882579
Summary
🐳📜🛠️
This pull request adds the initial code and configuration for the controllers/cloud project, which is a Kubernetes controller that manages CloudClient and License custom resources. The pull request adds the API types, the CRD manifests, the controller logic, the webhook logic, the Dockerfile, the Makefile, the PROJECT file, and the README file for the project. The pull request also adds the .dockerignore and .gitignore files to exclude unnecessary or sensitive files from the docker and git contexts. The pull request uses kubebuilder, controller-gen, kustomize, and docker buildx tools to scaffold and build the project.
Walkthrough