Skip to content

Commit

Permalink
OCPBUGSM-30853: Change default telemeter server of installed clusters…
Browse files Browse the repository at this point in the history
… to prod. (#1988)

Until now, in the service, we changed the default behavior of openshift,
which is to always send cluster metrics to prod-telemeter-server unless
changed by the user, and we:
    * left untouched clusters created by cloud prod env
    * redirected to telemeter-stage stage clusters
    * redirected to dummy-url all other clusters

The issue with this approach is that all prod clusters that aren't
created in the cloud, operator clusters for example,  will fail to
deliver telemetry.

Instead, we will now default to prod-telemeter instead of dummy-url
unless we know better:
    * left untouched clusters created by ALL prod envs (not just cloud)
    * redirect to telemeter-stage stage clusters
    * redirect to dummy-url integration clusters

Signed-off-by: Yoni Bettan <ybettan@redhat.com>
  • Loading branch information
ybettan committed Jun 15, 2021
1 parent 6bda34b commit 956bb02
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
21 changes: 11 additions & 10 deletions internal/network/manifests_generator.go
Expand Up @@ -361,10 +361,10 @@ data:
telemeterServerURL: {{.TELEMETER_SERVER_URL}}
`

prodServiceBaseURL = "https://api.openshift.com"
stageServiceBaseURL = "https://api.stage.openshift.com"
stageTelemeterURL = "https://infogw.stage.api.openshift.com"
dummyURL = "https://dummy.com"
stageServiceBaseURL = "https://api.stage.openshift.com"
integrationServiceBaseURL = "https://api.integration.openshift.com"
stageTelemeterURL = "https://infogw.api.stage.openshift.com"
dummyURL = "https://dummy.com"
)

// Default Telemeter server is prod.
Expand All @@ -374,20 +374,21 @@ func (m *ManifestsGenerator) AddTelemeterManifest(ctx context.Context, log logru

manifestParams := map[string]string{}

if m.Config.ServiceBaseURL == prodServiceBaseURL {
return nil
}
switch m.Config.ServiceBaseURL {

if m.Config.ServiceBaseURL == stageServiceBaseURL {
case stageServiceBaseURL:

log.Infof("Creating manifest to redirect metrics from installed cluster to telemeter-stage")
manifestParams["TELEMETER_SERVER_URL"] = stageTelemeterURL

} else {
case integrationServiceBaseURL:

log.Infof("Creating manifest to redirect metrics from installed cluster to a dummy URL")
log.Infof("Creating manifest to redirect metrics from installed cluster to dummy URL")
manifestParams["TELEMETER_SERVER_URL"] = dummyURL

default:
return nil

}

content, err := fillTemplate(manifestParams, redirectTelemeterStageManifest, log)
Expand Down
15 changes: 7 additions & 8 deletions internal/network/manifests_generator_test.go
Expand Up @@ -345,17 +345,16 @@ var _ = Describe("telemeter manifest", func() {
envName string
serviceBaseURL string
}{
{
envName: "Prod env",
serviceBaseURL: prodServiceBaseURL,
},
{
envName: "Stage env",
serviceBaseURL: stageServiceBaseURL,
},
{
envName: "Other envs",
serviceBaseURL: dummyURL,
envName: "Integration env",
serviceBaseURL: integrationServiceBaseURL,
},
{
envName: "Other envs",
},
} {
test := test
Expand All @@ -366,15 +365,15 @@ var _ = Describe("telemeter manifest", func() {
})

It("happy flow", func() {
if test.envName != "Prod env" {
if test.envName == "Stage env" || test.envName == "Integration env" {
mockManifestsApi.EXPECT().CreateClusterManifest(ctx, gomock.Any()).Return(operations.NewCreateClusterManifestCreated())
}
err := manifestsGeneratorApi.AddTelemeterManifest(ctx, log, &cluster)
Expect(err).ShouldNot(HaveOccurred())
})

It("AddTelemeterManifest failure", func() {
if test.envName == "Prod env" {
if test.envName != "Stage env" && test.envName != "Integration env" {
Skip("We don't create any additional manifest in prod")
}
mockManifestsApi.EXPECT().CreateClusterManifest(ctx, gomock.Any()).Return(common.GenerateErrorResponder(errors.Errorf("failed to upload to s3")))
Expand Down
2 changes: 1 addition & 1 deletion subsystem/manifests_test.go
Expand Up @@ -139,7 +139,7 @@ spec:
It("check installation telemeter manifests", func() {

isProdDeployment := func() bool {
return Options.InventoryHost == "api.openshift.com"
return Options.InventoryHost != "api.stage.openshift.com" && Options.InventoryHost != "api.integration.openshift.com"
}

if isProdDeployment() {
Expand Down

0 comments on commit 956bb02

Please sign in to comment.