Skip to content

Commit 056c7f3

Browse files
authored
Add codegen resource and delete redundant content (#858)
1 parent e56e218 commit 056c7f3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+3712
-1945
lines changed
File renamed without changes.

dubbod/discovery/pkg/bootstrap/cert_controller.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ func (s *Server) initDNSCertsK8SRA() error {
131131

132132
s.addStartFunc("dubbod server certificate rotation", func(stop <-chan struct{}) error {
133133
go func() {
134-
// Track TTL of DNS cert and renew cert in accordance to grace period.
135134
s.RotateDNSCertForK8sCA(stop, "", signerName, true, SelfSignedCACertTTL.Get())
136135
}()
137136
return nil
@@ -163,15 +162,12 @@ func (s *Server) initDNSCertsDubbod() error {
163162
}
164163
}
165164

166-
// check if signing key file exists the cert dir and if the dubbo-generated file
167-
// exists (only if USE_CACERTS_FOR_SELF_SIGNED_CA is enabled)
168165
if !detectedSigningCABundle {
169166
log.Infof("Use roots from dubbo-ca-secret")
170167

171168
caBundle = s.CA.GetCAKeyCertBundle().GetRootCertPem()
172169
s.addStartFunc("dubbod server certificate rotation", func(stop <-chan struct{}) error {
173170
go func() {
174-
// regenerate dubbod key cert when root cert changes.
175171
s.watchRootCertAndGenKeyCert(stop)
176172
}()
177173
return nil
@@ -180,10 +176,8 @@ func (s *Server) initDNSCertsDubbod() error {
180176
log.Infof("Use roots from %v and watch", fileBundle.RootCertFile)
181177

182178
caBundle = s.CA.GetCAKeyCertBundle().GetRootCertPem()
183-
// Similar code to dubbo-ca-secret: refresh the root cert, but in casecrets
184179
s.addStartFunc("dubbod server certificate rotation", func(stop <-chan struct{}) error {
185180
go func() {
186-
// regenerate dubbod key cert when root cert changes.
187181
s.watchRootCertAndGenKeyCert(stop)
188182
}()
189183
return nil
@@ -230,5 +224,6 @@ func (s *Server) updateRootCertAndGenKeyCert() error {
230224
}
231225

232226
s.dubbodCertBundleWatcher.SetAndNotify(keyPEM, certChain, caBundle)
227+
233228
return nil
234229
}

dubbod/discovery/pkg/bootstrap/config_controller.go

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ func (s *Server) initK8SConfigStore(args *DubboArgs) error {
8080
s.environment.GatewayAPIController = gwc
8181
s.ConfigStores = append(s.ConfigStores, s.environment.GatewayAPIController)
8282

83-
// Use a channel to signal activation of per-revision status writer
8483
activatePerRevisionStatusWriterCh := make(chan struct{})
8584
s.checkAndRunNonRevisionLeaderElectionIfRequired(args, activatePerRevisionStatusWriterCh)
8685

@@ -115,11 +114,6 @@ func (s *Server) initK8SConfigStore(args *DubboArgs) error {
115114
if s.kubeClient.CrdWatcher().WaitForCRD(gvr.KubernetesGateway, leaderStop) {
116115
controller := gateway.NewDeploymentController(s.kubeClient, s.clusterID, s.environment,
117116
s.webhookInfo.getWebhookConfig, s.webhookInfo.addHandler, nil, args.Revision, args.Namespace)
118-
// Start informers again. This fixes the case where informers for namespace do not start,
119-
// as we create them only after acquiring the leader lock
120-
// Note: stop here should be the overall pilot stop, NOT the leader election stop. We are
121-
// basically lazy loading the informer, if we stop it when we lose the lock we will never
122-
// recreate it again.
123117
s.kubeClient.RunAndWait(stop)
124118
// TODO tag watcher
125119
controller.Run(leaderStop)
@@ -144,8 +138,6 @@ func (s *Server) initK8SConfigStore(args *DubboArgs) error {
144138
return nil
145139
}
146140

147-
// initConfigSources will process mesh config 'configSources' and initialize
148-
// associated configs.
149141
func (s *Server) initConfigSources(args *DubboArgs) (err error) {
150142
for _, configSource := range s.environment.Mesh().ConfigSources {
151143
srcAddress, err := url.Parse(configSource.Address)
@@ -171,10 +163,6 @@ func (s *Server) initConfigSources(args *DubboArgs) (err error) {
171163
s.ConfigStores = append(s.ConfigStores, configController)
172164
log.Infof("Started File configSource %s", configSource.Address)
173165
case XDS:
174-
// XDS config source support (legacy - MCP protocol removed)
175-
// Note: MCP was a legacy protocol replaced by APIGenerator in Dubbo
176-
// This XDS config source may not be needed for proxyless mesh
177-
// TLS settings removed from ConfigSource - use insecure credentials
178166
// TODO: Implement TLS support when needed
179167
xdsClient, err := adsc.New(srcAddress.Host, &adsc.ADSConfig{
180168
InitialDiscoveryRequests: adsc.ConfigInitialRequests(),
@@ -223,8 +211,6 @@ func (s *Server) initConfigSources(args *DubboArgs) (err error) {
223211
func (s *Server) initConfigController(args *DubboArgs) error {
224212
meshGlobalConfig := s.environment.Mesh()
225213
if len(meshGlobalConfig.ConfigSources) > 0 {
226-
// XDS config source support (legacy - MCP protocol removed)
227-
// Note: MCP was a legacy protocol replaced by APIGenerator in Dubbo
228214
if err := s.initConfigSources(args); err != nil {
229215
return err
230216
}
@@ -247,17 +233,14 @@ func (s *Server) initConfigController(args *DubboArgs) error {
247233
}
248234
}
249235

250-
// Wrap the config controller with a cache.
251236
aggregateConfigController, err := configaggregate.MakeCache(s.ConfigStores)
252237
if err != nil {
253238
return err
254239
}
255240
s.configController = aggregateConfigController
256241

257-
// Create the config store.
258242
s.environment.ConfigStore = aggregateConfigController
259243

260-
// Defer starting the controller until after the service is created.
261244
s.addStartFunc("config controller", func(stop <-chan struct{}) error {
262245
go s.configController.Run(stop)
263246
return nil
@@ -266,7 +249,6 @@ func (s *Server) initConfigController(args *DubboArgs) error {
266249
return nil
267250
}
268251

269-
// getRootCertFromSecret fetches a map of keys and values from a secret with name in namespace
270252
func (s *Server) getRootCertFromSecret(name, namespace string) (*dubboCredentials.CertInfo, error) {
271253
secret, err := s.kubeClient.Kube().CoreV1().Secrets(namespace).Get(context.Background(), name, v1.GetOptions{})
272254
if err != nil {
@@ -279,7 +261,6 @@ func (s *Server) checkAndRunNonRevisionLeaderElectionIfRequired(args *DubboArgs,
279261
cm, err := s.kubeClient.Kube().CoreV1().ConfigMaps(args.Namespace).Get(context.Background(), leaderelection.GatewayStatusController, v1.GetOptions{})
280262

281263
if errors.IsNotFound(err) {
282-
// ConfigMap does not exist, so per-revision leader election should be active
283264
close(activateCh)
284265
return
285266
}
@@ -290,10 +271,8 @@ func (s *Server) checkAndRunNonRevisionLeaderElectionIfRequired(args *DubboArgs,
290271
}
291272
if err := json.Unmarshal([]byte(leaderAnn), &leaderInfo); err == nil {
292273
if leaderInfo.HolderIdentity != "" {
293-
// Non-revision leader election should run, per-revision should be waiting for activation
294274
s.addTerminatingStartFunc("gateway status", func(stop <-chan struct{}) error {
295275
secondStop := make(chan struct{})
296-
// if stop closes, ensure secondStop closes too
297276
go func() {
298277
<-stop
299278
select {
@@ -305,16 +284,12 @@ func (s *Server) checkAndRunNonRevisionLeaderElectionIfRequired(args *DubboArgs,
305284
leaderelection.
306285
NewLeaderElection(args.Namespace, args.PodName, leaderelection.GatewayStatusController, args.Revision, s.kubeClient).
307286
AddRunFunction(func(leaderStop <-chan struct{}) {
308-
// now that we have the leader lock, we can activate the per-revision status writer
309-
// first close the activateCh channel if it is not already closed
310287
log.Infof("Activating gateway status writer")
311288
select {
312289
case <-activateCh:
313-
// Channel already closed, do nothing
314290
default:
315291
close(activateCh)
316292
}
317-
// now end this lease itself
318293
select {
319294
case <-secondStop:
320295
default:
@@ -328,6 +303,5 @@ func (s *Server) checkAndRunNonRevisionLeaderElectionIfRequired(args *DubboArgs,
328303
}
329304
}
330305
}
331-
// If annotation missing or holderIdentity is blank, per-revision leader election should be active
332306
close(activateCh)
333307
}

dubbod/discovery/pkg/bootstrap/dubbo_ca.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ func (s *Server) createDubboRA(opts *caOptions) (ra.RegistrationAuthority, error
156156
return nil, fmt.Errorf("failed to get file info: %v", err)
157157
}
158158

159-
// File does not exist.
160159
if certSignerDomain == "" {
161160
log.Infof("CA cert file %q not found, using %q.", caCertFile, defaultCACertPath)
162161
caCertFile = defaultCACertPath
@@ -230,15 +229,12 @@ func (s *Server) createDubboCA(opts *caOptions) (*ca.DubboCA, error) {
230229
log.Infof("DubboGenerated %s secret found, use it as the CA certificate", ca.CACertsSecret)
231230
}
232231

233-
// Either the secret is not mounted because it is named `dubbo-ca-secret`,
234-
// or it is `cacerts` secret mounted with "dubbo-generated" key set.
235232
caOpts, err = s.createSelfSignedCACertificateOptions(&fileBundle, opts)
236233
if err != nil {
237234
return nil, err
238235
}
239236
caOpts.OnRootCertUpdate = s.updateRootCertAndGenKeyCert
240237
} else {
241-
// The secret is mounted and the "dubbo-generated" key is not used.
242238
log.Info("Use local CA certificate")
243239

244240
caOpts, err = ca.NewPluggedCertDubboCAOptions(fileBundle, workloadCertTTL.Get(), maxWorkloadCertTTL.Get(), caRSAKeySize.Get())
@@ -247,8 +243,6 @@ func (s *Server) createDubboCA(opts *caOptions) (*ca.DubboCA, error) {
247243
}
248244

249245
if features.EnableCACRL {
250-
// CRL is only supported for Plugged CA.
251-
// If CRL file is present, read and notify it for initial replication
252246
if len(fileBundle.CRLFile) > 0 {
253247
log.Infof("CRL file %s found, notifying it for initial replication", fileBundle.CRLFile)
254248
crlBytes, crlErr := os.ReadFile(fileBundle.CRLFile)
@@ -268,7 +262,6 @@ func (s *Server) createDubboCA(opts *caOptions) (*ca.DubboCA, error) {
268262
return nil, fmt.Errorf("failed to create an dubbod CA: %v", err)
269263
}
270264

271-
// Start root cert rotator in a separate goroutine.
272265
dubboCA.Run(s.internalStop)
273266
return dubboCA, nil
274267
}
@@ -335,7 +328,6 @@ func handleEvent(s *Server) {
335328
return
336329
}
337330

338-
// check if CA bundle is updated
339331
newCABundle, err = os.ReadFile(fileBundle.RootCertFile)
340332
if err != nil {
341333
log.Errorf("failed reading root-cert.pem: %v", err)
@@ -344,10 +336,7 @@ func handleEvent(s *Server) {
344336

345337
currentCABundle := s.CA.GetCAKeyCertBundle().GetRootCertPem()
346338

347-
// Only updating intermediate CA is supported now
348339
if !bytes.Equal(currentCABundle, newCABundle) {
349-
// in order to support root ca rotation, or we are removing the old ca,
350-
// we need to make the new CA bundle contain both old and new CA certs
351340
if bytes.Contains(currentCABundle, newCABundle) ||
352341
bytes.Contains(newCABundle, currentCABundle) {
353342
log.Info("Updating new ROOT-CA")
@@ -359,14 +348,10 @@ func handleEvent(s *Server) {
359348
}
360349

361350
if features.EnableCACRL {
362-
// check if crl file is updated
363351
if len(fileBundle.CRLFile) > 0 {
364352
currentCRLData := s.CA.GetCAKeyCertBundle().GetCRLPem()
365353
crlData, crlReadErr := os.ReadFile(fileBundle.CRLFile)
366354
if crlReadErr != nil {
367-
// handleEvent can be triggered either for key-cert bundle update or
368-
// for crl file update. So, even if there is an error in reading crl file,
369-
// we should log error and continue with key-cert bundle update.
370355
log.Errorf("failed reading crl file: %v", crlReadErr)
371356
}
372357

@@ -395,7 +380,6 @@ func handleEvent(s *Server) {
395380
return
396381
}
397382

398-
// notify watcher to replicate new or updated crl data
399383
if updateCRL {
400384
s.dubbodCertBundleWatcher.SetAndNotifyCACRL(s.CA.GetCAKeyCertBundle().GetCRLPem())
401385
log.Infof("Dubbod has detected the newly added CRL file and updated its CRL accordingly")
@@ -483,7 +467,6 @@ func checkCABundleCompleteness(signingKeyFile, signingCertFile, rootCertFile str
483467
func detectSigningCABundleAndCRL() (ca.SigningCAFileBundle, error) {
484468
tlsSigningFile := path.Join(LocalCertDir.Get(), ca.TLSSecretCACertFile)
485469

486-
// looking for tls file format (tls.crt)
487470
if _, err := os.Stat(tlsSigningFile); err == nil {
488471
log.Info("Using kubernetes.io/tls secret type for signing ca files")
489472
return ca.SigningCAFileBundle{
@@ -500,7 +483,6 @@ func detectSigningCABundleAndCRL() (ca.SigningCAFileBundle, error) {
500483
}
501484

502485
log.Info("Using dubbod file format for signing ca files")
503-
// default ca file format
504486
signingCAFileBundle := ca.SigningCAFileBundle{
505487
RootCertFile: path.Join(LocalCertDir.Get(), ca.RootCertFile),
506488
CertChainFiles: []string{path.Join(LocalCertDir.Get(), ca.CertChainFile)},
@@ -509,7 +491,6 @@ func detectSigningCABundleAndCRL() (ca.SigningCAFileBundle, error) {
509491
}
510492

511493
if features.EnableCACRL {
512-
// load crl file if it exists
513494
crlFilePath := path.Join(LocalCertDir.Get(), ca.CACRLFile)
514495
if _, err := os.Stat(crlFilePath); err == nil {
515496
log.Info("Detected CRL file")

dubbod/discovery/pkg/bootstrap/injector.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ import (
3333
)
3434

3535
const (
36-
webhookName = "grpcxds-injector.dubbo.apache.org"
37-
defaultInjectorConfigMapName = "dubbo-grpcxds-injector"
36+
webhookName = "proxyless-injector.dubbo.apache.org"
37+
defaultInjectorConfigMapName = "dubbo-proxyless-injector"
3838
)
3939

4040
var injectionEnabled = env.Register("INJECT_ENABLED", true, "Enable mutating webhook handler.")
@@ -43,11 +43,10 @@ func (s *Server) initInjector(args *DubboArgs) (*inject.Webhook, error) {
4343
// currently the constant: "./var/lib/dubbo/inject"
4444
injectPath := args.InjectionOptions.InjectionDirectory
4545
if injectPath == "" || !injectionEnabled.Get() {
46-
log.Infof("Skipping grpcxds injector, injection path is missing or disabled.")
46+
log.Infof("Skipping proxyxless injector, injection path is missing or disabled.")
4747
return nil, nil
4848
}
4949

50-
// If the injection config exists either locally or remotely, we will set up injection.
5150
var watcher inject.Watcher
5251
if _, err := os.Stat(filepath.Join(injectPath, "config")); !os.IsNotExist(err) {
5352
configFile := filepath.Join(injectPath, "config")
@@ -61,18 +60,18 @@ func (s *Server) initInjector(args *DubboArgs) (*inject.Webhook, error) {
6160
cms := s.kubeClient.Kube().CoreV1().ConfigMaps(args.Namespace)
6261
if _, err := cms.Get(context.TODO(), configMapName, metav1.GetOptions{}); err != nil {
6362
if errors.IsNotFound(err) {
64-
log.Infof("Skipping grpcxds injector, template not found")
63+
log.Infof("Skipping proxyless injector, template not found")
6564
return nil, nil
6665
}
6766
return nil, err
6867
}
6968
watcher = inject.NewConfigMapWatcher(s.kubeClient, args.Namespace, configMapName, "config", "values")
7069
} else {
71-
log.Infof("Skipping grpcxds injector, template not found")
70+
log.Infof("Skipping proxyless injector, template not found")
7271
return nil, nil
7372
}
7473

75-
log.Info("initializing grpcxds injector")
74+
log.Info("initializing proxyless injector")
7675

7776
parameters := inject.WebhookParameters{
7877
Watcher: watcher,

dubbod/discovery/pkg/bootstrap/options.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ type RegistryOptions struct {
4040
}
4141

4242
type InjectionOptions struct {
43-
// Directory of injection related config files.
4443
InjectionDirectory string
4544
}
4645

@@ -66,12 +65,11 @@ type DiscoveryServerOptions struct {
6665
}
6766

6867
type TLSOptions struct {
69-
// CaCertFile and related are set using CLI flags.
7068
CaCertFile string
7169
CertFile string
7270
KeyFile string
7371
TLSCipherSuites []string
74-
CipherSuits []uint16 // This is the parsed cipher suites
72+
CipherSuits []uint16
7573
}
7674

7775
func (p *DubboArgs) applyDefaults() {
@@ -85,10 +83,8 @@ func (p *DubboArgs) applyDefaults() {
8583
func NewDubboArgs(initFuncs ...func(*DubboArgs)) *DubboArgs {
8684
p := &DubboArgs{}
8785

88-
// Apply Default Values.
8986
p.applyDefaults()
9087

91-
// Apply custom initialization functions.
9288
for _, fn := range initFuncs {
9389
fn(p)
9490
}

0 commit comments

Comments
 (0)