[Feature] [Operator] Optimize the InjectStorage method of OAPServerReconciler to improve the efficiency of Reconcile execution
Los mantenedores suelen responder en 1 día
@dashanji ya está trabajando en esto.
Desde el 13/11/2023.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
Search before asking
- I had searched in the issues and found no similar feature requirement.
Description
the skywalking-swck version is v0.8.0. when i create an oapserver instance, the OAPServerReconciler will excute reconcile method, I found the InjectStorage method is only used to check storage name and get storage info like SW_STORAGE_ES_HTTP_PROTOCOL,SW_STORAGE, SW_ES_USER, SW_ES_PASSWORD and so on to append to oapserver.spec.config field. But this method and subsequent methods does not perform update the oapserver instance to kube-apiserver. So these updates are invalid, can we optimize the InjectStorage method to only check whether the storage name is exists?
func (r *OAPServerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
log := runtimelog.FromContext(ctx)
log.Info("=====================oapserver reconcile started================================")
oapServer := operatorv1alpha1.OAPServer{}
if err := r.Client.Get(ctx, req.NamespacedName, &oapServer); err != nil {
return ctrl.Result{}, client.IgnoreNotFound(err)
}
ff, err := r.FileRepo.GetFilesRecursive("templates")
if err != nil {
log.Error(err, "failed to load resource templates")
return ctrl.Result{}, err
}
app := kubernetes.Application{
Client: r.Client,
FileRepo: r.FileRepo,
CR: &oapServer,
GVK: operatorv1alpha1.GroupVersion.WithKind("OAPServer"),
Recorder: r.Recorder,
}
r.InjectStorage(ctx, log, &oapServer)
if err := app.ApplyAll(ctx, ff, log); err != nil {
return ctrl.Result{}, err
}
if err := r.checkState(ctx, log, &oapServer); err != nil {
l.Error(err, "failed to check sub resources state")
return ctrl.Result{}, err
}
return ctrl.Result{RequeueAfter: schedDuration}, nil
}
// InjectStorage Inject Storage
func (r *OAPServerReconciler) InjectStorage(ctx context.Context, log logr.Logger, oapServer *operatorv1alpha1.OAPServer) {
if oapServer.Spec.StorageConfig.Name == "" {
return
}
storage := &operatorv1alpha1.Storage{}
err := r.Client.Get(ctx, client.ObjectKey{Namespace: oapServer.Namespace, Name: oapServer.Spec.StorageConfig.Name}, storage)
if err == nil {
r.ConfigStorage(ctx, log, storage, oapServer)
log.Info("success inject storage")
} else {
log.Info("fail inject storage")
}
}
func (r *OAPServerReconciler) ConfigStorage(ctx context.Context, log logr.Logger, s *operatorv1alpha1.Storage, o *operatorv1alpha1.OAPServer) {
user, tls := s.Spec.Security.User, s.Spec.Security.TLS
SwStorageEsHTTPProtocol := "http"
SwEsUser := ""
SwEsPassword := ""
SwStorageEsSslJksPath := ""
SwStorageEsSslJksPass := "skywalking"
SwStorageEsClusterNodes := ""
o.Spec.StorageConfig.Storage = *s
if user.SecretName != "" {
if user.SecretName == "default" {
SwEsUser = "elastic"
SwEsPassword = "changeme"
} else {
usersecret := &core.Secret{}
if err := r.Client.Get(ctx, client.ObjectKey{Namespace: s.Namespace, Name: user.SecretName}, usersecret); err != nil && !apierrors.IsNotFound(err) {
log.Info("fail get usersecret ")
}
for k, v := range usersecret.Data {
if k == "username" {
SwEsUser = string(v)
} else if k == "password" {
SwEsPassword = string(v)
}
}
}
}
if tls {
SwStorageEsHTTPProtocol = "https"
SwStorageEsSslJksPath = "/skywalking/p12/storage.p12"
SwStorageEsClusterNodes = "skywalking-storage"
} else {
SwStorageEsClusterNodes = s.Name + "-" + s.Spec.Type
}
o.Spec.Config = append(o.Spec.Config, core.EnvVar{Name: "SW_STORAGE", Value: s.Spec.Type})
if user.SecretName != "" {
o.Spec.Config = append(o.Spec.Config, core.EnvVar{Name: "SW_ES_USER", Value: SwEsUser})
o.Spec.Config = append(o.Spec.Config, core.EnvVar{Name: "SW_ES_PASSWORD", Value: SwEsPassword})
}
if tls {
o.Spec.Config = append(o.Spec.Config, core.EnvVar{Name: "SW_STORAGE_ES_SSL_JKS_PATH", Value: SwStorageEsSslJksPath})
o.Spec.Config = append(o.Spec.Config, core.EnvVar{Name: "SW_STORAGE_ES_SSL_JKS_PASS", Value: SwStorageEsSslJksPass})
}
if apiequal.Semantic.DeepDerivative(s.Spec.ConnectType, "external") {
parseurl, _ := url.Parse(s.Spec.ConnectAddress)
SwStorageEsHTTPProtocol = parseurl.Scheme
SwStorageEsClusterNodes = parseurl.Host
o.Spec.Config = append(o.Spec.Config, core.EnvVar{Name: "SW_STORAGE_ES_HTTP_PROTOCOL", Value: SwStorageEsHTTPProtocol})
o.Spec.Config = append(o.Spec.Config, core.EnvVar{Name: "SW_STORAGE_ES_CLUSTER_NODES", Value: SwStorageEsClusterNodes})
} else {
o.Spec.Config = append(o.Spec.Config, core.EnvVar{Name: "SW_STORAGE_ES_HTTP_PROTOCOL", Value: SwStorageEsHTTPProtocol})
o.Spec.Config = append(o.Spec.Config, core.EnvVar{Name: "SW_STORAGE_ES_CLUSTER_NODES", Value: SwStorageEsClusterNodes + ":9200"})
}
}
Use case
No response
Related issues
No response
Are you willing to submit a pull request to implement this on your own?
- Yes I am willing to submit a pull request on my own!
Code of Conduct
- I agree to follow this project's Code of Conduct
- Lenguaje dominante
- Java
- Estrellas
- 25k
- Forks
- 6.6k
- Merge medio
- 15 h 37 min
- PR fusionados (30 d)
- 32
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de apache/skywalking
-
[Bug] BanyanDB trace block metadata format changed in 0.11 without a file format version bumpPosiblemente ocupada @hanahmily la tomó hoy. Abiertobug database
apache/skywalking#14169 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
chore CLI database
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
apache/skywalking#14168 ·
Los mantenedores suelen responder en 1 día
-
[Bug] BanyanDB stream scans run out of query memory even with a small limitPosiblemente ocupada @hanahmily la tomó hace 3 días. Abiertobug database
apache/skywalking#14165 · 3 comentarios · 2 asignados ·
Los mantenedores suelen responder en 1 día
-
[Feature] Canopy auth 2/2: SSO (OIDC/OAuth2), break-glass and the auth design docPosiblemente ocupada @hanahmily la tomó hace 1 día. Abiertodatabase feature
Dificultad 5/5 Más de una semana Aptitud para principiantes 20/100
apache/skywalking#14162 ·
Los mantenedores suelen responder en 1 día
-
[Feature] Canopy auth 1/2: local auth — auth config, argon2id login, server-side sessions, API tokensPosiblemente ocupada @hanahmily la tomó hace 3 días. Abiertodatabase feature
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
apache/skywalking#14159 ·
Los mantenedores suelen responder en 1 día
Todos los issues de apache/skywalking
Issues similares
-
[Bug] [Go] Ack returns nil when the server answers with a non-OK statusPosiblemente ocupada @leizhiyuan la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
apache/rocketmq-clients#1465 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
pdfium-drift
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
Stirling-Tools/JPDFium#188 ·
Los mantenedores suelen responder en 1 día
-
security
Dificultad 1/5 Menos de una hora Aptitud para principiantes 70/100
IBM/ibm-quarkus-ai-langchain4j-workshop#160 ·
Los mantenedores suelen responder en 1 día
-
Manager flashes an empty "errorOccurred" dialog while redirecting a logged-out user to loginAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
openremote/openremote#3487 · 1 comentario ·