Skip to content

servicequalities won't work when set state to "false" with result not empty #297

@hidingbear1x

Description

@hidingbear1x

I found this while I test the service qualities function.
I set state to "false" and result to "nginxok"

apiVersion: game.kruise.io/v1alpha1
kind: GameServerSet
metadata:
  name: test
  namespace: default
spec:
  replicas: 3
  gameServerTemplate:
    spec:
      containers:
        - image: nginx: perl
          name: nginx
  serviceQualities:
    - name: test
      containerName: nginx
      permanent: false
      exec:
        command: ["bash", "-c", "echo nginxok; exit 1"]
      serviceQualityAction:
        - state: false
          result: nginxok
          opsState: WaitToBeDeleted

But gs opsState did still “None”
And pod.status.conditions

Image Image ------------------------------------------------

when I set serviceQualityAction like this:

  serviceQualities:
    - name: test
      containerName: nginx
      permanent: false
      exec:
        command: ["bash", "-c", "echo nginxok; exit 0"]
      serviceQualityAction:
        - state: true
          result: nginxok
          opsState: WaitToBeDeleted
Image

it seems like when state set to "false", the result part won't work.
and I found when set state to "false", pod conditions didn't get message

these code maybe related
kruise-game-master/pkg/controllers/gameserver/gameserver_manager.go

			if !exist || ((sqCondition.Status != string(podCondition.Status) || (sqCondition.Result != podConditionMessage)) && (sqCondition.LastActionTransitionTime.IsZero() || !sq.Permanent)) {
				// exec action
				for _, action := range sq.ServiceQualityAction {
					state, err := strconv.ParseBool(string(podCondition.Status))
					if err == nil && state == action.State && (action.Result == "" || podConditionMessage == action.Result) {
						gs.Spec.DeletionPriority = action.DeletionPriority
						gs.Spec.UpdatePriority = action.UpdatePriority
						gs.Spec.OpsState = action.OpsState
						gs.Spec.NetworkDisabled = action.NetworkDisabled
						gs.SetLabels(util.MergeMapString(gs.GetLabels(), action.Labels))
						gs.SetAnnotations(util.MergeMapString(gs.GetAnnotations(), action.Annotations))
						lastActionTransitionTime = timeNow
					}
				}
			} else {
				lastActionTransitionTime = sqCondition.LastActionTransitionTime
			}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions