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

Confirm runnning Pools before restarting existing pools #777

Merged
merged 4 commits into from
Aug 22, 2021
Merged
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
6 changes: 6 additions & 0 deletions helm/minio-operator/crds/minio.min.io_tenants.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3798,6 +3798,9 @@ spec:
type: integer
syncVersion:
type: string
waitingOnReady:
format: date-time
type: string
writeQuorum:
format: int32
type: integer
Expand Down Expand Up @@ -7625,6 +7628,9 @@ spec:
type: integer
syncVersion:
type: string
waitingOnReady:
format: date-time
type: string
writeQuorum:
format: int32
type: integer
Expand Down
1 change: 1 addition & 0 deletions logsearchapi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@ func main() {
Addr: ":8080",
Handler: ls,
}
log.Print("Log Search API Listening on Port :8080")
log.Fatal(s.ListenAndServe())
}
8 changes: 1 addition & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import (
apiextension "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
kubeinformers "k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes"
certapi "k8s.io/client-go/kubernetes/typed/certificates/v1"
"k8s.io/client-go/rest"
)

Expand Down Expand Up @@ -103,11 +102,6 @@ func main() {
klog.Fatalf("Error building MinIO clientset: %s", err.Error())
}

certClient, err := certapi.NewForConfig(cfg)
if err != nil {
klog.Errorf("Error building certificate clientset: %v", err.Error())
}

extClient, err := apiextension.NewForConfig(cfg)
if err != nil {
klog.Errorf("Error building certificate clientset: %v", err.Error())
Expand Down Expand Up @@ -162,7 +156,7 @@ func main() {
promInformerFactory = prominformers.NewSharedInformerFactory(promClient, time.Second*30)
}

mainController := cluster.NewController(kubeClient, controllerClient, *certClient, promClient,
mainController := cluster.NewController(kubeClient, controllerClient, promClient,
kubeInformerFactory.Apps().V1().StatefulSets(),
kubeInformerFactory.Apps().V1().Deployments(),
kubeInformerFactory.Batch().V1().Jobs(),
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/minio.min.io/v2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,10 @@ type TenantStatus struct {
//
// Health State of the tenant
HealthStatus HealthStatus `json:"healthStatus,omitempty"`
// *Optional* +
//
// If set, we will wait until cleared for up a given time
WaitingOnReady *metav1.Time `json:"waitingOnReady,omitempty"`
}

// CertificateConfig (`certConfig`) defines controlling attributes associated to any TLS certificate automatically generated by the Operator as part of tenant creation. These fields have no effect if `spec.autoCert: false`.
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/minio.min.io/v2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pkg/controller/cluster/csr.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (c *Controller) createCertificateSigningRequest(ctx context.Context, labels
},
}

ks, err := c.certClient.CertificateSigningRequests().Create(ctx, kubeCSR, metav1.CreateOptions{})
ks, err := c.kubeClientSet.CertificatesV1().CertificateSigningRequests().Create(ctx, kubeCSR, metav1.CreateOptions{})
if err != nil && !k8serrors.IsAlreadyExists(err) {
return err
}
Expand All @@ -132,7 +132,7 @@ func (c *Controller) createCertificateSigningRequest(ctx context.Context, labels
},
}

_, err = c.certClient.CertificateSigningRequests().UpdateApproval(ctx, name, ks, metav1.UpdateOptions{})
_, err = c.kubeClientSet.CertificatesV1().CertificateSigningRequests().UpdateApproval(ctx, name, ks, metav1.UpdateOptions{})
if err != nil {
return err
}
Expand Down Expand Up @@ -161,7 +161,7 @@ func (c *Controller) fetchCertificate(ctx context.Context, csrName string) ([]by
return nil, fmt.Errorf("%s", s.String())

case <-tick.C:
r, err := c.certClient.CertificateSigningRequests().Get(ctx, csrName, v1.GetOptions{})
r, err := c.kubeClientSet.CertificatesV1().CertificateSigningRequests().Get(ctx, csrName, v1.GetOptions{})
if err != nil {
klog.Errorf("Unexpected error during certificate fetching of csr/%s: %s", csrName, err)
return nil, err
Expand Down
7 changes: 4 additions & 3 deletions pkg/controller/cluster/http_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package cluster

import (
"context"
"encoding/json"
"fmt"
"log"
Expand Down Expand Up @@ -86,7 +87,7 @@ func (c *Controller) BucketSrvHandler(w http.ResponseWriter, r *http.Request) {
}

// Find the tenant
tenant, err := c.tenantsLister.Tenants(namespace).Get(name)
tenant, err := c.minioClientSet.MinioV2().Tenants(namespace).Get(r.Context(), name, metav1.GetOptions{})
if err != nil {
klog.Errorf("Unable to lookup tenant:%s/%s for the bucket:%s request. err:%s", namespace, name, bucket, err)
http.Error(w, err.Error(), http.StatusBadRequest)
Expand Down Expand Up @@ -149,7 +150,7 @@ func (c *Controller) GetenvHandler(w http.ResponseWriter, r *http.Request) {
}

// Get the Tenant resource with this namespace/name
tenant, err := c.tenantsLister.Tenants(namespace).Get(name)
tenant, err := c.minioClientSet.MinioV2().Tenants(namespace).Get(context.Background(), name, metav1.GetOptions{})
if err != nil {
if k8serrors.IsNotFound(err) {
// The Tenant resource may no longer exist, in which case we stop processing.
Expand All @@ -167,7 +168,7 @@ func (c *Controller) GetenvHandler(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), http.StatusForbidden)
return
}
// correct all statefulset names by loading them, this will fix their name on the tenant pool namess
// correct all statefulset names by loading them, this will fix their name on the tenant pool names
_, err = c.getAllSSForTenant(tenant)
if err != nil {
http.Error(w, err.Error(), http.StatusForbidden)
Expand Down
8 changes: 4 additions & 4 deletions pkg/controller/cluster/kes.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (c *Controller) checkKESCertificatesStatus(ctx context.Context, tenant *min
return err
}
// TLS secret not found, delete CSR if exists and start certificate generation process again
if err = c.certClient.CertificateSigningRequests().Delete(ctx, tenant.MinIOClientCSRName(), metav1.DeleteOptions{}); err != nil {
if err = c.kubeClientSet.CertificatesV1().CertificateSigningRequests().Delete(ctx, tenant.MinIOClientCSRName(), metav1.DeleteOptions{}); err != nil {
return err
}
}
Expand All @@ -169,7 +169,7 @@ func (c *Controller) checkKESCertificatesStatus(ctx context.Context, tenant *min
return err
}
// TLS secret not found, delete CSR if exists and start certificate generation process again
if err = c.certClient.CertificateSigningRequests().Delete(ctx, tenant.KESCSRName(), metav1.DeleteOptions{}); err != nil {
if err = c.kubeClientSet.CertificatesV1().CertificateSigningRequests().Delete(ctx, tenant.KESCSRName(), metav1.DeleteOptions{}); err != nil {
return err
}
}
Expand Down Expand Up @@ -265,7 +265,7 @@ func (c *Controller) checkKESStatus(ctx context.Context, tenant *miniov2.Tenant,
}

func (c *Controller) checkAndCreateMinIOClientCSR(ctx context.Context, nsName types.NamespacedName, tenant *miniov2.Tenant) error {
if _, err := c.certClient.CertificateSigningRequests().Get(ctx, tenant.MinIOClientCSRName(), metav1.GetOptions{}); err != nil {
if _, err := c.kubeClientSet.CertificatesV1().CertificateSigningRequests().Get(ctx, tenant.MinIOClientCSRName(), metav1.GetOptions{}); err != nil {
if k8serrors.IsNotFound(err) {
if tenant, err = c.updateTenantStatus(ctx, tenant, StatusWaitingMinIOClientCert, 0); err != nil {
return err
Expand All @@ -284,7 +284,7 @@ func (c *Controller) checkAndCreateMinIOClientCSR(ctx context.Context, nsName ty
}

func (c *Controller) checkAndCreateKESCSR(ctx context.Context, nsName types.NamespacedName, tenant *miniov2.Tenant) error {
if _, err := c.certClient.CertificateSigningRequests().Get(ctx, tenant.KESCSRName(), metav1.GetOptions{}); err != nil {
if _, err := c.kubeClientSet.CertificatesV1().CertificateSigningRequests().Get(ctx, tenant.KESCSRName(), metav1.GetOptions{}); err != nil {
if k8serrors.IsNotFound(err) {
if tenant, err = c.updateTenantStatus(ctx, tenant, StatusWaitingKESCert, 0); err != nil {
return err
Expand Down
Loading