Skip to content

Commit

Permalink
[KOGITO-1474] Fix issue Kogito service cannot be scaled to 0 (apache#220
Browse files Browse the repository at this point in the history
)
  • Loading branch information
xieshenzh authored and MarianMacik committed Oct 3, 2023
1 parent 879d6e3 commit 30728a1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion bddframework/framework/kogitoapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func SetKogitoAppReplicas(namespace, name string, nbPods int) error {
return fmt.Errorf("No KogitoApp found with name %s in namespace %s", name, namespace)
}
replicas := int32(nbPods)
kogitoApp.Spec.KogitoServiceSpec.Replicas = replicas
kogitoApp.Spec.KogitoServiceSpec.Replicas = &replicas
return kubernetes.ResourceC(kubeClient).Update(kogitoApp)
}

Expand Down
6 changes: 3 additions & 3 deletions bddframework/framework/kogitodataindex.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ func InstallKogitoDataIndexService(namespace string, installerType InstallerType
case CLIInstallerType:
return cliInstallKogitoDataIndex(namespace, replicas)
case CRInstallerType:
return crInstallKogitoDataIndex(namespace, replicas)
return crInstallKogitoDataIndex(namespace, int32(replicas))
default:
panic(fmt.Errorf("Unknown installer type %s", installerType))
}
}

func crInstallKogitoDataIndex(namespace string, replicas int) error {
func crInstallKogitoDataIndex(namespace string, replicas int32) error {
// Get correct image tag
image := framework.ConvertImageTagToImage(infrastructure.DefaultDataIndexImageFullTag)
image.Tag = GetConfigServicesImageVersion()
Expand All @@ -52,7 +52,7 @@ func crInstallKogitoDataIndex(namespace string, replicas int) error {
},
Spec: v1alpha1.KogitoDataIndexSpec{
KogitoServiceSpec: v1alpha1.KogitoServiceSpec{
Replicas: int32(replicas),
Replicas: &replicas,
Image: image,
},
},
Expand Down
10 changes: 5 additions & 5 deletions bddframework/framework/kogitojobsservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func InstallKogitoJobsService(namespace string, installerType InstallerType, rep
}

func crInstallKogitoJobsService(namespace string, replicas int, persistence bool) error {
service := getJobsServiceStub(namespace, replicas, persistence)
service := getJobsServiceStub(namespace, int32(replicas), persistence)

if _, err := kubernetes.ResourceC(kubeClient).CreateIfNotExists(service); err != nil {
return fmt.Errorf("Error creating Kogito jobs service: %v", err)
Expand Down Expand Up @@ -100,19 +100,19 @@ func WaitForKogitoJobsService(namespace string, replicas, timeoutInMin int) erro
}

// SetKogitoJobsServiceReplicas sets the number of replicas for the Kogito Jobs Service
func SetKogitoJobsServiceReplicas(namespace string, nbPods int) error {
func SetKogitoJobsServiceReplicas(namespace string, nbPods int32) error {
GetLogger(namespace).Infof("Set Kogito jobs service replica number to %d", nbPods)
kogitoJobsService, err := GetKogitoJobsService(namespace)
if err != nil {
return err
} else if kogitoJobsService == nil {
return fmt.Errorf("No Kogito jobs service found in namespace %s", namespace)
}
kogitoJobsService.Spec.Replicas = int32(nbPods)
kogitoJobsService.Spec.Replicas = &nbPods
return kubernetes.ResourceC(kubeClient).Update(kogitoJobsService)
}

func getJobsServiceStub(namespace string, replicas int, persistence bool) *v1alpha1.KogitoJobsService {
func getJobsServiceStub(namespace string, replicas int32, persistence bool) *v1alpha1.KogitoJobsService {
// Get correct image for tests
image := framework.ConvertImageTagToImage(infrastructure.DefaultJobsServiceImageFullTag)
image.Tag = GetConfigServicesImageVersion()
Expand All @@ -124,7 +124,7 @@ func getJobsServiceStub(namespace string, replicas int, persistence bool) *v1alp
},
Spec: v1alpha1.KogitoJobsServiceSpec{
KogitoServiceSpec: v1alpha1.KogitoServiceSpec{
Replicas: int32(replicas),
Replicas: &replicas,
Image: image,
},
},
Expand Down
2 changes: 1 addition & 1 deletion bddframework/steps/kogitojobsservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (data *Data) kogitoJobsServiceHasPodsRunningWithinMinutes(pods, timeoutInMi
}

func (data *Data) scaleKogitoJobsServiceToPodsWithinMinutes(nbPods, timeoutInMin int) error {
err := framework.SetKogitoJobsServiceReplicas(data.Namespace, nbPods)
err := framework.SetKogitoJobsServiceReplicas(data.Namespace, int32(nbPods))
if err != nil {
return err
}
Expand Down

0 comments on commit 30728a1

Please sign in to comment.