Skip to content

Commit

Permalink
Merge pull request #1245 from shirady/update-comments-cco
Browse files Browse the repository at this point in the history
Default Backingstore IBM COS - Change Comment and Variable Name
  • Loading branch information
shirady authored Nov 12, 2023
2 parents cc71b80 + 401e4e0 commit 2b58b1e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
6 changes: 3 additions & 3 deletions pkg/system/phase2_creating.go
Original file line number Diff line number Diff line change
Expand Up @@ -788,9 +788,9 @@ func (r *Reconciler) ReconcileIBMCredentials() error {
// Currently IBM Cloud is not supported by cloud credential operator
// In IBM Cloud, the COS Creds will be provided through Secret.
r.Logger.Info("Running in IBM Cloud")
util.KubeCheck(r.IBMCloudCOSCreds)
if r.IBMCloudCOSCreds.UID == "" {
r.Logger.Infof("%q secret is not present", r.IBMCloudCOSCreds.Name)
util.KubeCheck(r.IBMCosBucketCreds)
if r.IBMCosBucketCreds.UID == "" {
r.Logger.Infof("%q secret is not present", r.IBMCosBucketCreds.Name)
return nil
}
return nil
Expand Down
30 changes: 15 additions & 15 deletions pkg/system/phase4_configuring.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import (
const (
ibmEndpoint = "https://s3.direct.%s.cloud-object-storage.appdomain.cloud"
ibmLocation = "%s-standard"
ibmCOSCred = "ibm-cloud-cos-creds"
ibmCosBucketCred = "ibm-cloud-cos-creds"
topologyConstraintsEnabledKubeVersion = "1.26.0"
minutesToWaitForDefaultBSCreation = 10
)
Expand Down Expand Up @@ -716,8 +716,8 @@ func (r *Reconciler) ReconcileDefaultBackingStore() error {
if err := r.prepareGCPBackingStore(); err != nil {
return err
}
} else if r.IBMCloudCOSCreds.UID != "" {
log.Infof("IBM objectstore credentials %q created. Creating default backing store on IBM objectstore", r.IBMCloudCOSCreds.Name)
} else if r.IBMCosBucketCreds.UID != "" {
log.Infof("IBM objectstore credentials %q created. Creating default backing store on IBM objectstore", r.IBMCosBucketCreds.Name)
if err := r.prepareIBMBackingStore(); err != nil {
return err
}
Expand Down Expand Up @@ -771,8 +771,8 @@ func (r *Reconciler) defaultBSCreationTimedout(timestampCreation time.Time) bool

func (r *Reconciler) fallbackToPVPoolWithEvent(backingStoreType nbv1.StoreType, secretName string) error {
message := fmt.Sprintf("Failed to create default backingstore with type %s by %d minutes, "+
"fallback to create PV Pool backingstore",
backingStoreType, minutesToWaitForDefaultBSCreation)
"fallback to create %s backingstore",
backingStoreType, minutesToWaitForDefaultBSCreation, nbv1.StoreTypePVPool)
additionalInfoForLogs := fmt.Sprintf(" (could not get Secret %s).", secretName)
r.Logger.Info(message + additionalInfoForLogs)
r.Recorder.Event(r.NooBaa, corev1.EventTypeWarning, "DefaultBackingStoreFailure", message)
Expand Down Expand Up @@ -987,29 +987,29 @@ func (r *Reconciler) prepareGCPBackingStore() error {

func (r *Reconciler) prepareIBMBackingStore() error {
r.Logger.Info("Preparing backing store in IBM Cloud")
secretName := r.IBMCloudCOSCreds.Name
secretName := r.IBMCosBucketCreds.Name

var (
endpoint string
location string
)

util.KubeCheck(r.IBMCloudCOSCreds)
if r.IBMCloudCOSCreds.UID == "" {
util.KubeCheck(r.IBMCosBucketCreds)
if r.IBMCosBucketCreds.UID == "" {
r.Logger.Errorf("Cloud credentials secret %q is not ready yet", secretName)

// in case we have a cred request but we do not get a secret
if r.defaultBSCreationTimedout(r.IBMCloudCOSCreds.CreationTimestamp.Time) {
// in case it takes too long to have the secret
if r.defaultBSCreationTimedout(r.IBMCosBucketCreds.CreationTimestamp.Time) {
return r.fallbackToPVPoolWithEvent(nbv1.StoreTypeIBMCos, secretName)
}
return fmt.Errorf("Cloud credentials secret %q is not ready yet", secretName)
}

if val, ok := r.IBMCloudCOSCreds.StringData["IBM_COS_Endpoint"]; ok {
if val, ok := r.IBMCosBucketCreds.StringData["IBM_COS_Endpoint"]; ok {
// Use the endpoint provided in the secret
endpoint = val
r.Logger.Infof("Endpoint provided in secret: %q", endpoint)
if val, ok := r.IBMCloudCOSCreds.StringData["IBM_COS_Location"]; ok {
if val, ok := r.IBMCosBucketCreds.StringData["IBM_COS_Location"]; ok {
location = val
r.Logger.Infof("Location provided in secret: %q", location)
}
Expand All @@ -1035,15 +1035,15 @@ func (r *Reconciler) prepareIBMBackingStore() error {
r.Logger.Infof("IBM COS Endpoint: %s LocationConstraint: %s", endpoint, location)

var accessKeyID string
if val, ok := r.IBMCloudCOSCreds.StringData["IBM_COS_ACCESS_KEY_ID"]; ok {
if val, ok := r.IBMCosBucketCreds.StringData["IBM_COS_ACCESS_KEY_ID"]; ok {
accessKeyID = val
} else {
r.Logger.Errorf("Missing IBM_COS_ACCESS_KEY_ID in the secret")
return fmt.Errorf("Missing IBM_COS_ACCESS_KEY_ID in the secret")
}

var secretAccessKey string
if val, ok := r.IBMCloudCOSCreds.StringData["IBM_COS_SECRET_ACCESS_KEY"]; ok {
if val, ok := r.IBMCosBucketCreds.StringData["IBM_COS_SECRET_ACCESS_KEY"]; ok {
secretAccessKey = val
} else {
r.Logger.Errorf("Missing IBM_COS_SECRET_ACCESS_KEY in the secret")
Expand Down Expand Up @@ -1074,7 +1074,7 @@ func (r *Reconciler) prepareIBMBackingStore() error {
TargetBucket: bucketName,
Secret: corev1.SecretReference{
Name: secretName,
Namespace: r.IBMCloudCOSCreds.Namespace,
Namespace: r.IBMCosBucketCreds.Namespace,
},
Endpoint: endpoint,
SignatureVersion: nbv1.S3SignatureVersionV2,
Expand Down
8 changes: 4 additions & 4 deletions pkg/system/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ type Reconciler struct {
AzureContainerCreds *corev1.Secret
GCPBucketCreds *corev1.Secret
GCPCloudCreds *cloudcredsv1.CredentialsRequest
IBMCloudCOSCreds *corev1.Secret
IBMCosBucketCreds *corev1.Secret
DefaultBackingStore *nbv1.BackingStore
DefaultBucketClass *nbv1.BucketClass
OBCStorageClass *storagev1.StorageClass
Expand Down Expand Up @@ -164,7 +164,7 @@ func NewReconciler(
AWSCloudCreds: util.KubeObject(bundle.File_deploy_internal_cloud_creds_aws_cr_yaml).(*cloudcredsv1.CredentialsRequest),
AzureCloudCreds: util.KubeObject(bundle.File_deploy_internal_cloud_creds_azure_cr_yaml).(*cloudcredsv1.CredentialsRequest),
GCPCloudCreds: util.KubeObject(bundle.File_deploy_internal_cloud_creds_gcp_cr_yaml).(*cloudcredsv1.CredentialsRequest),
IBMCloudCOSCreds: util.KubeObject(bundle.File_deploy_internal_secret_empty_yaml).(*corev1.Secret),
IBMCosBucketCreds: util.KubeObject(bundle.File_deploy_internal_secret_empty_yaml).(*corev1.Secret),
DefaultBackingStore: util.KubeObject(bundle.File_deploy_crds_noobaa_io_v1alpha1_backingstore_cr_yaml).(*nbv1.BackingStore),
DefaultBucketClass: util.KubeObject(bundle.File_deploy_crds_noobaa_io_v1alpha1_bucketclass_cr_yaml).(*nbv1.BucketClass),
OBCStorageClass: util.KubeObject(bundle.File_deploy_obc_storage_class_yaml).(*storagev1.StorageClass),
Expand Down Expand Up @@ -211,7 +211,7 @@ func NewReconciler(
r.AzureCloudCreds.Spec.SecretRef.Namespace = r.Request.Namespace
r.GCPCloudCreds.Namespace = r.Request.Namespace
r.GCPCloudCreds.Spec.SecretRef.Namespace = r.Request.Namespace
r.IBMCloudCOSCreds.Namespace = r.Request.Namespace
r.IBMCosBucketCreds.Namespace = r.Request.Namespace
r.DefaultBackingStore.Namespace = r.Request.Namespace
r.DefaultBucketClass.Namespace = r.Request.Namespace
r.PrometheusRule.Namespace = r.Request.Namespace
Expand Down Expand Up @@ -255,7 +255,7 @@ func NewReconciler(
r.GCPCloudCreds.Name = r.Request.Name + "-gcp-cloud-creds"
r.GCPCloudCreds.Spec.SecretRef.Name = r.Request.Name + "-gcp-cloud-creds-secret"
r.CephObjectStoreUser.Name = r.Request.Name + "-ceph-objectstore-user"
r.IBMCloudCOSCreds.Name = ibmCOSCred
r.IBMCosBucketCreds.Name = ibmCosBucketCred
r.DefaultBackingStore.Name = r.Request.Name + "-default-backing-store"
r.DefaultBucketClass.Name = r.Request.Name + "-default-bucket-class"
r.PrometheusRule.Name = r.Request.Name + "-prometheus-rules"
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ func IsIBMPlatform() bool {
}
isIBM := strings.HasPrefix(nodesList.Items[0].Spec.ProviderID, "ibm")
if isIBM {
// Incase of Satellite cluster is deployed in user provided infrastructure
// In case of Satellite cluster is deployed in user provided infrastructure
if strings.Contains(nodesList.Items[0].Spec.ProviderID, "/sat-") {
isIBM = false
}
Expand Down

0 comments on commit 2b58b1e

Please sign in to comment.