From bcab97d45f6e6c39a37b7500314271b31f791a3d Mon Sep 17 00:00:00 2001 From: Irina Date: Sun, 19 Apr 2020 17:03:16 +0300 Subject: [PATCH] RIC-208 - KA Decision: ask K8S to restart E2T instance - comment code Change-Id: Ic15c8c5fcb994603544c9c7688f272057fce3a5d Signed-off-by: Irina --- E2Manager/configuration/configuration.go | 16 ++++++++-------- E2Manager/configuration/configuration_test.go | 10 +++++----- E2Manager/container-tag.yaml | 2 +- E2Manager/managers/e2t_shutdown_manager.go | 2 +- E2Manager/managers/e2t_shutdown_manager_test.go | 17 ++++++++++------- E2Manager/managers/kubernetes_manager.go | 14 +++++--------- E2Manager/managers/kubernetes_manager_test.go | 2 ++ E2Manager/resources/configuration.yaml | 5 +---- E2Manager/resources/rmr.verbose | 2 +- 9 files changed, 34 insertions(+), 36 deletions(-) diff --git a/E2Manager/configuration/configuration.go b/E2Manager/configuration/configuration.go index 54a0410..2169f6a 100644 --- a/E2Manager/configuration/configuration.go +++ b/E2Manager/configuration/configuration.go @@ -38,10 +38,10 @@ type Configuration struct { RoutingManager struct { BaseUrl string } - Kubernetes struct { +/* Kubernetes struct { ConfigPath string Namespace string - } + }*/ NotificationResponseBuffer int BigRedButtonTimeoutSec int MaxConnectionAttempts int @@ -73,7 +73,7 @@ func ParseConfiguration() *Configuration { config.populateHttpConfig(viper.Sub("http")) config.populateLoggingConfig(viper.Sub("logging")) config.populateRoutingManagerConfig(viper.Sub("routingManager")) - config.populateKubernetesConfig(viper.Sub("kubernetes")) + //config.populateKubernetesConfig(viper.Sub("kubernetes")) config.NotificationResponseBuffer = viper.GetInt("notificationResponseBuffer") config.BigRedButtonTimeoutSec = viper.GetInt("bigRedButtonTimeoutSec") config.MaxConnectionAttempts = viper.GetInt("maxConnectionAttempts") @@ -115,13 +115,13 @@ func (c *Configuration) populateRoutingManagerConfig(rmConfig *viper.Viper) { c.RoutingManager.BaseUrl = rmConfig.GetString("baseUrl") } -func (c *Configuration) populateKubernetesConfig(rmConfig *viper.Viper) { +/*func (c *Configuration) populateKubernetesConfig(rmConfig *viper.Viper) { if rmConfig == nil { panic(fmt.Sprintf("#configuration.populateKubernetesConfig - failed to populate Kubernetes configuration: The entry 'kubernetes' not found\n")) } c.Kubernetes.ConfigPath = rmConfig.GetString("configPath") c.Kubernetes.Namespace = rmConfig.GetString("namespace") -} +}*/ func (c *Configuration) populateGlobalRicIdConfig(globalRicIdConfig *viper.Viper) { if globalRicIdConfig == nil { @@ -135,7 +135,7 @@ func (c *Configuration) String() string { return fmt.Sprintf("{logging.logLevel: %s, http.port: %d, rmr: { port: %d, maxMsgSize: %d}, routingManager.baseUrl: %s, "+ "notificationResponseBuffer: %d, bigRedButtonTimeoutSec: %d, maxConnectionAttempts: %d, maxRnibConnectionAttempts: %d, "+ "rnibRetryIntervalMs: %d, keepAliveResponseTimeoutMs: %d, keepAliveDelayMs: %d, e2tInstanceDeletionTimeoutMs: %d, "+ - "globalRicId: { plmnId: %s, ricNearRtId: %s}, kubernetes: {configPath: %s, namespace: %s}}", + "globalRicId: { plmnId: %s, ricNearRtId: %s}}",//, kubernetes: {configPath: %s, namespace: %s}}", c.Logging.LogLevel, c.Http.Port, c.Rmr.Port, @@ -151,7 +151,7 @@ func (c *Configuration) String() string { c.E2TInstanceDeletionTimeoutMs, c.GlobalRicId.PlmnId, c.GlobalRicId.RicNearRtId, - c.Kubernetes.ConfigPath, - c.Kubernetes.Namespace, + // c.Kubernetes.ConfigPath, + //c.Kubernetes.Namespace, ) } diff --git a/E2Manager/configuration/configuration_test.go b/E2Manager/configuration/configuration_test.go index ce0448d..cdbf338 100644 --- a/E2Manager/configuration/configuration_test.go +++ b/E2Manager/configuration/configuration_test.go @@ -42,8 +42,8 @@ func TestParseConfigurationSuccess(t *testing.T) { assert.NotNil(t, config.GlobalRicId) assert.NotEmpty(t, config.GlobalRicId.PlmnId) assert.NotEmpty(t, config.GlobalRicId.RicNearRtId) - assert.NotEmpty(t, config.Kubernetes.Namespace) - assert.NotEmpty(t, config.Kubernetes.ConfigPath) + /*assert.NotEmpty(t, config.Kubernetes.Namespace) + assert.NotEmpty(t, config.Kubernetes.ConfigPath)*/ } func TestStringer(t *testing.T) { @@ -208,7 +208,7 @@ func TestGlobalRicIdConfigNotFoundFailure(t *testing.T) { "logging": map[string]interface{}{"logLevel": "info"}, "http": map[string]interface{}{"port": 3800}, "routingManager": map[string]interface{}{"baseUrl": "http://iltlv740.intl.att.com:8080/ric/v1/handles/"}, - "kubernetes": map[string]interface{}{"namespace": "test", "ConfigPath": "test"}, + //"kubernetes": map[string]interface{}{"namespace": "test", "ConfigPath": "test"}, } buf, err := yaml.Marshal(yamlMap) if err != nil { @@ -222,7 +222,7 @@ func TestGlobalRicIdConfigNotFoundFailure(t *testing.T) { func() { ParseConfiguration() }) } -func TestKubernetesConfigNotFoundFailure(t *testing.T) { +/*func TestKubernetesConfigNotFoundFailure(t *testing.T) { configPath := "../resources/configuration.yaml" configPathTmp := "../resources/configuration.yaml_tmp" err := os.Rename(configPath, configPathTmp) @@ -252,4 +252,4 @@ func TestKubernetesConfigNotFoundFailure(t *testing.T) { } assert.PanicsWithValue(t, "#configuration.populateKubernetesConfig - failed to populate Kubernetes configuration: The entry 'kubernetes' not found\n", func() { ParseConfiguration() }) -} +}*/ diff --git a/E2Manager/container-tag.yaml b/E2Manager/container-tag.yaml index 4504e37..745e65a 100644 --- a/E2Manager/container-tag.yaml +++ b/E2Manager/container-tag.yaml @@ -1,4 +1,4 @@ # The Jenkins job requires a tag to build the Docker image. # Global-JJB script assumes this file is in the repo root. --- -tag: 4.4.1 +tag: 4.4.2 diff --git a/E2Manager/managers/e2t_shutdown_manager.go b/E2Manager/managers/e2t_shutdown_manager.go index bb89e3b..6287547 100644 --- a/E2Manager/managers/e2t_shutdown_manager.go +++ b/E2Manager/managers/e2t_shutdown_manager.go @@ -62,7 +62,7 @@ func (m E2TShutdownManager) Shutdown(e2tInstance *entities.E2TInstance) error { return nil } - go m.kubernetesManager.DeletePod(e2tInstance.PodName) + //go m.kubernetesManager.DeletePod(e2tInstance.PodName) err := m.markE2tInstanceToBeDeleted(e2tInstance) if err != nil { diff --git a/E2Manager/managers/e2t_shutdown_manager_test.go b/E2Manager/managers/e2t_shutdown_manager_test.go index 21de338..499f067 100644 --- a/E2Manager/managers/e2t_shutdown_manager_test.go +++ b/E2Manager/managers/e2t_shutdown_manager_test.go @@ -35,8 +35,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "io/ioutil" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/client-go/kubernetes/fake" + //"k8s.io/apimachinery/pkg/runtime" + //"k8s.io/client-go/kubernetes/fake" "net/http" "testing" "time" @@ -56,11 +56,14 @@ func initE2TShutdownManagerTest(t *testing.T) (*E2TShutdownManager, *mocks.RnibR httpClientMock := &mocks.HttpClientMock{} rmClient := clients.NewRoutingManagerClient(log, config, httpClientMock) associationManager := NewE2TAssociationManager(log, rnibDataService, e2tInstancesManager, rmClient) - kubernetesManager := initKubernetesManagerTest(t) + //kubernetesManager := initKubernetesManagerTest(t) - shutdownManager := NewE2TShutdownManager(log, config, rnibDataService, e2tInstancesManager, associationManager, kubernetesManager) + /*shutdownManager := NewE2TShutdownManager(log, config, rnibDataService, e2tInstancesManager, associationManager, kubernetesManager) - return shutdownManager, readerMock, writerMock, httpClientMock, kubernetesManager + return shutdownManager, readerMock, writerMock, httpClientMock, kubernetesManager*/ + shutdownManager := NewE2TShutdownManager(log, config, rnibDataService, e2tInstancesManager, associationManager, nil) + + return shutdownManager, readerMock, writerMock, httpClientMock, nil } func TestShutdownSuccess1OutOf3Instances(t *testing.T) { @@ -409,7 +412,7 @@ func TestShutdownFailureInRemoveE2TInstance(t *testing.T) { writerMock.AssertExpectations(t) httpClientMock.AssertExpectations(t) } - +/* func TestShutdownSuccess2Instance2Rans(t *testing.T) { shutdownManager, readerMock, writerMock, httpClientMock,kubernetesManager := initE2TShutdownManagerTest(t) @@ -504,4 +507,4 @@ func TestShutdownSuccess2Instance2RansNoPod(t *testing.T) { writerMock.AssertExpectations(t) httpClientMock.AssertExpectations(t) }) -} \ No newline at end of file +}*/ \ No newline at end of file diff --git a/E2Manager/managers/kubernetes_manager.go b/E2Manager/managers/kubernetes_manager.go index 5c3e8ee..ef36c28 100644 --- a/E2Manager/managers/kubernetes_manager.go +++ b/E2Manager/managers/kubernetes_manager.go @@ -22,12 +22,8 @@ package managers import ( "e2mgr/configuration" - "e2mgr/e2managererrors" "e2mgr/logger" - metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" - "k8s.io/client-go/tools/clientcmd" - "path/filepath" ) type KubernetesManager struct { @@ -39,7 +35,7 @@ type KubernetesManager struct { func NewKubernetesManager(logger *logger.Logger, config *configuration.Configuration) *KubernetesManager { return &KubernetesManager{ Logger: logger, - ClientSet: createClientSet(logger, config), + // ClientSet: createClientSet(logger, config), Config: config, } } @@ -63,7 +59,7 @@ func NewKubernetesManager(logger *logger.Logger, config *configuration.Configura km.DeletePod(podInterface, podName) }*/ -func createClientSet(logger *logger.Logger, config *configuration.Configuration) kubernetes.Interface { +/*func createClientSet(logger *logger.Logger, config *configuration.Configuration) kubernetes.Interface { ////path := os.Getenv("HOME") + "/.kube/config" absConfigPath,err := filepath.Abs(config.Kubernetes.ConfigPath) @@ -84,7 +80,7 @@ func createClientSet(logger *logger.Logger, config *configuration.Configuration) return nil } return clientSet -} +}*/ /*func (km KubernetesManager) DeletePod(podInterface v1.PodInterface, podName string) { km.logger.Infof("#KubernetesManager.DeletePod - POD name %s ", podName) @@ -99,7 +95,7 @@ func createClientSet(logger *logger.Logger, config *configuration.Configuration) } */ func (km KubernetesManager) DeletePod(podName string) error { - km.Logger.Infof("#KubernetesManager.DeletePod - POD name: %s ", podName) +/* km.Logger.Infof("#KubernetesManager.DeletePod - POD name: %s ", podName) if km.ClientSet == nil { km.Logger.Errorf("#KubernetesManager.DeletePod - no kubernetesManager connection") @@ -118,7 +114,7 @@ func (km KubernetesManager) DeletePod(podName string) error { return err } - km.Logger.Infof("#KubernetesManager.DeletePod - POD %s was deleted", podName) + km.Logger.Infof("#KubernetesManager.DeletePod - POD %s was deleted", podName)*/ return nil } diff --git a/E2Manager/managers/kubernetes_manager_test.go b/E2Manager/managers/kubernetes_manager_test.go index 0f207ed..dab5943 100644 --- a/E2Manager/managers/kubernetes_manager_test.go +++ b/E2Manager/managers/kubernetes_manager_test.go @@ -20,6 +20,7 @@ package managers +/* import ( "e2mgr/configuration" "e2mgr/logger" @@ -148,3 +149,4 @@ func pod(namespace, image string) *v1.Pod { }, } } +*/ \ No newline at end of file diff --git a/E2Manager/resources/configuration.yaml b/E2Manager/resources/configuration.yaml index a7cfcd3..434994b 100644 --- a/E2Manager/resources/configuration.yaml +++ b/E2Manager/resources/configuration.yaml @@ -17,7 +17,4 @@ keepAliveDelayMs: 1500 e2tInstanceDeletionTimeoutMs: 15000 globalRicId: plmnId: 131014 - ricNearRtId: 556670 -kubernetes: - configPath: ./kub_config.yml - namespace: ricplt \ No newline at end of file + ricNearRtId: 556670 \ No newline at end of file diff --git a/E2Manager/resources/rmr.verbose b/E2Manager/resources/rmr.verbose index 56a6051..c227083 100644 --- a/E2Manager/resources/rmr.verbose +++ b/E2Manager/resources/rmr.verbose @@ -1 +1 @@ -1 \ No newline at end of file +0 \ No newline at end of file -- 2.16.6