in pkg/ndbconfig/config_summary.go [121:191]
func (cs *ConfigSummary) MySQLClusterConfigNeedsUpdate(nc *v1.NdbCluster) (needsUpdate bool) {
newNdbdConfig := nc.Spec.DataNode.Config
// Operator sets some default config parameters - take them into account when comparing configs.
totalNdbdConfig := len(newNdbdConfig) + numOfOperatorSetConfigs
// Add a count for EncryptedFileSystem if TDE is enabled
if cs.TDEPasswordSecretName != "" {
totalNdbdConfig = totalNdbdConfig + 1
}
// Check if the default ndbd section has been updated
if totalNdbdConfig != len(cs.defaultNdbdSection) {
// A config has been added (or) removed from default ndbd section
return true
}
// Check if all configs exist and their value has not changed
// TODO: Compare with actual values from the DataNodes
for configKey, configValue := range newNdbdConfig {
if value, exists := cs.defaultNdbdSection.GetValue(configKey); !exists || value != configValue.String() {
// Either the config doesn't exist or the value has been changed
return true
}
}
// Check if the data nodes are being added
if cs.NumOfDataNodes < nc.Spec.DataNode.NodeCount {
return true
}
// Check if there is a change in the number of MySQL server
// slots or number of free api slots.
if cs.NumOfMySQLServerSlots != GetNumOfSectionsRequiredForMySQLServers(nc) {
return true
}
// Check if there is a change in the TDE password
if cs.TDEPasswordSecretName != GetTDESecretName(nc) {
// If the field is unset in new or old config. Then the EncryptedFileSystem config parameter
// needs to be added/deleted from the config.ini
if cs.TDEPasswordSecretName == "" || GetTDESecretName(nc) == "" {
return true
}
}
// Check if more freeAPISlots slots are being declared by the new spec.
// Note that the config will have an extra API slot dedicated for use by the NDB Operator
if cs.NumOfFreeApiSlots != nc.Spec.FreeAPISlots+1 {
// Number of free slots have been changed. Regenerate config and apply it.
return true
}
// Check if the default mgmd section has been updated
if nc.Spec.ManagementNode != nil {
newMgmdConfig := nc.Spec.ManagementNode.Config
if len(newMgmdConfig) != len(cs.defaultMgmdSection) {
// A config has been added (or) removed from default mgmd section
return true
}
// Check if all configs exist and their value has not changed
for configKey, configValue := range newMgmdConfig {
if value, exists := cs.defaultMgmdSection.GetValue(configKey); !exists || value != configValue.String() {
// Either the config doesn't exist or the value has been changed
return true
}
}
}
// No update required to the MySQL Cluster config.
return false
}