github.com/1aal/kubeblocks@v0.0.0-20231107070852-e1c03e598921/controllers/dataprotection/types.go (about)

     1  /*
     2  Copyright (C) 2022-2023 ApeCloud Co., Ltd
     3  
     4  This file is part of KubeBlocks project
     5  
     6  This program is free software: you can redistribute it and/or modify
     7  it under the terms of the GNU Affero General Public License as published by
     8  the Free Software Foundation, either version 3 of the License, or
     9  (at your option) any later version.
    10  
    11  This program is distributed in the hope that it will be useful
    12  but WITHOUT ANY WARRANTY; without even the implied warranty of
    13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14  GNU Affero General Public License for more details.
    15  
    16  You should have received a copy of the GNU Affero General Public License
    17  along with this program.  If not, see <http://www.gnu.org/licenses/>.
    18  */
    19  
    20  package dataprotection
    21  
    22  import (
    23  	"runtime"
    24  	"time"
    25  
    26  	corev1 "k8s.io/api/core/v1"
    27  
    28  	viper "github.com/1aal/kubeblocks/pkg/viperx"
    29  )
    30  
    31  const (
    32  	trueVal = "true"
    33  )
    34  
    35  const (
    36  	// settings keys
    37  	maxConcurDataProtectionReconKey = "MAXCONCURRENTRECONCILES_DATAPROTECTION"
    38  
    39  	// label keys
    40  	dataProtectionBackupRepoKey          = "dataprotection.kubeblocks.io/backup-repo-name"
    41  	dataProtectionWaitRepoPreparationKey = "dataprotection.kubeblocks.io/wait-repo-preparation"
    42  	dataProtectionIsToolConfigKey        = "dataprotection.kubeblocks.io/is-tool-config"
    43  
    44  	// annotation keys
    45  	dataProtectionBackupRepoDigestAnnotationKey     = "dataprotection.kubeblocks.io/backup-repo-digest"
    46  	dataProtectionNeedUpdateToolConfigAnnotationKey = "dataprotection.kubeblocks.io/need-update-tool-config"
    47  )
    48  
    49  // condition constants
    50  const (
    51  	// condition types
    52  	ConditionTypeStorageProviderReady  = "StorageProviderReady"
    53  	ConditionTypeParametersChecked     = "ParametersChecked"
    54  	ConditionTypeStorageClassCreated   = "StorageClassCreated"
    55  	ConditionTypePVCTemplateChecked    = "PVCTemplateChecked"
    56  	ConditionTypeDerivedObjectsDeleted = "DerivedObjectsDeleted"
    57  	ConditionTypePreCheckPassed        = "PreCheckPassed"
    58  
    59  	// condition reasons
    60  	ReasonStorageProviderReady      = "StorageProviderReady"
    61  	ReasonStorageProviderNotReady   = "StorageProviderNotReady"
    62  	ReasonStorageProviderNotFound   = "StorageProviderNotFound"
    63  	ReasonInvalidStorageProvider    = "InvalidStorageProvider"
    64  	ReasonParametersChecked         = "ParametersChecked"
    65  	ReasonCredentialSecretNotFound  = "CredentialSecretNotFound"
    66  	ReasonPrepareCSISecretFailed    = "PrepareCSISecretFailed"
    67  	ReasonPrepareStorageClassFailed = "PrepareStorageClassFailed"
    68  	ReasonBadPVCTemplate            = "BadPVCTemplate"
    69  	ReasonStorageClassCreated       = "StorageClassCreated"
    70  	ReasonPVCTemplateChecked        = "PVCTemplateChecked"
    71  	ReasonHaveAssociatedBackups     = "HaveAssociatedBackups"
    72  	ReasonHaveResidualPVCs          = "HaveResidualPVCs"
    73  	ReasonDerivedObjectsDeleted     = "DerivedObjectsDeleted"
    74  	ReasonPreCheckPassed            = "PreCheckPassed"
    75  	ReasonPreCheckFailed            = "PreCheckFailed"
    76  	ReasonDigestChanged             = "DigestChanged"
    77  	ReasonUnknownError              = "UnknownError"
    78  	ReasonSkipped                   = "Skipped"
    79  )
    80  
    81  // constant  for volume populator
    82  const (
    83  	populatePodPrefix = "kb-populate"
    84  
    85  	// annotation keys
    86  	annSelectedNode = "volume.kubernetes.io/selected-node"
    87  	annPopulateFrom = "dataprotection.kubeblocks.io/populate-from"
    88  
    89  	// event reason
    90  	reasonStartToVolumePopulate = "StartToVolumePopulate"
    91  	reasonVolumePopulateSucceed = "VolumePopulateSucceed"
    92  	reasonVolumePopulateFailed  = "VolumePopulateFailed"
    93  
    94  	// pvc condition type and reason
    95  	reasonPopulatingFailed     = "Failed"
    96  	reasonPopulatingProcessing = "Processing"
    97  	reasonPopulatingSucceed    = "Succeed"
    98  
    99  	PersistentVolumeClaimPopulating corev1.PersistentVolumeClaimConditionType = "Populating"
   100  )
   101  
   102  var reconcileInterval = time.Second
   103  
   104  func init() {
   105  	viper.SetDefault(maxConcurDataProtectionReconKey, runtime.NumCPU()*2)
   106  }