diff --git a/install/Docker/dockerfiles/Dockerfile.redis b/install/Docker/dockerfiles/Dockerfile.redis index 3c12d143c..2962655c4 100644 --- a/install/Docker/dockerfiles/Dockerfile.redis +++ b/install/Docker/dockerfiles/Dockerfile.redis @@ -25,16 +25,16 @@ RUN if [ -z "$ODIMRA_USER_ID" ] || [ -z "$ODIMRA_GROUP_ID" ]; then \ RUN apt-get -y update RUN apt-get -y install openssl bash sed -RUN mkdir /redis-master /redis-slave +RUN mkdir /redis-primary /redis-secondary -COPY --chown=odimra:odimra install/Docker/dockerfiles/scripts/redis-master.conf /redis-master/redis.conf -COPY --chown=odimra:odimra install/Docker/dockerfiles/scripts/redis-slave.conf /redis-slave/redis.conf +COPY --chown=odimra:odimra install/Docker/dockerfiles/scripts/redis-primary.conf /redis-primary/redis.conf +COPY --chown=odimra:odimra install/Docker/dockerfiles/scripts/redis-secondary.conf /redis-secondary/redis.conf COPY --chown=odimra:odimra install/Docker/dockerfiles/scripts/redis-createschema.sh /createschema.sh COPY --chown=odimra:odimra install/Docker/dockerfiles/scripts/redis-checkdb.sh /checkdb.sh COPY --chown=odimra:odimra install/Docker/dockerfiles/scripts/redis-entrypointsetup.sh /entrypointsetup.sh -RUN chmod 0700 /entrypointsetup.sh /redis-master /redis-slave -RUN chown -R odimra:odimra /data /redis-master /redis-slave +RUN chmod 0700 /entrypointsetup.sh /redis-primary /redis-secondary +RUN chown -R odimra:odimra /data /redis-primary /redis-secondary USER odimra:odimra diff --git a/install/Docker/dockerfiles/scripts/redis-checkdb.sh b/install/Docker/dockerfiles/scripts/redis-checkdb.sh index c9d5c0a1f..c5f476a62 100755 --- a/install/Docker/dockerfiles/scripts/redis-checkdb.sh +++ b/install/Docker/dockerfiles/scripts/redis-checkdb.sh @@ -18,6 +18,6 @@ sleep 3 echo "Checking if default entries already present" redis_password=$(openssl pkeyutl -decrypt -in cipher -inkey ${ODIMRA_RSA_PRIVATE_FILE} -pkeyopt rsa_padding_mode:oaep -pkeyopt rsa_oaep_md:sha512) -redis-cli -a ${redis_password} -h ${master} -p ${REDIS_HA_REDIS_SERVICE_PORT} --tls --cert ${TLS_CERT_FILE} --key ${TLS_KEY_FILE} --cacert ${TLS_CA_CERT_FILE} < /dev/null` if [ $? -eq 0 ]; then echo "Updating the db with default entries" redis_password=$(openssl pkeyutl -decrypt -in cipher -inkey ${ODIMRA_RSA_PRIVATE_FILE} -pkeyopt rsa_padding_mode:oaep -pkeyopt rsa_oaep_md:sha512) - redis-cli -a ${redis_password} -h ${master} -p ${REDIS_HA_REDIS_SERVICE_PORT} --tls --cert ${TLS_CERT_FILE} --key ${TLS_KEY_FILE} --cacert ${TLS_CA_CERT_FILE} < insert_master_ip_and_default_entries.sh - bash insert_master_ip_and_default_entries.sh & - sed -i "s/REDIS_DEFAULT_PASSWORD/${redis_password}/" /redis-master/redis.conf - + echo "while true; do sleep 2; export primary=\$(hostname -I | cut -d ' ' -f 1); echo \"Primary IP is Me : \${primary}\"; echo \"Setting STARTUP_PRIMARY_IP in redis\"; redis-cli -a '${redis_password}' -h \${primary} --tls --cert ${TLS_CERT_FILE} --key ${TLS_KEY_FILE} --cacert ${TLS_CA_CERT_FILE} set STARTUP_PRIMARY_IP \${primary}; if [ \$? == \"0\" ]; then echo \"Successfully set STARTUP_PRIMARY_IP\"; if [ \${REDIS_ONDISK_DB} == \"true\" ]; then bash \/createschema.sh; fi; break; fi; echo \"Connecting to primary \${primary} failed. Waiting...\"; sleep 5; done" > insert_primary_ip_and_default_entries.sh + bash insert_primary_ip_and_default_entries.sh & + sed -i "s/REDIS_DEFAULT_PASSWORD/${redis_password}/" /redis-primary/redis.conf hostname=$(hostname -f) - sed -i "s/%replica-announce-ip%/${hostname}/" /redis-master/redis.conf - sed -i "s/%master-port%/${REDIS_HA_REDIS_SERVICE_PORT}/" /redis-master/redis.conf + sed -i "s/%replica-announce-ip%/${hostname}/" /redis-primary/redis.conf + sed -i "s/%primary-port%/${REDIS_HA_REDIS_SERVICE_PORT}/" /redis-primary/redis.conf - redis-server /redis-master/redis.conf --protected-mode no + redis-server /redis-primary/redis.conf --protected-mode no } # This method launches sentinels @@ -50,10 +49,10 @@ function launchsentinel() { x=1 while [ $x -le 5 ] do - master=$(redis-cli -a ${redis_password} -h ${REDIS_HA_SENTINEL_SERVICE_HOST} -p ${REDIS_HA_SENTINEL_SERVICE_PORT} --tls --cert ${TLS_CERT_FILE} --key ${TLS_KEY_FILE} --cacert ${TLS_CA_CERT_FILE} --csv SENTINEL get-master-addr-by-name ${REDIS_MASTER_SET} | tr ',' ' ' | cut -d' ' -f1) - if [[ -n ${master} ]]; then - echo "Connected to Sentinel Service and retrieved Redis Master hostname as ${master}" - master="${master//\"}" + primary=$(redis-cli -a ${redis_password} -h ${REDIS_HA_SENTINEL_SERVICE_HOST} -p ${REDIS_HA_SENTINEL_SERVICE_PORT} --tls --cert ${TLS_CERT_FILE} --key ${TLS_KEY_FILE} --cacert ${TLS_CA_CERT_FILE} --csv SENTINEL get-primary-addr-by-name ${REDIS_PRIMARY_SET} | tr ',' ' ' | cut -d' ' -f1) + if [[ -n ${primary} ]]; then + echo "Connected to Sentinel Service and retrieved Redis Primary hostname as ${primary}" + primary="${primary//\"}" break else echo "Unable to connect to sentinel, retrying..." @@ -62,17 +61,17 @@ function launchsentinel() { x=$(( $x + 1 )) done - if ! [[ -n ${master} ]]; then - echo "Unable to connect to Sentinel Service, probably because I am first Sentinel to start. I will use default master hostname ${MASTER_HOST_NAME} to connect to sentinel" - master=${MASTER_HOST_NAME} + if ! [[ -n ${primary} ]]; then + echo "Unable to connect to Sentinel Service, probably because I am first Sentinel to start. I will use default primary hostname ${PRIMARY_HOST_NAME} to connect to sentinel" + primary=${PRIMARY_HOST_NAME} fi while true; do - redis-cli -a ${redis_password} -h ${master} --tls --cert ${TLS_CERT_FILE} --key ${TLS_KEY_FILE} --cacert ${TLS_CA_CERT_FILE} INFO + redis-cli -a ${redis_password} -h ${primary} --tls --cert ${TLS_CERT_FILE} --key ${TLS_KEY_FILE} --cacert ${TLS_CA_CERT_FILE} INFO if [[ "$?" == "0" ]]; then break fi - echo "Connecting to master failed. Waiting..." + echo "Connecting to primary failed. Waiting..." sleep 10 done @@ -84,12 +83,12 @@ function launchsentinel() { echo "sentinel announce-hostnames yes" >> ${sentinel_conf} echo "sentinel announce-ip ${hostname}" >> ${sentinel_conf} echo "sentinel announce-port ${REDIS_HA_SENTINEL_SERVICE_PORT}" >> ${sentinel_conf} - echo "sentinel monitor ${REDIS_MASTER_SET} ${master} ${REDIS_HA_REDIS_SERVICE_PORT} ${SENTINEL_QUORUM}" >> ${sentinel_conf} - echo "sentinel auth-pass ${REDIS_MASTER_SET} ${redis_password}" >> ${sentinel_conf} + echo "sentinel monitor ${REDIS_PRIMARY_SET} ${primary} ${REDIS_HA_REDIS_SERVICE_PORT} ${SENTINEL_QUORUM}" >> ${sentinel_conf} + echo "sentinel auth-pass ${REDIS_PRIMARY_SET} ${redis_password}" >> ${sentinel_conf} echo "requirepass ${redis_password}" >> ${sentinel_conf} - echo "sentinel down-after-milliseconds ${REDIS_MASTER_SET} ${DOWN_AFTER_MILLISECONDS}" >> ${sentinel_conf} - echo "sentinel failover-timeout ${REDIS_MASTER_SET} ${FAILOVER_TIMEOUT}" >> ${sentinel_conf} - echo "sentinel parallel-syncs ${REDIS_MASTER_SET} ${PARALLEL_SYNCS}" >> ${sentinel_conf} + echo "sentinel down-after-milliseconds ${REDIS_PRIMARY_SET} ${DOWN_AFTER_MILLISECONDS}" >> ${sentinel_conf} + echo "sentinel failover-timeout ${REDIS_PRIMARY_SET} ${FAILOVER_TIMEOUT}" >> ${sentinel_conf} + echo "sentinel parallel-syncs ${REDIS_PRIMARY_SET} ${PARALLEL_SYNCS}" >> ${sentinel_conf} echo "bind 0.0.0.0" >> ${sentinel_conf} echo "port 0" >> ${sentinel_conf} echo "tls-port 26379" >> ${sentinel_conf} @@ -102,42 +101,42 @@ function launchsentinel() { redis-sentinel ${sentinel_conf} --protected-mode no } -# This method launches slave instances -function launchslave() { - echo "Starting Redis instance as Slave , Master IP $1" +# This method launches secondry instances +function launchsecondry() { + echo "Starting Redis instance as Secondry , Primary IP $1" redis_password=$(openssl pkeyutl -decrypt -in cipher -inkey ${ODIMRA_RSA_PRIVATE_FILE} -pkeyopt rsa_padding_mode:oaep -pkeyopt rsa_oaep_md:sha512) while true; do - echo "Trying to retrieve the Master IP again, in case of failover master ip would have changed." - master=$(redis-cli -a ${redis_password} -h ${REDIS_HA_SENTINEL_SERVICE_HOST} -p ${REDIS_HA_SENTINEL_SERVICE_PORT} --tls --cert ${TLS_CERT_FILE} --key ${TLS_KEY_FILE} --cacert ${TLS_CA_CERT_FILE} --csv SENTINEL get-master-addr-by-name ${REDIS_MASTER_SET} | tr ',' ' ' | cut -d' ' -f1) + echo "Trying to retrieve the Primary IP again, in case of failover primary ip would have changed." + Primary=$(redis-cli -a ${redis_password} -h ${REDIS_HA_SENTINEL_SERVICE_HOST} -p ${REDIS_HA_SENTINEL_SERVICE_PORT} --tls --cert ${TLS_CERT_FILE} --key ${TLS_KEY_FILE} --cacert ${TLS_CA_CERT_FILE} --csv SENTINEL get-primary-addr-by-name ${REDIS_PRIMARY_SET} | tr ',' ' ' | cut -d' ' -f1) - if [[ -n ${master} ]]; then - master="${master//\"}" + if [[ -n ${primary} ]]; then + primary="${primary//\"}" else - echo "Failed to find master." + echo "Failed to find primary." sleep 60 continue fi - redis-cli -a ${redis_password} -h ${master} --tls --cert ${TLS_CERT_FILE} --key ${TLS_KEY_FILE} --cacert ${TLS_CA_CERT_FILE} INFO + redis-cli -a ${redis_password} -h ${primary} --tls --cert ${TLS_CERT_FILE} --key ${TLS_KEY_FILE} --cacert ${TLS_CA_CERT_FILE} INFO if [[ "$?" == "0" ]]; then break fi - echo "Connecting to master failed. Waiting..." + echo "Connecting to primary failed. Waiting..." sleep 10 done hostname=$(hostname -f) - sed -i "s/%master-ip%/${master}/" /redis-slave/redis.conf - sed -i "s/%master-port%/${REDIS_HA_REDIS_SERVICE_PORT}/" /redis-slave/redis.conf - sed -i "s/REDIS_DEFAULT_PASSWORD/${redis_password}/" /redis-slave/redis.conf - sed -i "s/%replica-announce-ip%/${hostname}/" /redis-slave/redis.conf - sed -i "s/%replicaof%/${master}/" /redis-slave/redis.conf + sed -i "s/%primary-ip%/${primary}/" /redis-secondry/redis.conf + sed -i "s/%primary-port%/${REDIS_HA_REDIS_SERVICE_PORT}/" /redis-secondry/redis.conf + sed -i "s/REDIS_DEFAULT_PASSWORD/${redis_password}/" /redis-secondry/redis.conf + sed -i "s/%replica-announce-ip%/${hostname}/" /redis-secondry/redis.conf + sed -i "s/%replicaof%/${primary}/" /redis-secondry/redis.conf - redis-server /redis-slave/redis.conf --protected-mode no + redis-server /redis-secondry/redis.conf --protected-mode no } -# This method launches either slave or master based on some parameters +# This method launches either secondry or primary based on some parameters function launchredis() { echo "Launching Redis instance" @@ -149,35 +148,35 @@ function launchredis() { sentinel_down_time=10 sleep ${sentinel_down_time} - # Loop till I am able to launch slave or master + # Loop till I am able to launch secondry or primary while true; do # I will check if sentinel is up or not by connecting to it. - echo "Trying to connect to sentinel, to retireve master's ip" - master=$(redis-cli -a ${redis_password} -h ${REDIS_HA_SENTINEL_SERVICE_HOST} -p ${REDIS_HA_SENTINEL_SERVICE_PORT} --tls --cert ${TLS_CERT_FILE} --key ${TLS_KEY_FILE} --cacert ${TLS_CA_CERT_FILE} --csv SENTINEL get-master-addr-by-name ${REDIS_MASTER_SET} | tr ',' ' ' | cut -d' ' -f1) - # Is this instance marked as MASTER, it will matter only when the cluster is starting up for first time. - if [[ "${MASTER}" == "true" ]]; then - echo "MASTER is set to true" - # If I am able get master ip, then i will connect to the master, else i will asume the role of master - if [[ -n ${master} ]]; then - echo "Connected to Sentinel, this means it is not first time start, hence will start as a slave" + echo "Trying to connect to sentinel, to retireve primary's ip" + primary=$(redis-cli -a ${redis_password} -h ${REDIS_HA_SENTINEL_SERVICE_HOST} -p ${REDIS_HA_SENTINEL_SERVICE_PORT} --tls --cert ${TLS_CERT_FILE} --key ${TLS_KEY_FILE} --cacert ${TLS_CA_CERT_FILE} --csv SENTINEL get-primary-addr-by-name ${REDIS_PRIMARY_SET} | tr ',' ' ' | cut -d' ' -f1) + # Is this instance marked as PRIMARY, it will matter only when the cluster is starting up for first time. + if [[ "${PRIMARY}" == "true" ]]; then + echo "PRIMARY is set to true" + # If I am able get primary ip, then i will connect to the primary, else i will asume the role of primary + if [[ -n ${primary} ]]; then + echo "Connected to Sentinel, this means it is not first time start, hence will start as a secondry" currenthost=$(hostname -f | cut -d ' ' -f 1) - master=`echo $master |tr -d '"'` - if [[ "${currenthost}" == "${master}" ]]; then - launchmaster + primary=`echo $primary |tr -d '"'` + if [[ "${currenthost}" == "${primary}" ]]; then + launchprimary exit 0 fi - launchslave ${master} + launchsecondry ${primary} exit 0 else - launchmaster + launchprimary exit 0 fi fi - # If I am not master, then i am definitely slave. - if [[ -n ${master} ]]; then - echo "Connected to Sentinel and Retrieved Master IP ${master}" - launchslave ${master} + # If I am not primary, then i am definitely secondry. + if [[ -n ${primary} ]]; then + echo "Connected to Sentinel and Retrieved Primary IP ${primary}" + launchsecondry ${primary} exit 0 else echo "Connecting to sentinel failed, Waiting..." diff --git a/install/Docker/dockerfiles/scripts/redis-master.conf b/install/Docker/dockerfiles/scripts/redis-primary.conf similarity index 99% rename from install/Docker/dockerfiles/scripts/redis-master.conf rename to install/Docker/dockerfiles/scripts/redis-primary.conf index 2bd35aefe..8624eb659 100644 --- a/install/Docker/dockerfiles/scripts/redis-master.conf +++ b/install/Docker/dockerfiles/scripts/redis-primary.conf @@ -893,5 +893,5 @@ tls-cluster yes # and ROLE will report those values. # replica-announce-ip %replica-announce-ip% -replica-announce-port %master-port% +replica-announce-port %primary-port% # diff --git a/install/Docker/dockerfiles/scripts/redis-slave.conf b/install/Docker/dockerfiles/scripts/redis-secondary.conf similarity index 99% rename from install/Docker/dockerfiles/scripts/redis-slave.conf rename to install/Docker/dockerfiles/scripts/redis-secondary.conf index 6426d83ca..4978b889d 100644 --- a/install/Docker/dockerfiles/scripts/redis-slave.conf +++ b/install/Docker/dockerfiles/scripts/redis-secondary.conf @@ -217,7 +217,7 @@ dir /redis-data # network partition slaves automatically try to reconnect to masters # and resynchronize with them. # -slaveof %master-ip% %master-port% +slaveof %primary-ip% %primary-port% # If the master is password protected (using the "requirepass" configuration # directive below) it is possible to tell the slave to authenticate before @@ -893,7 +893,7 @@ tls-cluster yes # and ROLE will report those values. # replica-announce-ip %replica-announce-ip% -replica-announce-port %master-port% +replica-announce-port %primary-port% # Master-Replica replication. Use replicaof to make a Redis instance a copy of # another Redis server. A few things to understand ASAP about Redis replication. # @@ -913,5 +913,5 @@ replica-announce-port %master-port% # network partition replicas automatically try to reconnect to masters # and resynchronize with them. # -replicaof %replicaof% %master-port% +replicaof %replicaof% %primary-port% # \ No newline at end of file diff --git a/lib-persistence-manager/persistencemgr/config.go b/lib-persistence-manager/persistencemgr/config.go index 60758961b..2e616a60f 100644 --- a/lib-persistence-manager/persistencemgr/config.go +++ b/lib-persistence-manager/persistencemgr/config.go @@ -33,7 +33,7 @@ type Config struct { Host string SentinelHost string SentinelPort string - MasterSet string + PrimarySet string Password string } @@ -41,6 +41,6 @@ type Config struct { type ConnPool struct { ReadPool *redis.Client WritePool *redis.Client - MasterIP string + PrimaryIP string Mux sync.Mutex } diff --git a/lib-persistence-manager/persistencemgr/redis.go b/lib-persistence-manager/persistencemgr/redis.go index ae611657f..6643b3d6f 100644 --- a/lib-persistence-manager/persistencemgr/redis.go +++ b/lib-persistence-manager/persistencemgr/redis.go @@ -76,7 +76,7 @@ type Conn struct { // RedisExternalCalls containes the methods to make calls to external client libraries of Redis DB type RedisExternalCalls interface { newSentinelClient(opt *redis.Options) *redis.SentinelClient - getMasterAddrByName(mset string, snlClient *redis.SentinelClient) []string + getPrimaryAddrByName(mset string, snlClient *redis.SentinelClient) []string } type redisExtCallsImp struct{} @@ -85,8 +85,8 @@ func (r redisExtCallsImp) newSentinelClient(opt *redis.Options) *redis.SentinelC return redis.NewSentinelClient(opt) } -func (r redisExtCallsImp) getMasterAddrByName(masterSet string, snlClient *redis.SentinelClient) []string { - return snlClient.GetMasterAddrByName(masterSet).Val() +func (r redisExtCallsImp) getPrimaryAddrByName(primarySet string, snlClient *redis.SentinelClient) []string { + return snlClient.GetMasterAddrByName(primarySet).Val() } // NewRedisExternalCalls is Constructor for RedisExternalCalls @@ -118,24 +118,24 @@ var ( goroutineCreated uint32 ) -// GetCurrentMasterHostPort is to get the current Redis Master IP and Port from Sentinel. -func GetCurrentMasterHostPort(dbConfig *Config) (string, string, error) { +// GetCurrentPrimaryHostPort is to get the current Redis Primary IP and Port from Sentinel. +func GetCurrentPrimaryHostPort(dbConfig *Config) (string, string, error) { sentinelClient, err := sentinelNewClient(dbConfig) if err != nil { return "", "", err } - stringSlice := redisExtCalls.getMasterAddrByName(dbConfig.MasterSet, sentinelClient) - var masterIP string - var masterPort string + stringSlice := redisExtCalls.getPrimaryAddrByName(dbConfig.PrimarySet, sentinelClient) + var primaryIP string + var primaryPort string if len(stringSlice) == 2 { - masterIP = stringSlice[0] - masterPort = stringSlice[1] + primaryIP = stringSlice[0] + primaryPort = stringSlice[1] } if atomic.CompareAndSwapUint32(&goroutineCreated, 0, 1) { go monitorFailureOver(sentinelClient) } - return masterIP, masterPort, nil + return primaryIP, primaryPort, nil } // monitorFailureOver will monitor the failover and reset the connection @@ -198,28 +198,28 @@ func resetDBWriteConnection(dbFlag DbType) error { } func (p *ConnPool) setWritePool(c *Config) error { - currentMasterIP := c.Host - currentMasterPort := c.Port + currentPrimaryIP := c.Host + currentPrimaryPort := c.Port if config.Data.DBConf.RedisHAEnabled { - currentMasterIP, currentMasterPort = retryForMasterIP(p, c) + currentPrimaryIP, currentPrimaryPort = retryForPrimaryIP(p, c) } - if currentMasterIP == "" { - return fmt.Errorf("unable to retrieve master ip from sentinel master election") + if currentPrimaryIP == "" { + return fmt.Errorf("unable to retrieve primary ip from sentinel primary election") } - writePool, _ := goRedisNewClient(c, currentMasterIP, currentMasterPort) + writePool, _ := goRedisNewClient(c, currentPrimaryIP, currentPrimaryPort) if writePool == nil { return fmt.Errorf("write pool creation failed") } p.WritePool = writePool - p.MasterIP = currentMasterIP + p.PrimaryIP = currentPrimaryIP return nil } -func retryForMasterIP(pool *ConnPool, config *Config) (currentMasterIP, currentMasterPort string) { +func retryForPrimaryIP(pool *ConnPool, config *Config) (currentPrimaryIP, currentPrimaryPort string) { for i := 0; i < 120; i++ { - currentMasterIP, currentMasterPort, _ = GetCurrentMasterHostPort(config) - if currentMasterIP != "" { + currentPrimaryIP, currentPrimaryPort, _ = GetCurrentPrimaryHostPort(config) + if currentPrimaryIP != "" { break } time.Sleep(1 * time.Second) @@ -234,7 +234,7 @@ func getInMemoryDBConfig() *Config { Host: config.Data.DBConf.InMemoryHost, SentinelHost: config.Data.DBConf.InMemorySentinelHost, SentinelPort: config.Data.DBConf.InMemorySentinelPort, - MasterSet: config.Data.DBConf.InMemoryPrimarySet, + PrimarySet: config.Data.DBConf.InMemoryPrimarySet, Password: string(config.Data.DBConf.RedisInMemoryPassword), } } @@ -246,7 +246,7 @@ func getOnDiskDBConfig() *Config { Host: config.Data.DBConf.OnDiskHost, SentinelHost: config.Data.DBConf.OnDiskSentinelHost, SentinelPort: config.Data.DBConf.OnDiskSentinelPort, - MasterSet: config.Data.DBConf.OnDiskPrimarySet, + PrimarySet: config.Data.DBConf.OnDiskPrimarySet, Password: string(config.Data.DBConf.RedisOnDiskPassword), } } @@ -358,12 +358,12 @@ func getTLSConfig() (*tls.Config, error) { // Connection does not take any input and returns a connection object used to interact with the DB func (c *Config) Connection() (*ConnPool, *errors.Error) { var err error - var masterIP, masterPort string + var primaryIP, primaryPort string connPools := &ConnPool{} - masterIP = c.Host - masterPort = c.Port + primaryIP = c.Host + primaryPort = c.Port if config.Data.DBConf.RedisHAEnabled { - masterIP, masterPort, err = GetCurrentMasterHostPort(c) + primaryIP, primaryPort, err = GetCurrentPrimaryHostPort(c) if err != nil { return nil, errors.PackError(errors.UndefinedErrorType, err.Error()) } @@ -372,11 +372,11 @@ func (c *Config) Connection() (*ConnPool, *errors.Error) { if err != nil { return nil, errors.PackError(errors.DBConnFailed, err.Error()) } - connPools.WritePool, err = goRedisNewClient(c, masterIP, masterPort) + connPools.WritePool, err = goRedisNewClient(c, primaryIP, primaryPort) if err != nil { return nil, errors.PackError(errors.DBConnFailed, err.Error()) } - connPools.MasterIP = masterIP + connPools.PrimaryIP = primaryIP return connPools, nil } diff --git a/lib-persistence-manager/persistencemgr/redis_test.go b/lib-persistence-manager/persistencemgr/redis_test.go index a5bacc640..f863ce1c1 100644 --- a/lib-persistence-manager/persistencemgr/redis_test.go +++ b/lib-persistence-manager/persistencemgr/redis_test.go @@ -1101,18 +1101,18 @@ func newSentinelClientMock(opt *redis.Options) *redis.SentinelClient { } return nil } -func (r redisExtCallsImpMock) getMasterAddrByName(masterSet string, snlClient *redis.SentinelClient) []string { - return getMasterAddbyNameMock(masterSet, snlClient) +func (r redisExtCallsImpMock) getPrimaryAddrByName(primarySet string, snlClient *redis.SentinelClient) []string { + return getPrimaryAddbyNameMock(primarySet, snlClient) } -func getMasterAddbyNameMock(masterSet string, snlClient *redis.SentinelClient) []string { - if masterSet == "ValidMasterSet" && snlClient != nil { - return []string{"ValidMasterIP", "ValidMasterPort"} +func getPrimaryAddbyNameMock(primarySet string, snlClient *redis.SentinelClient) []string { + if primarySet == "ValidPrimarySet" && snlClient != nil { + return []string{"ValidPrimaryIP", "ValidPrimaryPort"} } return []string{"", ""} } -func TestGetCurrentMasterHostPort(t *testing.T) { +func TestGetCurrentPrimaryHostPort(t *testing.T) { redisExtCalls = redisExtCallsImpMock{} type args struct { dbConfig *Config @@ -1129,11 +1129,11 @@ func TestGetCurrentMasterHostPort(t *testing.T) { dbConfig: &Config{ Host: "ValidHost", SentinelPort: "ValidSentinelPort", - MasterSet: "ValidMasterSet", + PrimarySet: "ValidPrimarySet", }, }, - want: "ValidMasterIP", - want1: "ValidMasterPort", + want: "ValidPrimaryIP", + want1: "ValidPrimaryPort", }, { name: "Negative Case: Invalid sentinel Host", @@ -1141,7 +1141,7 @@ func TestGetCurrentMasterHostPort(t *testing.T) { dbConfig: &Config{ Host: "InvalidHost", SentinelPort: "ValidSentinelPort", - MasterSet: "ValidMasterSet", + PrimarySet: "ValidPrimarySet", }, }, want: "", @@ -1153,19 +1153,19 @@ func TestGetCurrentMasterHostPort(t *testing.T) { dbConfig: &Config{ Host: "ValidHost", SentinelPort: "InvalidSentinelPort", - MasterSet: "ValidMasterSet", + PrimarySet: "ValidPrimarySet", }, }, want: "", want1: "", }, { - name: "Negative Case: Invalid MasterSet", + name: "Negative Case: Invalid PrimarySet", args: args{ dbConfig: &Config{ Host: "ValidHost", SentinelPort: "ValidSentinelPort", - MasterSet: "InvalidMasterSet", + PrimarySet: "InvalidPrimarySet", }, }, want: "", @@ -1177,19 +1177,19 @@ func TestGetCurrentMasterHostPort(t *testing.T) { dbConfig: &Config{ Host: "", SentinelPort: "ValidSentinelPort", - MasterSet: "ValidMasterSet", + PrimarySet: "ValidPrimarySet", }, }, want: "", want1: "", }, { - name: "Negative Case: empty MasterSet", + name: "Negative Case: empty PrimarySet", args: args{ dbConfig: &Config{ Host: "ValidHost", SentinelPort: "ValidSentinelPort", - MasterSet: "", + PrimarySet: "", }, }, want: "", @@ -1198,12 +1198,12 @@ func TestGetCurrentMasterHostPort(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - got, got1, _ := GetCurrentMasterHostPort(tt.args.dbConfig) + got, got1, _ := GetCurrentPrimaryHostPort(tt.args.dbConfig) if got != tt.want { - t.Errorf("GetCurrentMasterHostPort() got = %v, want %v", got, tt.want) + t.Errorf("GetCurrentPrimaryHostPort() got = %v, want %v", got, tt.want) } if got1 != tt.want1 { - t.Errorf("GetCurrentMasterHostPort() got1 = %v, want %v", got1, tt.want1) + t.Errorf("GetCurrentPrimaryHostPort() got1 = %v, want %v", got1, tt.want1) } }) } @@ -1268,12 +1268,12 @@ func TestGetDBConnectionHAEnabled(t *testing.T) { config.Data.DBConf.RedisHAEnabled = true inMemDBConnPool = &ConnPool{ - ReadPool: &redis.Client{}, - MasterIP: "NotValid", + ReadPool: &redis.Client{}, + PrimaryIP: "NotValid", } onDiskDBConnPool = &ConnPool{ - ReadPool: &redis.Client{}, - MasterIP: "NotValid", + ReadPool: &redis.Client{}, + PrimaryIP: "NotValid", } redisExtCalls = redisExtCallsImpMock{} type args struct { diff --git a/odim-controller/helmcharts/redis-ha/templates/redis-ha-inmemory-primary-statefulset.yaml b/odim-controller/helmcharts/redis-ha/templates/redis-ha-inmemory-primary-statefulset.yaml index e540adafb..d43a69a6f 100644 --- a/odim-controller/helmcharts/redis-ha/templates/redis-ha-inmemory-primary-statefulset.yaml +++ b/odim-controller/helmcharts/redis-ha/templates/redis-ha-inmemory-primary-statefulset.yaml @@ -94,9 +94,9 @@ spec: mountPath: /etc/odimra_certs env: - - name: MASTER + - name: PRIMARY value: "true" - - name: MASTER_HOST_NAME + - name: PRIMARY_HOST_NAME value: "redis-ha-inmemory-primary-0.redis-ha-inmemory-headless.odim.svc.cluster.local" - name: REDIS_ONDISK_DB value: "false" @@ -118,5 +118,5 @@ spec: value: "26379" - name: REDIS_HA_SENTINEL_SERVICE_HOST value: "redis-ha-inmemory-sentinel.{{ .Values.odimra.namespace }}.svc.cluster.local" - - name: REDIS_MASTER_SET - value: {{ .Values.odimra.redisMasterSet | quote }} \ No newline at end of file + - name: REDIS_PRIMARY_SET + value: {{ .Values.odimra.redisPrimarySet | quote }} \ No newline at end of file diff --git a/odim-controller/helmcharts/redis-ha/templates/redis-ha-inmemory-secondary-statefulset.yaml b/odim-controller/helmcharts/redis-ha/templates/redis-ha-inmemory-secondary-statefulset.yaml index 09872e51a..844f41578 100644 --- a/odim-controller/helmcharts/redis-ha/templates/redis-ha-inmemory-secondary-statefulset.yaml +++ b/odim-controller/helmcharts/redis-ha/templates/redis-ha-inmemory-secondary-statefulset.yaml @@ -94,9 +94,9 @@ spec: mountPath: /etc/odimra_certs env: - - name: MASTER + - name: PRIMARY value: "false" - - name: MASTER_HOST_NAME + - name: PRIMARY_HOST_NAME value: "redis-ha-inmemory-primary-0.redis-ha-inmemory-headless.odim.svc.cluster.local" - name: REDIS_ONDISK_DB value: "false" @@ -118,5 +118,5 @@ spec: value: "26379" - name: REDIS_HA_SENTINEL_SERVICE_HOST value: "redis-ha-inmemory-sentinel.{{ .Values.odimra.namespace }}.svc.cluster.local" - - name: REDIS_MASTER_SET - value: {{ .Values.odimra.redisMasterSet | quote }} + - name: REDIS_PRIMARY_SET + value: {{ .Values.odimra.redisPrimarySet | quote }} diff --git a/odim-controller/helmcharts/redis-ha/templates/redis-ha-inmemory-sentinel-primary-statefulset.yaml b/odim-controller/helmcharts/redis-ha/templates/redis-ha-inmemory-sentinel-primary-statefulset.yaml index 971b95756..89265467d 100644 --- a/odim-controller/helmcharts/redis-ha/templates/redis-ha-inmemory-sentinel-primary-statefulset.yaml +++ b/odim-controller/helmcharts/redis-ha/templates/redis-ha-inmemory-sentinel-primary-statefulset.yaml @@ -93,7 +93,7 @@ spec: env: - name: SENTINEL value: "true" - - name: MASTER_HOST_NAME + - name: PRIMARY_HOST_NAME value: "redis-ha-inmemory-primary-0.redis-ha-inmemory-headless.odim.svc.cluster.local" - name: TLS_CERT_FILE value: "/etc/odimra_certs/odimra_server.crt" @@ -113,8 +113,8 @@ spec: value: "26379" - name: REDIS_HA_SENTINEL_SERVICE_HOST value: "redis-ha-inmemory-sentinel.{{ .Values.odimra.namespace }}.svc.cluster.local" - - name: REDIS_MASTER_SET - value: {{ .Values.odimra.redisMasterSet | quote }} + - name: REDIS_PRIMARY_SET + value: {{ .Values.odimra.redisPrimarySet | quote }} - name: DOWN_AFTER_MILLISECONDS value: {{ .Values.odimra.redisDownAfterMilliseconds | quote }} - name: FAILOVER_TIMEOUT diff --git a/odim-controller/helmcharts/redis-ha/templates/redis-ha-inmemory-sentinel-secondary-statefulset.yaml b/odim-controller/helmcharts/redis-ha/templates/redis-ha-inmemory-sentinel-secondary-statefulset.yaml index ee33a4597..6225134de 100644 --- a/odim-controller/helmcharts/redis-ha/templates/redis-ha-inmemory-sentinel-secondary-statefulset.yaml +++ b/odim-controller/helmcharts/redis-ha/templates/redis-ha-inmemory-sentinel-secondary-statefulset.yaml @@ -93,7 +93,7 @@ spec: env: - name: SENTINEL value: "true" - - name: MASTER_HOST_NAME + - name: PRIMARY_HOST_NAME value: "redis-ha-inmemory-primary-0.redis-ha-inmemory-headless.odim.svc.cluster.local" - name: TLS_CERT_FILE value: "/etc/odimra_certs/odimra_server.crt" @@ -113,8 +113,8 @@ spec: value: "26379" - name: REDIS_HA_SENTINEL_SERVICE_HOST value: "redis-ha-inmemory-sentinel.{{ .Values.odimra.namespace }}.svc.cluster.local" - - name: REDIS_MASTER_SET - value: {{ .Values.odimra.redisMasterSet | quote }} + - name: REDIS_PRIMARY_SET + value: {{ .Values.odimra.redisPrimarySet | quote }} - name: DOWN_AFTER_MILLISECONDS value: {{ .Values.odimra.redisDownAfterMilliseconds | quote }} - name: FAILOVER_TIMEOUT diff --git a/odim-controller/helmcharts/redis-ha/templates/redis-ha-ondisk-primary-statefulset.yaml b/odim-controller/helmcharts/redis-ha/templates/redis-ha-ondisk-primary-statefulset.yaml index bb6923fc3..219a39fa8 100644 --- a/odim-controller/helmcharts/redis-ha/templates/redis-ha-ondisk-primary-statefulset.yaml +++ b/odim-controller/helmcharts/redis-ha/templates/redis-ha-ondisk-primary-statefulset.yaml @@ -98,9 +98,9 @@ spec: mountPath: /etc/odimra_certs env: - - name: MASTER + - name: PRIMARY value: "true" - - name: MASTER_HOST_NAME + - name: PRIMARY_HOST_NAME value: "redis-ha-ondisk-primary-0.redis-ha-ondisk-headless.odim.svc.cluster.local" - name: REDIS_ONDISK_DB value: "true" @@ -122,5 +122,5 @@ spec: value: "26379" - name: REDIS_HA_SENTINEL_SERVICE_HOST value: "redis-ha-ondisk-sentinel.{{ .Values.odimra.namespace }}.svc.cluster.local" - - name: REDIS_MASTER_SET - value: {{ .Values.odimra.redisMasterSet | quote }} + - name: REDIS_PRIMARY_SET + value: {{ .Values.odimra.redisPrimarySet | quote }} diff --git a/odim-controller/helmcharts/redis-ha/templates/redis-ha-ondisk-secondary-statefulset.yaml b/odim-controller/helmcharts/redis-ha/templates/redis-ha-ondisk-secondary-statefulset.yaml index d540be1ca..47bec8bb3 100644 --- a/odim-controller/helmcharts/redis-ha/templates/redis-ha-ondisk-secondary-statefulset.yaml +++ b/odim-controller/helmcharts/redis-ha/templates/redis-ha-ondisk-secondary-statefulset.yaml @@ -98,9 +98,9 @@ spec: mountPath: /etc/odimra_certs env: - - name: MASTER + - name: PRIMARY value: "false" - - name: MASTER_HOST_NAME + - name: PRIMARY_HOST_NAME value: "redis-ha-ondisk-primary-0.redis-ha-ondisk-headless.odim.svc.cluster.local" - name: REDIS_ONDISK_DB value: "true" @@ -122,5 +122,5 @@ spec: value: "26379" - name: REDIS_HA_SENTINEL_SERVICE_HOST value: "redis-ha-ondisk-sentinel.{{ .Values.odimra.namespace }}.svc.cluster.local" - - name: REDIS_MASTER_SET - value: {{ .Values.odimra.redisMasterSet | quote }} + - name: REDIS_PRIMARY_SET + value: {{ .Values.odimra.redisPrimarySet | quote }} diff --git a/odim-controller/helmcharts/redis-ha/templates/redis-ha-ondisk-sentinel-primary-statefulset.yaml b/odim-controller/helmcharts/redis-ha/templates/redis-ha-ondisk-sentinel-primary-statefulset.yaml index 4fc7b51e6..344da03ff 100644 --- a/odim-controller/helmcharts/redis-ha/templates/redis-ha-ondisk-sentinel-primary-statefulset.yaml +++ b/odim-controller/helmcharts/redis-ha/templates/redis-ha-ondisk-sentinel-primary-statefulset.yaml @@ -96,7 +96,7 @@ spec: env: - name: SENTINEL value: "true" - - name: MASTER_HOST_NAME + - name: PRIMARY_HOST_NAME value: "redis-ha-ondisk-primary-0.redis-ha-ondisk-headless.odim.svc.cluster.local" - name: TLS_CERT_FILE value: "/etc/odimra_certs/odimra_server.crt" @@ -116,8 +116,8 @@ spec: value: "26379" - name: REDIS_HA_SENTINEL_SERVICE_HOST value: "redis-ha-ondisk-sentinel.{{ .Values.odimra.namespace }}.svc.cluster.local" - - name: REDIS_MASTER_SET - value: {{ .Values.odimra.redisMasterSet | quote }} + - name: REDIS_PRIMARY_SET + value: {{ .Values.odimra.redisPrimarySet | quote }} - name: DOWN_AFTER_MILLISECONDS value: {{ .Values.odimra.redisDownAfterMilliseconds | quote }} - name: FAILOVER_TIMEOUT diff --git a/odim-controller/helmcharts/redis-ha/templates/redis-ha-ondisk-sentinel-secondary-statefulset.yaml b/odim-controller/helmcharts/redis-ha/templates/redis-ha-ondisk-sentinel-secondary-statefulset.yaml index 71039a7cf..dfbee95ab 100644 --- a/odim-controller/helmcharts/redis-ha/templates/redis-ha-ondisk-sentinel-secondary-statefulset.yaml +++ b/odim-controller/helmcharts/redis-ha/templates/redis-ha-ondisk-sentinel-secondary-statefulset.yaml @@ -97,7 +97,7 @@ spec: env: - name: SENTINEL value: "true" - - name: MASTER_HOST_NAME + - name: PRIMARY_HOST_NAME value: "redis-ha-ondisk-primary-0.redis-ha-ondisk-headless.odim.svc.cluster.local" - name: TLS_CERT_FILE value: "/etc/odimra_certs/odimra_server.crt" @@ -119,8 +119,8 @@ spec: value: "26379" - name: REDIS_HA_SENTINEL_SERVICE_HOST value: "redis-ha-ondisk-sentinel.{{ .Values.odimra.namespace }}.svc.cluster.local" - - name: REDIS_MASTER_SET - value: {{ .Values.odimra.redisMasterSet | quote }} + - name: REDIS_PRIMARY_SET + value: {{ .Values.odimra.redisPrimarySet | quote }} - name: DOWN_AFTER_MILLISECONDS value: {{ .Values.odimra.redisDownAfterMilliseconds | quote }} - name: FAILOVER_TIMEOUT diff --git a/odim-controller/helmcharts/redis-ha/values.yaml b/odim-controller/helmcharts/redis-ha/values.yaml index bb4a99b38..2765e0b44 100644 --- a/odim-controller/helmcharts/redis-ha/values.yaml +++ b/odim-controller/helmcharts/redis-ha/values.yaml @@ -5,7 +5,7 @@ odimra: redisOndiskDataPath: redisInmemoryDataPath: redisSecondayReplicaCount: 2 - redisMasterSet: primaryset + redisPrimarySet: primaryset redisQuorum: 2 redisDownAfterMilliseconds: 1000 redisFailoverTimeout: 3000 diff --git a/odim-controller/helmcharts/redis/templates/redis-ondisk-statefulset.yaml b/odim-controller/helmcharts/redis/templates/redis-ondisk-statefulset.yaml index bd80bf65c..4fd659610 100644 --- a/odim-controller/helmcharts/redis/templates/redis-ondisk-statefulset.yaml +++ b/odim-controller/helmcharts/redis/templates/redis-ondisk-statefulset.yaml @@ -71,7 +71,7 @@ spec: - name: odimra-secret mountPath: /etc/odimra_certs env: - - name: MASTER + - name: PRIMARY value: "true" - name: REDIS_ONDISK_DB value: "true" diff --git a/odim-controller/helmcharts/urplugin/urplugin/templates/configmaps.yaml b/odim-controller/helmcharts/urplugin/urplugin/templates/configmaps.yaml index 91e49da3f..ce488e705 100644 --- a/odim-controller/helmcharts/urplugin/urplugin/templates/configmaps.yaml +++ b/odim-controller/helmcharts/urplugin/urplugin/templates/configmaps.yaml @@ -27,7 +27,7 @@ data: {{ else }} # RedisAddress here is a SentinelAddress used when HA deployment is enabled RedisAddress: redis-ha-ondisk-sentinel.{{ .Values.odimra.namespace }}.svc.cluster.local:26379 - SentinelMasterName: {{ .Values.urplugin.sentinelMasterName }} + SentinelPrimaryName: {{ .Values.urplugin.sentinelPrimaryName }} {{ end }} TLSConf: MinVersion: 0x0303 diff --git a/odim-controller/helmcharts/urplugin/urplugin/values.yaml b/odim-controller/helmcharts/urplugin/urplugin/values.yaml index 705b69705..1c3fc2f4c 100644 --- a/odim-controller/helmcharts/urplugin/urplugin/values.yaml +++ b/odim-controller/helmcharts/urplugin/urplugin/values.yaml @@ -10,6 +10,6 @@ urplugin: host: urplugin odimUsername: odimPassword: - sentinelMasterName: primaryset + sentinelPrimaryName: primaryset logPath: logsOnConsole: true diff --git a/odim-controller/odimra/roles/configure-keepalived/templates/action_script.sh.j2 b/odim-controller/odimra/roles/configure-keepalived/templates/action_script.sh.j2 index 429ccfe10..c41a076b2 100644 --- a/odim-controller/odimra/roles/configure-keepalived/templates/action_script.sh.j2 +++ b/odim-controller/odimra/roles/configure-keepalived/templates/action_script.sh.j2 @@ -18,7 +18,7 @@ declare TYPE ## name of the instance or group declare NAME -## transitioned to state, "MASTER", "BACKUP" or "FAULT" +## transitioned to state, "PRIMARY", "BACKUP" or "FAULT" declare STATE ## priority of the instance as set in conf file declare PRIO @@ -82,7 +82,7 @@ PRIO=$4 echo "[$(date)] -- INFO -- Notification recieved with TYPE=${TYPE} NAME=${NAME} STATE=${STATE} PRIORITY=${PRIO}" case "${STATE}" in - MASTER) + PRIMARY) start_nginx ;; BACKUP|FAULT) diff --git a/odim-controller/odimra/roles/configure-keepalived/templates/keepalived.conf.j2 b/odim-controller/odimra/roles/configure-keepalived/templates/keepalived.conf.j2 index 69969ae20..501e5243f 100644 --- a/odim-controller/odimra/roles/configure-keepalived/templates/keepalived.conf.j2 +++ b/odim-controller/odimra/roles/configure-keepalived/templates/keepalived.conf.j2 @@ -7,7 +7,7 @@ global_defs { } vrrp_instance ODIM_VI { - state MASTER + state PRIMARY interface {{ item.interfaceName }} virtual_router_id {{ item.virtualRouterID }} priority {{ item.priority }} diff --git a/odim-controller/scripts/odim-controller.py b/odim-controller/scripts/odim-controller.py index 3a16ccd65..22a29d183 100755 --- a/odim-controller/scripts/odim-controller.py +++ b/odim-controller/scripts/odim-controller.py @@ -90,8 +90,8 @@ def write_node_details(): temp_dict = {node : {'ansible_host': attrs['ip'], 'ip':attrs['ip'], 'access_ip':attrs['ip']}} node_details['all']['hosts'].update(temp_dict) temp_dict = {node: None} - if attrs["isMaster"]: - logger.debug("%s(%s) is marked as master node", node, attrs['ip']) + if attrs["isPrimary"]: + logger.debug("%s(%s) is marked as primary node", node, attrs['ip']) node_details['all']['children']['kube_control_plane']['hosts'].update(temp_dict) node_details['all']['children']['kube_node']['hosts'].update(temp_dict) node_details['all']['children']['etcd']['hosts'].update(temp_dict) @@ -408,7 +408,7 @@ def helper_msg(): def check_time_sync(): logger.info("Checking if time on all nodes provided are in sync") host_time_map = {} - # fetch date and time from any one of the master node, if not new deployment + # fetch date and time from any one of the primary node, if not new deployment if K8S_INVENTORY_DATA != None: for node, attrs in K8S_INVENTORY_DATA['all']['hosts'].items(): cmd = '/usr/bin/ssh {username}@{ipaddr} date'.format(username=os.getenv('USER'), ipaddr=attrs['ip']) @@ -478,7 +478,7 @@ def scale_in_k8s(): nodes_list = "" for node, attrs in CONTROLLER_CONF_DATA['nodes'].items(): if node in K8S_INVENTORY_DATA['all']['children']['kube_control_plane']['hosts']: - logger.warn("%s is master node, removing of which is not allowed, skipping!!!", node) + logger.warn("%s is primary node, removing of which is not allowed, skipping!!!", node) continue if node in K8S_INVENTORY_DATA['all']['hosts'].keys(): no_nodes_to_remove = False @@ -994,12 +994,12 @@ def operation_odimra(operation): shutil.copyfile(CONTROLLER_CONF_FILE, odimra_config_file) # as rollback of failed operation is not handled yet - # will try on first master node and exit on failure - master_node = list(K8S_INVENTORY_DATA['all']['children']['kube_control_plane']['hosts'].keys())[0] - logger.info("Starting odimra %s on master node %s", operation, master_node) + # will try on first primary node and exit on failure + primary_node = list(K8S_INVENTORY_DATA['all']['children']['kube_control_plane']['hosts'].keys())[0] + logger.info("Starting odimra %s on primary node %s", operation, primary_node) odimra_deploy_cmd = 'ansible-playbook -i {host_conf_file} --become --become-user=root \ - --extra-vars "host={master_node} helm_config_file={helm_config_file} ignore_err={ignore_err}" \ -{operation_conf_file}.yaml'.format(host_conf_file=host_file, master_node=master_node, helm_config_file=CONTROLLER_CONF_FILE, \ + --extra-vars "host={primary_node} helm_config_file={helm_config_file} ignore_err={ignore_err}" \ +{operation_conf_file}.yaml'.format(host_conf_file=host_file, primary_node=primary_node, helm_config_file=CONTROLLER_CONF_FILE, \ operation_conf_file=operation,ignore_err=IGNORE_ERRORS_SET) ret = exec(odimra_deploy_cmd, {'ANSIBLE_BECOME_PASS': ANSIBLE_BECOME_PASS}) @@ -1008,7 +1008,7 @@ def operation_odimra(operation): os.remove(odimra_config_file) if ret != 0: - logger.critical("ODIMRA %s failed on master node %s", operation, master_node) + logger.critical("ODIMRA %s failed on primary node %s", operation, primary_node) os.chdir(cur_dir) exit(1) @@ -1472,27 +1472,27 @@ def update_helm_charts(config_map_name): logger.info("ODIMRA %s success copy docker image %s", operationName, dockerImageName) - for master_node in K8S_INVENTORY_DATA['all']['children']['kube_control_plane']['hosts'].items(): - logger.info("Starting upgrade of %s on master node %s", fullHelmChartName, master_node[0]) + for primary_node in K8S_INVENTORY_DATA['all']['children']['kube_control_plane']['hosts'].items(): + logger.info("Starting upgrade of %s on primary node %s", fullHelmChartName, primary_node[0]) odimra_upgrade_cmd = 'ansible-playbook -i {host_conf_file} --become --become-user=root \ - --extra-vars "host={master_node} helm_chart_name={helm_chart_name} helm_chart_name_version={helm_chart_name_version} helm_config_file={helm_config_file} ignore_err={ignore_err}" {operation_conf_file}.yaml'.format( \ - host_conf_file=host_file, master_node=master_node[0], \ + --extra-vars "host={primary_node} helm_chart_name={helm_chart_name} helm_chart_name_version={helm_chart_name_version} helm_config_file={helm_config_file} ignore_err={ignore_err}" {operation_conf_file}.yaml'.format( \ + host_conf_file=host_file, primary_node=primary_node[0], \ helm_chart_name=config_map_name, \ helm_chart_name_version=fullHelmChartName, \ helm_config_file=CONTROLLER_CONF_FILE, \ operation_conf_file=operationName,ignore_err=IGNORE_ERRORS_SET) ret = exec(odimra_upgrade_cmd, {'ANSIBLE_BECOME_PASS': ANSIBLE_BECOME_PASS}) if ret != 0: - logger.critical("ODIMRA %s failed when tried on master node %s", operationName, master_node[0]) + logger.critical("ODIMRA %s failed when tried on primary node %s", operationName, primary_node[0]) else: - logger.info("ODIMRA %s success on master node %s", operationName, master_node[0]) + logger.info("ODIMRA %s success on primary node %s", operationName, primary_node[0]) upgrade_flag=True break if upgrade_flag: logger.info("Completed ODIMRA %s operation", operationName) else: - logger.info("Could not %s ODIMRA on any master nodes", operationName) + logger.info("Could not %s ODIMRA on any primary nodes", operationName) os.chdir(cur_dir) exit(1) @@ -1515,8 +1515,8 @@ def list_deployments(): load_k8s_host_conf() list_flag = False - for master_node in K8S_INVENTORY_DATA['all']['children']['kube_control_plane']['hosts'].items(): - ip = K8S_INVENTORY_DATA['all']['hosts'][master_node[0]]['ip'] + for primary_node in K8S_INVENTORY_DATA['all']['children']['kube_control_plane']['hosts'].items(): + ip = K8S_INVENTORY_DATA['all']['hosts'][primary_node[0]]['ip'] list_deps_cmd = '/usr/bin/ssh {ip} helm list -n {namespace}'.format( \ namespace=CONTROLLER_CONF_DATA['odimra']['namespace'], ip=ip) ret = exec(list_deps_cmd, {'ANSIBLE_BECOME_PASS': ANSIBLE_BECOME_PASS}) @@ -1544,8 +1544,8 @@ def list_deployment_history(depName): load_k8s_host_conf() list_flag = False - for master_node in K8S_INVENTORY_DATA['all']['children']['kube_control_plane']['hosts'].items(): - ip = K8S_INVENTORY_DATA['all']['hosts'][master_node[0]]['ip'] + for primary_node in K8S_INVENTORY_DATA['all']['children']['kube_control_plane']['hosts'].items(): + ip = K8S_INVENTORY_DATA['all']['hosts'][primary_node[0]]['ip'] list_history_cmd = '/usr/bin/ssh {ip} helm history {deployment} -n {namespace}'.format( \ ip=ip, deployment=depName, \ namespace=CONTROLLER_CONF_DATA['odimra']['namespace']) @@ -1578,15 +1578,15 @@ def rollback_deployment(depName, revision): rollback_flag = False host_file = os.path.join(KUBESPRAY_SRC_PATH, DEPLOYMENT_SRC_DIR, 'hosts.yaml') - for master_node in K8S_INVENTORY_DATA['all']['children']['kube_control_plane']['hosts'].items(): - logger.info("Starting rollback of %s deployment on master node %s", depName, master_node[0]) + for primary_node in K8S_INVENTORY_DATA['all']['children']['kube_control_plane']['hosts'].items(): + logger.info("Starting rollback of %s deployment on primary node %s", depName, primary_node[0]) rollback_dep_cmd = 'ansible-playbook -i {host_conf_file} --become --become-user=root \ - --extra-vars "host={master_node} release={depName} revision={revision}" rollback.yaml'.format( \ - host_conf_file=host_file, master_node=master_node[0], \ + --extra-vars "host={primary_node} release={depName} revision={revision}" rollback.yaml'.format( \ + host_conf_file=host_file, primary_node=primary_node[0], \ depName=depName, revision=revision) ret = exec(rollback_dep_cmd, {'ANSIBLE_BECOME_PASS': ANSIBLE_BECOME_PASS}) if ret != 0: - logger.critical("rollback of %s deployment failed on master node %s", depName, master_node[0]) + logger.critical("rollback of %s deployment failed on primary node %s", depName, primary_node[0]) else: rollback_flag=True break @@ -1626,16 +1626,16 @@ def scale_plugin(plugin_name, replica_count): exit(1) host_file = os.path.join(KUBESPRAY_SRC_PATH, DEPLOYMENT_SRC_DIR, 'hosts.yaml') - for master_node in K8S_INVENTORY_DATA['all']['children']['kube_control_plane']['hosts'].items(): - logger.info("Starting scaling of %s plugin on master node %s", plugin_name, master_node[0]) + for primary_node in K8S_INVENTORY_DATA['all']['children']['kube_control_plane']['hosts'].items(): + logger.info("Starting scaling of %s plugin on primary node %s", plugin_name, primary_node[0]) scale_plugin_cmd = 'ansible-playbook -i {host_conf_file} --become --become-user=root \ - --extra-vars "host={master_node} helm_chart_name={helm_chart_name} helm_config_file={helm_config_file} replicas={replicas}" scale_plugin.yaml'.format( \ - host_conf_file=host_file, master_node=master_node[0], \ + --extra-vars "host={primary_node} helm_chart_name={helm_chart_name} helm_config_file={helm_config_file} replicas={replicas}" scale_plugin.yaml'.format( \ + host_conf_file=host_file, primary_node=primary_node[0], \ helm_chart_name=plugin_name, helm_config_file=CONTROLLER_CONF_FILE, \ replicas=replica_count) ret = exec(scale_plugin_cmd, {'ANSIBLE_BECOME_PASS': ANSIBLE_BECOME_PASS}) if ret != 0: - logger.critical("scaling %s plugin failed on master node %s", plugin_name, master_node[0]) + logger.critical("scaling %s plugin failed on primary node %s", plugin_name, primary_node[0]) else: scaling_flag=True break @@ -1687,11 +1687,11 @@ def scale_svc_helm_chart(svc_uservice_name,replica_count,helmchartData): if not DRY_RUN_SET: load_password_from_vault(cur_dir) scale_flag = False - for master_node in K8S_INVENTORY_DATA['all']['children']['kube_control_plane']['hosts'].items(): - logger.info("Starting scaling of %s on master node %s", fullHelmChartName, master_node[0]) + for primary_node in K8S_INVENTORY_DATA['all']['children']['kube_control_plane']['hosts'].items(): + logger.info("Starting scaling of %s on primary node %s", fullHelmChartName, primary_node[0]) odimra_upgrade_cmd = 'ansible-playbook -i {host_conf_file} --become --become-user=root \ - --extra-vars "host={master_node} helm_chart_name={helm_chart_name} helm_chart_name_version={helm_chart_name_version} helm_config_file={helm_config_file} replicas={replicas} ignore_err={ignore_err}" {operation_conf_file}.yaml'.format( \ - host_conf_file=host_file, master_node=master_node[0], \ + --extra-vars "host={primary_node} helm_chart_name={helm_chart_name} helm_chart_name_version={helm_chart_name_version} helm_config_file={helm_config_file} replicas={replicas} ignore_err={ignore_err}" {operation_conf_file}.yaml'.format( \ + host_conf_file=host_file, primary_node=primary_node[0], \ helm_chart_name=svc_uservice_name, \ helm_chart_name_version=fullHelmChartName, \ helm_config_file=CONTROLLER_CONF_FILE, \ @@ -1699,16 +1699,16 @@ def scale_svc_helm_chart(svc_uservice_name,replica_count,helmchartData): operation_conf_file=operationName,ignore_err=IGNORE_ERRORS_SET) ret = exec(odimra_upgrade_cmd, {'ANSIBLE_BECOME_PASS': ANSIBLE_BECOME_PASS}) if ret != 0: - logger.critical("ODIMRA %s failed when tried on master node %s", operationName, master_node[0]) + logger.critical("ODIMRA %s failed when tried on primary node %s", operationName, primary_node[0]) else: - logger.info("ODIMRA %s success on master node %s", operationName, master_node[0]) + logger.info("ODIMRA %s success on primary node %s", operationName, primary_node[0]) scale_flag=True break if scale_flag: logger.info("Completed ODIMRA %s operation", operationName) else: - logger.info("Could not %s ODIMRA on any master nodes", operationName) + logger.info("Could not %s ODIMRA on any primary nodes", operationName) os.chdir(cur_dir) exit(1) @@ -1793,16 +1793,16 @@ def deploy_plugin(plugin_name): plugin_count = 0 for plugin in plugin_list: - for master_node in K8S_INVENTORY_DATA['all']['children']['kube_control_plane']['hosts'].items(): - logger.info("Starting deployment of %s on master node %s", plugin, master_node[0]) + for primary_node in K8S_INVENTORY_DATA['all']['children']['kube_control_plane']['hosts'].items(): + logger.info("Starting deployment of %s on primary node %s", plugin, primary_node[0]) deploy_plugin_cmd = 'ansible-playbook -i {host_conf_file} --become --become-user=root \ - --extra-vars "host={master_node} release_name={plugin_name} helm_chart_name={helm_chart_name} helm_config_file={helm_config_file}" deploy_plugin.yaml'.format( \ - host_conf_file=host_file, master_node=master_node[0], \ + --extra-vars "host={primary_node} release_name={plugin_name} helm_chart_name={helm_chart_name} helm_config_file={helm_config_file}" deploy_plugin.yaml'.format( \ + host_conf_file=host_file, primary_node=primary_node[0], \ plugin_name=plugin, helm_chart_name=plugin, \ helm_config_file=CONTROLLER_CONF_FILE) ret = exec(deploy_plugin_cmd, {'ANSIBLE_BECOME_PASS': ANSIBLE_BECOME_PASS}) if ret != 0: - logger.critical("deploying %s failed on master node %s", plugin, master_node) + logger.critical("deploying %s failed on primary node %s", plugin, primary_node) else: plugin_count += 1 break @@ -1843,16 +1843,16 @@ def remove_plugin(plugin_name): load_password_from_vault(cur_dir) upgrade_flag = False - for master_node in K8S_INVENTORY_DATA['all']['children']['kube_control_plane']['hosts'].items(): - logger.info("Starting removal of %s plugin on master node %s", plugin_name, master_node[0]) + for primary_node in K8S_INVENTORY_DATA['all']['children']['kube_control_plane']['hosts'].items(): + logger.info("Starting removal of %s plugin on primary node %s", plugin_name, primary_node[0]) remove_plugin_cmd = 'ansible-playbook -i {host_conf_file} --become --become-user=root \ - --extra-vars "host={master_node} release_name={plugin_name} helm_chart_name={helm_chart_name} helm_config_file={helm_config_file}" remove_plugin.yaml'.format( \ - host_conf_file=host_file, master_node=master_node[0], \ + --extra-vars "host={primary_node} release_name={plugin_name} helm_chart_name={helm_chart_name} helm_config_file={helm_config_file}" remove_plugin.yaml'.format( \ + host_conf_file=host_file, primary_node=primary_node[0], \ plugin_name=plugin_name, helm_chart_name=plugin_name, \ helm_config_file=CONTROLLER_CONF_FILE) ret = exec(remove_plugin_cmd, {'ANSIBLE_BECOME_PASS': ANSIBLE_BECOME_PASS}) if ret != 0: - logger.critical("removal of %s plugin failed on master node %s", plugin_name, master_node[0]) + logger.critical("removal of %s plugin failed on primary node %s", plugin_name, primary_node[0]) else: upgrade_flag=True break diff --git a/plugin-unmanaged-racks/config/config.go b/plugin-unmanaged-racks/config/config.go index 6916f52a3..607d94ce9 100644 --- a/plugin-unmanaged-racks/config/config.go +++ b/plugin-unmanaged-racks/config/config.go @@ -54,7 +54,7 @@ type PluginConfig struct { PKICertificatePath string `yaml:"PKICertificatePath" envconfig:"PKI_CERTIFICATE_PATH_PATH"` LogLevel string `yaml:"LogLevel" envconfig:"LOG_LEVEL"` RedisAddress string `yaml:"RedisAddress" envconfig:"REDIS_ADDRESS"` - SentinelMasterName string `yaml:"SentinelMasterName" envconfig:"SENTINEL_MASTER_NAME"` + SentinelPrimaryName string `yaml:"SentinelPrimaryName" envconfig:"SENTINEL_PRIMARY_NAME"` RedisOnDiskPasswordFilePath string `yaml:"RedisOnDiskPasswordFilePath" envconfig:"REDIS_ONDISK_PASSWORD_FILE_PATH"` RedisOnDiskPassword []byte } diff --git a/plugin-unmanaged-racks/config/config.yml b/plugin-unmanaged-racks/config/config.yml index b3a63c7f6..9c144f028 100644 --- a/plugin-unmanaged-racks/config/config.yml +++ b/plugin-unmanaged-racks/config/config.yml @@ -68,7 +68,7 @@ OdimPassword: #password# # Uncommented 'SentinelMasterName' property, forces URP to initialize failover redis client which # will work only if your Redis has been configured with Sentinel support. # -# SentinelMasterName: mymaster +# SentinelPrimaryName: mymaster # RedisAddress: odimra.local:6380 diff --git a/plugin-unmanaged-racks/db/persistence.go b/plugin-unmanaged-racks/db/persistence.go index b62769013..3415153a4 100644 --- a/plugin-unmanaged-racks/db/persistence.go +++ b/plugin-unmanaged-racks/db/persistence.go @@ -56,12 +56,12 @@ var GetTLSConfig TLSConfig = func(c *config.PluginConfig) (*tls.Config, error) { } // CreateDAO creates new instance of DAO -func CreateDAO(c *config.PluginConfig, sentinelMasterName string, getTLSConfig TLSConfig) *DAO { +func CreateDAO(c *config.PluginConfig, sentinelPrimaryName string, getTLSConfig TLSConfig) *DAO { tlsConfig, err := getTLSConfig(c) if err != nil { logging.Fatalf("error while getting tls configuration: %s", err.Error()) } - if sentinelMasterName == "" { + if sentinelPrimaryName == "" { return &DAO{ redis.NewClient(&redis.Options{ Addr: c.RedisAddress, @@ -73,7 +73,7 @@ func CreateDAO(c *config.PluginConfig, sentinelMasterName string, getTLSConfig T return &DAO{ redis.NewFailoverClient(&redis.FailoverOptions{ - MasterName: sentinelMasterName, + MasterName: sentinelPrimaryName, SentinelAddrs: []string{c.RedisAddress}, TLSConfig: tlsConfig, SentinelPassword: string(c.RedisOnDiskPassword), diff --git a/plugin-unmanaged-racks/go.sum b/plugin-unmanaged-racks/go.sum index 60a52fad4..91663a0cc 100644 --- a/plugin-unmanaged-racks/go.sum +++ b/plugin-unmanaged-racks/go.sum @@ -94,6 +94,8 @@ github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:W github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/gomodule/redigo v1.7.1-0.20190724094224-574c33c3df38/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= +github.com/gomodule/redigo v1.8.2/go.mod h1:P9dn9mFrCBvWhGE1wpxx6fgq7BAeLBk+UUUzlpkBYO0= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= diff --git a/plugin-unmanaged-racks/rest/module.go b/plugin-unmanaged-racks/rest/module.go index a67f4c2ef..2e19a84b6 100644 --- a/plugin-unmanaged-racks/rest/module.go +++ b/plugin-unmanaged-racks/rest/module.go @@ -49,7 +49,7 @@ func InitializeAndRun(pluginConfiguration *config.PluginConfig) { redfish.BasicAuth(pluginConfiguration.OdimUserName, enigma.Decrypt(pluginConfiguration.OdimPassword)), ) - dao := db.CreateDAO(pluginConfiguration, pluginConfiguration.SentinelMasterName, db.GetTLSConfig) + dao := db.CreateDAO(pluginConfiguration, pluginConfiguration.SentinelPrimaryName, db.GetTLSConfig) createApplication(pluginConfiguration, dao, odimraHTTPClient).Run( func(app *iris.Application) error {