Skip to content

Commit

Permalink
chore: classification of const variables (#7542)
Browse files Browse the repository at this point in the history
  • Loading branch information
Y-Rookie committed Jun 14, 2024
1 parent 486f561 commit 0ca2de5
Show file tree
Hide file tree
Showing 16 changed files with 388 additions and 269 deletions.
4 changes: 2 additions & 2 deletions controllers/apps/operations/volume_expansion.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ func (ve volumeExpansionOpsHandler) handleVCTExpansionProgress(reqCtx intctrluti
constant.KBAppComponentLabelKey: veHelper.fullComponentName,
}
if veHelper.templateName != "" {
matchingLabels[constant.KBAppComponentInstanceTemplatelabelKey] = veHelper.templateName
matchingLabels[constant.KBAppComponentInstanceTemplateLabelKey] = veHelper.templateName
}
pvcList := &corev1.PersistentVolumeClaimList{}
if err = cli.List(reqCtx.Ctx, pvcList, matchingLabels, client.InNamespace(opsRes.Cluster.Namespace)); err != nil {
Expand All @@ -345,7 +345,7 @@ func (ve volumeExpansionOpsHandler) handleVCTExpansionProgress(reqCtx intctrluti
if ordinal > veHelper.expectCount-1 {
continue
}
if v.Labels[constant.KBAppComponentInstanceTemplatelabelKey] != veHelper.templateName {
if v.Labels[constant.KBAppComponentInstanceTemplateLabelKey] != veHelper.templateName {
continue
}
objectKey := getPVCProgressObjectKey(v.Name)
Expand Down
43 changes: 33 additions & 10 deletions pkg/constant/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,39 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

package constant

const (
HorizontalScaleBackupPolicyTemplateKey = "apps.kubeblocks.io/horizontal-scale-backup-policy-template"
)

// annotations for kubeblocks
const (
ClusterSnapshotAnnotationKey = "kubeblocks.io/cluster-snapshot" // ClusterSnapshotAnnotationKey saves the snapshot of cluster.
OpsRequestAnnotationKey = "kubeblocks.io/ops-request" // OpsRequestAnnotationKey OpsRequest annotation key in Cluster
ReconcileAnnotationKey = "kubeblocks.io/reconcile" // ReconcileAnnotationKey Notify k8s object to reconcile
RestartAnnotationKey = "kubeblocks.io/restart" // RestartAnnotationKey the annotation which notices the StatefulSet/DeploySet to restart
RestoreFromBackupAnnotationKey = "kubeblocks.io/restore-from-backup"
RestoreDoneAnnotationKey = "kubeblocks.io/restore-done"
BackupSourceTargetAnnotationKey = "kubeblocks.io/backup-source-target" // RestoreFromBackupAnnotationKey specifies the component to recover from the backup.
SnapShotForStartAnnotationKey = "kubeblocks.io/snapshot-for-start"
ComponentReplicasAnnotationKey = "apps.kubeblocks.io/component-replicas" // ComponentReplicasAnnotationKey specifies the number of pods in replicas
BackupPolicyTemplateAnnotationKey = "apps.kubeblocks.io/backup-policy-template"
LastAppliedClusterAnnotationKey = "apps.kubeblocks.io/last-applied-cluster"
PVLastClaimPolicyAnnotationKey = "apps.kubeblocks.io/pv-last-claim-policy"
HaltRecoveryAllowInconsistentCVAnnotKey = "clusters.apps.kubeblocks.io/allow-inconsistent-cv"
HaltRecoveryAllowInconsistentResAnnotKey = "clusters.apps.kubeblocks.io/allow-inconsistent-resource"
KubeBlocksGenerationKey = "kubeblocks.io/generation"
ExtraEnvAnnotationKey = "kubeblocks.io/extra-env"
LastRoleSnapshotVersionAnnotationKey = "apps.kubeblocks.io/last-role-snapshot-version"
ComponentScaleInAnnotationKey = "apps.kubeblocks.io/component-scale-in" // ComponentScaleInAnnotationKey specifies whether the component is scaled in
DisableHAAnnotationKey = "kubeblocks.io/disable-ha"
)

// annotations for multi-cluster
const (
KBAppMultiClusterPlacementKey = "apps.kubeblocks.io/multi-cluster-placement"
MultiClusterServicePlacementKey = "apps.kubeblocks.io/multi-cluster-service-placement"
)

// GetKBGenerationAnnotation returns the annotation for kubeblocks generation.
func GetKBGenerationAnnotation(generation string) map[string]string {
return map[string]string{
Expand All @@ -40,13 +73,3 @@ func GetKBReservedAnnotationKeys() []string {
KBAppServiceVersionKey,
}
}

const (
HorizontalScaleBackupPolicyTemplateKey = "apps.kubeblocks.io/horizontal-scale-backup-policy-template"
)

// annotations for multi-cluster
const (
KBAppMultiClusterPlacementKey = "apps.kubeblocks.io/multi-cluster-placement"
MultiClusterServicePlacementKey = "apps.kubeblocks.io/multi-cluster-service-placement"
)
40 changes: 40 additions & 0 deletions pkg/constant/backup.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
Copyright (C) 2022-2024 ApeCloud Co., Ltd
This file is part of KubeBlocks project
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package constant

const (
// BackupRetain always retained, unless manually deleted by the user
BackupRetain = "Retain"

// BackupRetainUntilExpired retains backup till it expires
BackupRetainUntilExpired = "RetainUntilExpired"

// BackupDelete (default) deletes backup immediately when cluster's terminationPolicy is WipeOut
BackupDelete = "Delete"
)

const (
BackupNameKeyForRestore = "name"
BackupNamespaceKeyForRestore = "namespace"
VolumeRestorePolicyKeyForRestore = "volumeRestorePolicy"
DoReadyRestoreAfterClusterRunning = "doReadyRestoreAfterClusterRunning"
RestoreTimeKeyForRestore = "restoreTime"
ConnectionPassword = "connectionPassword"
)
58 changes: 58 additions & 0 deletions pkg/constant/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,62 @@ package constant
const (
TPLRenderToolPath = "/bin/config_render"
ConfigManagerToolPath = "/bin/reloader"

// ConfigurationTplLabelPrefixKey clusterVersion or clusterdefinition using tpl
ConfigurationTplLabelPrefixKey = "config.kubeblocks.io/tpl"
ConfigurationConstraintsLabelPrefixKey = "config.kubeblocks.io/constraints"

// CMInsLastReconfigurePhaseKey defines the current phase
CMInsLastReconfigurePhaseKey = "config.kubeblocks.io/last-applied-reconfigure-phase"

// ConfigurationRevision defines the current revision
// TODO support multi version
ConfigurationRevision = "config.kubeblocks.io/configuration-revision"
LastConfigurationRevisionPhase = "config.kubeblocks.io/revision-reconcile-phase"

// Deprecated: only compatible with version 0.6, will be removed in 0.8
// CMInsEnableRerenderTemplateKey is used to enable rerender template
CMInsEnableRerenderTemplateKey = "config.kubeblocks.io/enable-rerender"
)

const (
CMConfigurationSpecProviderLabelKey = "config.kubeblocks.io/config-spec" // CMConfigurationSpecProviderLabelKey is ComponentConfigSpec name
CMConfigurationCMKeysLabelKey = "config.kubeblocks.io/configmap-keys" // CMConfigurationCMKeysLabelKey Specify configmap keys
CMConfigurationTemplateNameLabelKey = "config.kubeblocks.io/config-template-name"
CMTemplateNameLabelKey = "config.kubeblocks.io/template-name"
CMConfigurationTypeLabelKey = "config.kubeblocks.io/config-type"
CMInsConfigurationHashLabelKey = "config.kubeblocks.io/config-hash"
CMInsCurrentConfigurationHashLabelKey = "config.kubeblocks.io/update-config-hash"
CMConfigurationConstraintsNameLabelKey = "config.kubeblocks.io/config-constraints-name"
CMConfigurationTemplateVersion = "config.kubeblocks.io/config-template-version"
)

const (
DisableUpgradeInsConfigurationAnnotationKey = "config.kubeblocks.io/disable-reconfigure"
LastAppliedConfigAnnotationKey = "config.kubeblocks.io/last-applied-configuration"
LastAppliedOpsCRAnnotationKey = "config.kubeblocks.io/last-applied-ops-name"
UpgradePolicyAnnotationKey = "config.kubeblocks.io/reconfigure-policy"
KBParameterUpdateSourceAnnotationKey = "config.kubeblocks.io/reconfigure-source"
UpgradeRestartAnnotationKey = "config.kubeblocks.io/restart"
ConfigAppliedVersionAnnotationKey = "config.kubeblocks.io/config-applied-version"
)

const (
ConfigSidecarName = "config-manager"
ConfigManagerGPRCPortEnv = "CONFIG_MANAGER_GRPC_PORT"
ConfigManagerLogLevel = "CONFIG_MANAGER_LOG_LEVEL"

PodMinReadySecondsEnv = "POD_MIN_READY_SECONDS"
ConfigTemplateType = "tpl"
ConfigInstanceType = "instance"

ReconfigureManagerSource = "manager"
ReconfigureUserSource = "ops"
ReconfigureTemplateSource = "external-template"

ConfigManagerPortName = "config-manager"
)

const (
FeatureGateIgnoreConfigTemplateDefaultMode = "IGNORE_CONFIG_TEMPLATE_DEFAULT_MODE"
)
Loading

0 comments on commit 0ca2de5

Please sign in to comment.