Skip to content

Commit

Permalink
fix some issue about upgrade
Browse files Browse the repository at this point in the history
Signed-off-by: root <[email protected]>
  • Loading branch information
ldpliu committed Dec 25, 2024
1 parent 7a74c9a commit ebdc58b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
4 changes: 3 additions & 1 deletion operator/pkg/controllers/agent/addon_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ func ReadyToEnableAddonManager(mgh *v1alpha4.MulticlusterGlobalHub) bool {
if !config.IsACMResourceReady() {
return false
}

if config.GetTransporterConn() == nil {
return false
}
if !meta.IsStatusConditionTrue(mgh.Status.Conditions, config.CONDITION_TYPE_GLOBALHUB_READY) {
return false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
operatorutils "github.com/stolostron/multicluster-global-hub/operator/pkg/utils"
"github.com/stolostron/multicluster-global-hub/pkg/constants"
"github.com/stolostron/multicluster-global-hub/pkg/transport"
"github.com/stolostron/multicluster-global-hub/pkg/utils"
)

const (
Expand Down Expand Up @@ -629,6 +630,8 @@ func (k *strimziTransporter) kafkaClusterReady() (KafkaStatus, error) {
return kafkaStatus, nil
}

k.isNewKafkaCluster = utils.HasAnnotation(kafkaCluster, constants.UpgradeKafkaFromZookeeperAnnotation)

if kafkaCluster.Spec != nil && kafkaCluster.Spec.Kafka.Listeners != nil {
// if the kafka cluster is already created, check if the tls is enabled
enableTLS := false
Expand Down Expand Up @@ -781,6 +784,9 @@ func (k *strimziTransporter) newKafkaCluster(mgh *operatorv1alpha4.MulticlusterG
},
},
}
if k.isNewKafkaCluster {
kafkaCluster.Annotations[constants.UpgradeKafkaFromZookeeperAnnotation] = "true"
}

k.setAffinity(mgh, kafkaCluster)
k.setTolerations(mgh, kafkaCluster)
Expand Down
3 changes: 2 additions & 1 deletion pkg/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ const (
ManagedClusterManagedByAnnotation = "global-hub.open-cluster-management.io/managed-by"
// identify the resource is from the global hub cluster
OriginOwnerReferenceAnnotation = "global-hub.open-cluster-management.io/origin-ownerreference-uid"

// identy the kafka is upgrade from zookeeper mode
UpgradeKafkaFromZookeeperAnnotation = "global-hub.open-cluster-management.io/upgrade-from-zookeeper"
// resync the kafka client secret in agent
ResyncKafkaClientSecretAnnotation = "global-hub.open-cluster-management.io/resign-kafka-client-secret" // #nosec G101
)
Expand Down
6 changes: 6 additions & 0 deletions test/integration/operator/controllers/agent/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
"github.com/stolostron/multicluster-global-hub/operator/pkg/controllers/agent"
operatortrans "github.com/stolostron/multicluster-global-hub/operator/pkg/controllers/transporter/protocol"
"github.com/stolostron/multicluster-global-hub/pkg/constants"
"github.com/stolostron/multicluster-global-hub/pkg/transport"
"github.com/stolostron/multicluster-global-hub/pkg/utils"
)

Expand Down Expand Up @@ -122,6 +123,11 @@ var _ = BeforeSuite(func() {
EnablePprof: false,
},
}
config.SetTransporterConn(&transport.KafkaConfig{
ClusterID: "fake",
IsNewKafkaCluster: true,
})

By("start the addon manager and add addon controller to manager")
_, err = agent.StartAddonManagerController(controllerOption)
Expect(err).ToNot(HaveOccurred())
Expand Down

0 comments on commit ebdc58b

Please sign in to comment.