diff --git a/deploy/olm/noobaa-operator.clusterserviceversion.yaml b/deploy/olm/noobaa-operator.clusterserviceversion.yaml index ffa444349..3fffb4825 100644 --- a/deploy/olm/noobaa-operator.clusterserviceversion.yaml +++ b/deploy/olm/noobaa-operator.clusterserviceversion.yaml @@ -60,7 +60,7 @@ spec: type: SingleNamespace - supported: false type: MultiNamespace - - supported: false + - supported: true type: AllNamespaces install: strategy: deployment diff --git a/pkg/backingstore/reconciler.go b/pkg/backingstore/reconciler.go index 98d3d4a15..19499c86f 100644 --- a/pkg/backingstore/reconciler.go +++ b/pkg/backingstore/reconciler.go @@ -1173,8 +1173,8 @@ func (r *Reconciler) needUpdate(pod *corev1.Pod) bool { configMapValue := r.CoreAppConfig.Data[name] noobaaLogEnvVar := util.GetEnvVariable(&c.Env, name) - if configMapValue != noobaaLogEnvVar.Value { - r.Logger.Warnf("%s Env variable change detected: (%v) on the config map (%v)", name, noobaaLogEnvVar.Value, configMapValue) + if (noobaaLogEnvVar == nil && configMapValue != "") || (noobaaLogEnvVar != nil && configMapValue != noobaaLogEnvVar.Value) { + r.Logger.Warnf("%s Env variable change detected: (%v) on the config map (%v)", name, noobaaLogEnvVar, configMapValue) return true } } diff --git a/pkg/bucket/bucket.go b/pkg/bucket/bucket.go index 72e13f7be..e8f3bcb8d 100644 --- a/pkg/bucket/bucket.go +++ b/pkg/bucket/bucket.go @@ -109,11 +109,14 @@ func RunCreate(cmd *cobra.Command, args []string) { log.Fatal(fmt.Errorf("CreateTieringStructure for PlacementPolicy failed to create policy %q with error: %v", tierName, err)) } - forceMd5Etag, _ := cmd.Flags().GetBool("force_md5_etag") + forceMd5EtagPtr, err := util.GetBoolFlagPtr(cmd, "force_md5_etag") + if err != nil { + log.Fatal(err) + } maxSize, _ := cmd.Flags().GetString("max-size") maxObjects, _ := cmd.Flags().GetString("max-objects") - err = nbClient.CreateBucketAPI(nb.CreateBucketParams{Name: bucketName, Tiering: tierName, ForceMd5Etag: forceMd5Etag}) + err = nbClient.CreateBucketAPI(nb.CreateBucketParams{Name: bucketName, Tiering: tierName, ForceMd5Etag: forceMd5EtagPtr}) if err != nil { log.Fatal(err) } @@ -135,17 +138,24 @@ func RunUpdate(cmd *cobra.Command, args []string) { } bucketName := args[0] nbClient := system.GetNBClient() - forceMd5Etag, _ := cmd.Flags().GetBool("force_md5_etag") + forceMd5EtagPtr, err := util.GetBoolFlagPtr(cmd, "force_md5_etag") + if err != nil { + log.Fatal(err) + } maxSize, _ := cmd.Flags().GetString("max-size") maxObjects, _ := cmd.Flags().GetString("max-objects") + updateParams := nb.CreateBucketParams{ + Name: bucketName, + ForceMd5Etag: forceMd5EtagPtr, + } + quota, updateQuota := prepareQuotaConfig(maxSize, maxObjects) - var err error if updateQuota { - err = nbClient.UpdateBucketAPI(nb.CreateBucketParams{Name: bucketName, ForceMd5Etag: forceMd5Etag, Quota: "a}) - } else { - err = nbClient.UpdateBucketAPI(nb.CreateBucketParams{Name: bucketName, ForceMd5Etag: forceMd5Etag}) + updateParams.Quota = "a } + + err = nbClient.UpdateBucketAPI(updateParams) if err != nil { log.Fatal(err) } @@ -187,7 +197,9 @@ func RunStatus(cmd *cobra.Command, args []string) { } fmt.Printf(" %-22s : %s\n", "Type", b.BucketType) fmt.Printf(" %-22s : %s\n", "Mode", b.Mode) - fmt.Printf(" %-22s : %t\n", "Force Md5 Etag", b.ForceMd5Etag) + if b.ForceMd5Etag != nil { + fmt.Printf(" %-22s : %t\n", "Force Md5 Etag", *b.ForceMd5Etag) + } if b.PolicyModes != nil { fmt.Printf(" %-22s : %s\n", "ResiliencyStatus", b.PolicyModes.ResiliencyStatus) fmt.Printf(" %-22s : %s\n", "QuotaStatus", b.PolicyModes.QuotaStatus) diff --git a/pkg/bundle/deploy.go b/pkg/bundle/deploy.go index b6a51b4de..17787b827 100644 --- a/pkg/bundle/deploy.go +++ b/pkg/bundle/deploy.go @@ -5907,7 +5907,7 @@ s3 ls s3://first.bucket ` + "`" + `` + "`" + `` + "`" + ` ` -const Sha256_deploy_olm_noobaa_operator_clusterserviceversion_yaml = "900ed615837a7f63510de5bff4bd8ffdcc02bea8cec0cf231d21e32812f78ed7" +const Sha256_deploy_olm_noobaa_operator_clusterserviceversion_yaml = "3b11ab7cce6a4dfc36ad13f75b37821c8e200aec4cf21007208948e74ce9cc44" const File_deploy_olm_noobaa_operator_clusterserviceversion_yaml = `apiVersion: operators.coreos.com/v1alpha1 kind: ClusterServiceVersion @@ -5971,7 +5971,7 @@ spec: type: SingleNamespace - supported: false type: MultiNamespace - - supported: false + - supported: true type: AllNamespaces install: strategy: deployment diff --git a/pkg/nb/types.go b/pkg/nb/types.go index 74528501a..991ea28c6 100644 --- a/pkg/nb/types.go +++ b/pkg/nb/types.go @@ -70,7 +70,7 @@ type BucketInfo struct { BucketType string `json:"bucket_type"` Mode string `json:"mode"` Undeletable string `json:"undeletable"` - ForceMd5Etag bool `json:"force_md5_etag"` + ForceMd5Etag *bool `json:"force_md5_etag,omitempty"` BucketClaim *BucketClaimInfo `json:"bucket_claim,omitempty"` Tiering *TieringPolicyInfo `json:"tiering,omitempty"` @@ -340,7 +340,7 @@ type CreateSystemReply struct { type CreateBucketParams struct { Name string `json:"name"` Tiering string `json:"tiering,omitempty"` - ForceMd5Etag bool `json:"force_md5_etag,omitempty"` + ForceMd5Etag *bool `json:"force_md5_etag,omitempty"` BucketClaim *BucketClaimInfo `json:"bucket_claim,omitempty"` Namespace *NamespaceBucketInfo `json:"namespace,omitempty"` Quota *QuotaConfig `json:"quota,omitempty"` @@ -411,7 +411,7 @@ type CreateAccountParams struct { S3Access bool `json:"s3_access"` AllowBucketCreate bool `json:"allow_bucket_creation"` DefaultResource string `json:"default_resource,omitempty"` - ForceMd5Etag bool `json:"force_md5_etag,omitempty"` + ForceMd5Etag *bool `json:"force_md5_etag,omitempty"` BucketClaimOwner string `json:"bucket_claim_owner,omitempty"` NsfsAccountConfig *nbv1.AccountNsfsConfig `json:"nsfs_account_config,omitempty"` } diff --git a/pkg/noobaaaccount/noobaaaccount.go b/pkg/noobaaaccount/noobaaaccount.go index 5f632c206..97ce88b85 100644 --- a/pkg/noobaaaccount/noobaaaccount.go +++ b/pkg/noobaaaccount/noobaaaccount.go @@ -182,7 +182,10 @@ func RunCreate(cmd *cobra.Command, args []string) { defaultResource, _ := cmd.Flags().GetString("default_resource") nsfsAccountConfig, _ := cmd.Flags().GetBool("nsfs_account_config") - forceMd5Etag, _ := cmd.Flags().GetBool("force_md5_etag") + forceMd5EtagPtr, err := util.GetBoolFlagPtr(cmd, "force_md5_etag") + if err != nil { + log.Fatal(err) + } newBucketsPath, _ := cmd.Flags().GetString("new_buckets_path") nsfsOnly, _ := cmd.Flags().GetBool("nsfs_only") @@ -198,7 +201,7 @@ func RunCreate(cmd *cobra.Command, args []string) { noobaaAccount.Name = name noobaaAccount.Namespace = options.Namespace noobaaAccount.Spec.AllowBucketCreate = allowBucketCreate - noobaaAccount.Spec.ForceMd5Etag = &forceMd5Etag + noobaaAccount.Spec.ForceMd5Etag = forceMd5EtagPtr if nsfsAccountConfig { nsfsUID := util.GetFlagIntOrPrompt(cmd, "uid") @@ -240,7 +243,7 @@ func RunCreate(cmd *cobra.Command, args []string) { noobaaAccount.Spec.DefaultResource = defaultResource - err := util.KubeClient().Get(util.Context(), util.ObjectKey(noobaaAccount), noobaaAccount) + err = util.KubeClient().Get(util.Context(), util.ObjectKey(noobaaAccount), noobaaAccount) if err == nil { log.Fatalf(`❌ noobaaAccount %q already exists in namespace %q`, noobaaAccount.Name, noobaaAccount.Namespace) } @@ -272,10 +275,9 @@ func RunUpdate(cmd *cobra.Command, args []string) { name := args[0] newDefaultResource := util.GetFlagStringOrPrompt(cmd, "new_default_resource") - var forceMd5EtagPtr *bool = nil - if cmd.Flags().Changed("force_md5_etag") { - forceMd5Etag, _ := cmd.Flags().GetBool("force_md5_etag") - forceMd5EtagPtr = &forceMd5Etag + forceMd5EtagPtr, err := util.GetBoolFlagPtr(cmd, "force_md5_etag") + if err != nil { + log.Fatal(err) } o := util.KubeObject(bundle.File_deploy_crds_noobaa_io_v1alpha1_noobaaaccount_cr_yaml) diff --git a/pkg/noobaaaccount/reconciler.go b/pkg/noobaaaccount/reconciler.go index eda3abc76..932e1daf5 100644 --- a/pkg/noobaaaccount/reconciler.go +++ b/pkg/noobaaaccount/reconciler.go @@ -338,7 +338,7 @@ func (r *Reconciler) CreateNooBaaAccount() error { DefaultResource: r.NooBaaAccount.Spec.DefaultResource, HasLogin: false, S3Access: true, - ForceMd5Etag: *r.NooBaaAccount.Spec.ForceMd5Etag, + ForceMd5Etag: r.NooBaaAccount.Spec.ForceMd5Etag, AllowBucketCreate: r.NooBaaAccount.Spec.AllowBucketCreate, } diff --git a/pkg/system/phase2_creating.go b/pkg/system/phase2_creating.go index 2c770d61e..b94f0626c 100644 --- a/pkg/system/phase2_creating.go +++ b/pkg/system/phase2_creating.go @@ -361,7 +361,7 @@ func (r *Reconciler) setDesiredCoreEnv(c *corev1.Container) { case "POSTGRES_HOST": if r.NooBaa.Spec.ExternalPgSecret == nil { - c.Env[j].Value = r.NooBaaPostgresDB.Name + "-0." + r.NooBaaPostgresDB.Spec.ServiceName + c.Env[j].Value = r.NooBaaPostgresDB.Name + "-0." + r.NooBaaPostgresDB.Spec.ServiceName + "." + r.NooBaaPostgresDB.Namespace + ".svc" } case "DB_TYPE": diff --git a/pkg/util/util.go b/pkg/util/util.go index d023dee07..9db144f85 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -1238,6 +1238,19 @@ func GetFlagStringOrPromptPassword(cmd *cobra.Command, flag string) string { return str } +// GetBoolFlagPtr returns a pointer to the boolean flag value if set, or nil if not set +func GetBoolFlagPtr(cmd *cobra.Command, flag string) (*bool, error) { + if cmd.Flags().Changed(flag) { + flagVal, err := cmd.Flags().GetBool(flag) + if err != nil { + return nil, err + } + return &flagVal, nil + } + + return nil, nil +} + // PrintThisNoteWhenFinishedApplyingAndStartWaitLoop is a common log task func PrintThisNoteWhenFinishedApplyingAndStartWaitLoop() { log := Logger()