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

WIP: fix too many csrs in registration. #643

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/registration/register/csr/csr.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ func (c *CSRDriver) Process(
if !shouldCreate {
return nil, nil, nil
}
fmt.Printf("TODO: remove, shouldCreateCSR is true for controller: %s, namespace: %s, name: %s\n", controllerName, secret.Namespace, secret.Name)

shouldHalt := csrOption.HaltCSRCreation()
if shouldHalt {
Expand Down Expand Up @@ -310,6 +311,7 @@ func shouldCreateCSR(
recorder events.Recorder,
subject *pkix.Name,
additionalSecretData map[string][]byte) (bool, error) {
fmt.Printf("TODO: remove, shouldCreateCSR for controller: %s, namespace: %s, name: %s\n", controllerName, secret.Namespace, secret.Name)
// create a csr to request new client certificate if
// a.there is no valid client certificate issued for the current cluster/agent
valid, err := isCertificateValid(logger, secret.Data[TLSCertFile], subject)
Expand Down
5 changes: 5 additions & 0 deletions pkg/registration/register/secret_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ func NewSecretController(
}
// only enqueue a specific secret
if accessor.GetNamespace() == c.SecretNamespace && accessor.GetName() == c.SecretName {
fmt.Printf("TODO: remove, enqueuing secret for controller: %s, namespace: %s, name: %s", c.controllerName, c.SecretNamespace, c.SecretName)
return true
}
return false
Expand All @@ -101,6 +102,9 @@ func NewSecretController(
}

func (c *secretController) sync(ctx context.Context, syncCtx factory.SyncContext) error {
// log the controller name
fmt.Printf("TODO: remove, syncing secret for controller: %s, namespace: %s, name: %s\n", c.controllerName, c.SecretNamespace, c.SecretName)

// get secret containing client certificate
secret, err := c.ManagementCoreClient.Secrets(c.SecretNamespace).Get(ctx, c.SecretName, metav1.GetOptions{})
switch {
Expand Down Expand Up @@ -143,6 +147,7 @@ func (c *secretController) sync(ctx context.Context, syncCtx factory.SyncContext
}

// save the changes into secret
time.Sleep(5 * time.Second)
if err := saveSecret(c.ManagementCoreClient, c.SecretNamespace, c.secretToSave); err != nil {
return err
}
Expand Down
1 change: 1 addition & 0 deletions pkg/registration/spoke/registration/registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ func NewCSROption(
}

// only enqueue csr whose name starts with the cluster name
fmt.Printf("TODO: remove, enqueue csr for cluster: %s, name: %s\n", secretOption.ClusterName, accessor.GetName())
return strings.HasPrefix(accessor.GetName(), fmt.Sprintf("%s-", secretOption.ClusterName))
},
HaltCSRCreation: haltCSRCreationFunc(csrControl.Informer().GetIndexer(), secretOption.ClusterName),
Expand Down
Loading