Skip to content

Commit

Permalink
fix compile
Browse files Browse the repository at this point in the history
  • Loading branch information
leon-inf committed Jun 27, 2023
1 parent 0bf0210 commit 4e93a0c
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 24 deletions.
8 changes: 4 additions & 4 deletions cmd/probe/internal/binding/operation_volume_protection.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ const (
tokenFile = "/var/run/secrets/kubernetes.io/serviceaccount/token"

envNamespace = "KB_NAMESPACE"
envHostIp = "KB_HOST_IP"
envHostIP = "KB_HOST_IP"
envNodeName = "KB_NODENAME"
envPodName = "KB_POD_NAME"
envPodUid = "KB_POD_UID"
envPodUID = "KB_POD_UID"
envVolumesToProbe = "KB_VOLUME_PROTECTION_SPEC"

reasonLock = "HighVolumeWatermark"
Expand Down Expand Up @@ -303,7 +303,7 @@ func (o *operationVolumeProtection) createEvent(reason, msg string) *corev1.Even
Kind: "Pod",
Namespace: os.Getenv(envNamespace),
Name: os.Getenv(envPodName),
UID: types.UID(os.Getenv(envPodUid)),
UID: types.UID(os.Getenv(envPodUID)),
FieldPath: "spec.containers{sqlchannel}",
},
Reason: reason,
Expand Down Expand Up @@ -361,7 +361,7 @@ func httpRequest(ctx context.Context) (*http.Request, error) {
}

func kubeletEndpointHost(ctx context.Context) (string, error) {
return os.Getenv(envHostIp), nil
return os.Getenv(envHostIP), nil
}

func kubeletEndpointPort(ctx context.Context) (string, error) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/probe/internal/binding/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func SentProbeEvent(ctx context.Context, opsResult OpsResult, log logger.Logger)
return
}

sendEvent(ctx, log, event)
_ = sendEvent(ctx, log, event)
}

func createProbeEvent(opsResult OpsResult) (*corev1.Event, error) {
Expand Down
62 changes: 62 additions & 0 deletions config/crd/bases/apps.kubeblocks.io_clusterdefinitions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8120,6 +8120,50 @@ spec:
minimum: 1
type: integer
type: object
volumeProtectionProbe:
description: 'TODO: we should not provide this option for
user. Probe to monitor the volume space usage and prohibit
the instance from writing if the volume space usage is
over the defined threshold. Reference ClusterDefinition.ClusterComponentDefinition.VolumeProtectionSpec
for the threshold and volumes to monitor.'
properties:
commands:
description: commands used to execute for probe.
properties:
queries:
description: Read check executed on probe sidecar,
used to check workload's readonly access.
items:
type: string
type: array
writes:
description: Write check executed on probe sidecar,
used to check workload's allow write access.
items:
type: string
type: array
type: object
failureThreshold:
default: 3
description: Minimum consecutive failures for the probe
to be considered failed after having succeeded.
format: int32
minimum: 2
type: integer
periodSeconds:
default: 1
description: How often (in seconds) to perform the probe.
format: int32
minimum: 1
type: integer
timeoutSeconds:
default: 1
description: Number of seconds after which the probe
times out. Defaults to 1 second.
format: int32
minimum: 1
type: integer
type: object
type: object
replicationSpec:
description: replicationSpec defines replication related spec
Expand Down Expand Up @@ -9000,6 +9044,24 @@ spec:
- cmdExecutorConfig
- passwordConfig
type: object
volumeProtectionSpec:
properties:
highWatermark:
default: 90
maximum: 100
minimum: 0
type: integer
lowWatermark:
default: 90
maximum: 100
minimum: 0
type: integer
volumes:
description: Volumes to monitor.
items:
type: string
type: array
type: object
volumeTypes:
description: "volumeTypes is used to describe the purpose of
the volumes mapping the name of the VolumeMounts in the PodSpec.Container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ var _ = Describe("ReplicationSet Util", func() {
Expect(err.Error()).Should(ContainSubstring("more than one primary pod found"))

newReplicationStatus := &appsv1alpha1.ReplicationSetStatus{}
err = genReplicationSetStatus(newReplicationStatus, podList)
_ = genReplicationSetStatus(newReplicationStatus, podList)
Expect(len(newReplicationStatus.Secondaries)).Should(Equal(3))
}

Expand Down
62 changes: 62 additions & 0 deletions deploy/helm/crds/apps.kubeblocks.io_clusterdefinitions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8120,6 +8120,50 @@ spec:
minimum: 1
type: integer
type: object
volumeProtectionProbe:
description: 'TODO: we should not provide this option for
user. Probe to monitor the volume space usage and prohibit
the instance from writing if the volume space usage is
over the defined threshold. Reference ClusterDefinition.ClusterComponentDefinition.VolumeProtectionSpec
for the threshold and volumes to monitor.'
properties:
commands:
description: commands used to execute for probe.
properties:
queries:
description: Read check executed on probe sidecar,
used to check workload's readonly access.
items:
type: string
type: array
writes:
description: Write check executed on probe sidecar,
used to check workload's allow write access.
items:
type: string
type: array
type: object
failureThreshold:
default: 3
description: Minimum consecutive failures for the probe
to be considered failed after having succeeded.
format: int32
minimum: 2
type: integer
periodSeconds:
default: 1
description: How often (in seconds) to perform the probe.
format: int32
minimum: 1
type: integer
timeoutSeconds:
default: 1
description: Number of seconds after which the probe
times out. Defaults to 1 second.
format: int32
minimum: 1
type: integer
type: object
type: object
replicationSpec:
description: replicationSpec defines replication related spec
Expand Down Expand Up @@ -9000,6 +9044,24 @@ spec:
- cmdExecutorConfig
- passwordConfig
type: object
volumeProtectionSpec:
properties:
highWatermark:
default: 90
maximum: 100
minimum: 0
type: integer
lowWatermark:
default: 90
maximum: 100
minimum: 0
type: integer
volumes:
description: Volumes to monitor.
items:
type: string
type: array
type: object
volumeTypes:
description: "volumeTypes is used to describe the purpose of
the volumes mapping the name of the VolumeMounts in the PodSpec.Container
Expand Down
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,20 @@ require (
gopkg.in/inf.v0 v0.9.1
gopkg.in/yaml.v2 v2.4.0
helm.sh/helm/v3 v3.11.1
k8s.io/api v0.27.3
k8s.io/api v0.26.1
k8s.io/apiextensions-apiserver v0.26.1
k8s.io/apimachinery v0.27.3
k8s.io/apimachinery v0.26.1
k8s.io/cli-runtime v0.26.1
k8s.io/client-go v0.27.3
k8s.io/client-go v0.26.1
k8s.io/code-generator v0.26.1
k8s.io/component-base v0.27.3
k8s.io/component-base v0.26.1
k8s.io/cri-api v0.25.0
k8s.io/gengo v0.0.0-20220913193501-391367153a38
k8s.io/klog v1.0.0
k8s.io/klog/v2 v2.90.1
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f
k8s.io/kube-openapi v0.0.0-20230308215209-15aac26d736a
k8s.io/kubectl v0.26.0
k8s.io/kubelet v0.27.3
k8s.io/kubelet v0.26.1
k8s.io/metrics v0.26.0
k8s.io/utils v0.0.0-20230209194617-a36077c30491
sigs.k8s.io/controller-runtime v0.14.4
Expand Down
14 changes: 2 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2560,8 +2560,6 @@ k8s.io/api v0.20.4/go.mod h1:++lNL1AJMkDymriNniQsWRkMDzRaX2Y/POTUi8yvqYQ=
k8s.io/api v0.20.6/go.mod h1:X9e8Qag6JV/bL5G6bU8sdVRltWKmdHsFUGS3eVndqE8=
k8s.io/api v0.26.1 h1:f+SWYiPd/GsiWwVRz+NbFyCgvv75Pk9NK6dlkZgpCRQ=
k8s.io/api v0.26.1/go.mod h1:xd/GBNgR0f707+ATNyPmQ1oyKSgndzXij81FzWGsejg=
k8s.io/api v0.27.3 h1:yR6oQXXnUEBWEWcvPWS0jQL575KoAboQPfJAuKNrw5Y=
k8s.io/api v0.27.3/go.mod h1:C4BNvZnQOF7JA/0Xed2S+aUyJSfTGkGFxLXz9MnpIpg=
k8s.io/apiextensions-apiserver v0.26.1 h1:cB8h1SRk6e/+i3NOrQgSFij1B2S0Y0wDoNl66bn8RMI=
k8s.io/apiextensions-apiserver v0.26.1/go.mod h1:AptjOSXDGuE0JICx/Em15PaoO7buLwTs0dGleIHixSM=
k8s.io/apimachinery v0.19.0/go.mod h1:DnPGDnARWFvYa3pMHgSxtbZb7gpzzAZ1pTfaUNDVlmA=
Expand All @@ -2570,8 +2568,6 @@ k8s.io/apimachinery v0.20.4/go.mod h1:WlLqWAHZGg07AeltaI0MV5uk1Omp8xaN0JGLY6gkRp
k8s.io/apimachinery v0.20.6/go.mod h1:ejZXtW1Ra6V1O5H8xPBGz+T3+4gfkTCeExAHKU57MAc=
k8s.io/apimachinery v0.26.1 h1:8EZ/eGJL+hY/MYCNwhmDzVqq2lPl3N3Bo8rvweJwXUQ=
k8s.io/apimachinery v0.26.1/go.mod h1:tnPmbONNJ7ByJNz9+n9kMjNP8ON+1qoAIIC70lztu74=
k8s.io/apimachinery v0.27.3 h1:Ubye8oBufD04l9QnNtW05idcOe9Z3GQN8+7PqmuVcUM=
k8s.io/apimachinery v0.27.3/go.mod h1:XNfZ6xklnMCOGGFNqXG7bUrQCoR04dh/E7FprV6pb+E=
k8s.io/apiserver v0.20.1/go.mod h1:ro5QHeQkgMS7ZGpvf4tSMx6bBOgPfE+f52KwvXfScaU=
k8s.io/apiserver v0.20.4/go.mod h1:Mc80thBKOyy7tbvFtB4kJv1kbdD0eIH8k8vianJcbFM=
k8s.io/apiserver v0.20.6/go.mod h1:QIJXNt6i6JB+0YQRNcS0hdRHJlMhflFmsBDeSgT1r8Q=
Expand All @@ -2585,8 +2581,6 @@ k8s.io/client-go v0.20.4/go.mod h1:LiMv25ND1gLUdBeYxBIwKpkSC5IsozMMmOOeSJboP+k=
k8s.io/client-go v0.20.6/go.mod h1:nNQMnOvEUEsOzRRFIIkdmYOjAZrC8bgq0ExboWSU1I0=
k8s.io/client-go v0.26.1 h1:87CXzYJnAMGaa/IDDfRdhTzxk/wzGZ+/HUQpqgVSZXU=
k8s.io/client-go v0.26.1/go.mod h1:IWNSglg+rQ3OcvDkhY6+QLeasV4OYHDjdqeWkDQZwGE=
k8s.io/client-go v0.27.3 h1:7dnEGHZEJld3lYwxvLl7WoehK6lAq7GvgjxpA3nv1E8=
k8s.io/client-go v0.27.3/go.mod h1:2MBEKuTo6V1lbKy3z1euEGnhPfGZLKTS9tiJ2xodM48=
k8s.io/code-generator v0.19.0/go.mod h1:moqLn7w0t9cMs4+5CQyxnfA/HV8MF6aAVENF+WZZhgk=
k8s.io/code-generator v0.19.7/go.mod h1:lwEq3YnLYb/7uVXLorOJfxg+cUu2oihFhHZ0n9NIla0=
k8s.io/code-generator v0.26.1 h1:dusFDsnNSKlMFYhzIM0jAO1OlnTN5WYwQQ+Ai12IIlo=
Expand All @@ -2596,8 +2590,6 @@ k8s.io/component-base v0.20.4/go.mod h1:t4p9EdiagbVCJKrQ1RsA5/V4rFQNDfRlevJajlGw
k8s.io/component-base v0.20.6/go.mod h1:6f1MPBAeI+mvuts3sIdtpjljHWBQ2cIy38oBIWMYnrM=
k8s.io/component-base v0.26.1 h1:4ahudpeQXHZL5kko+iDHqLj/FSGAEUnSVO0EBbgDd+4=
k8s.io/component-base v0.26.1/go.mod h1:VHrLR0b58oC035w6YQiBSbtsf0ThuSwXP+p5dD/kAWU=
k8s.io/component-base v0.27.3 h1:g078YmdcdTfrCE4fFobt7qmVXwS8J/3cI1XxRi/2+6k=
k8s.io/component-base v0.27.3/go.mod h1:JNiKYcGImpQ44iwSYs6dysxzR9SxIIgQalk4HaCNVUY=
k8s.io/component-helpers v0.26.0 h1:KNgwqs3EUdK0HLfW4GhnbD+q/Zl9U021VfIU7qoVYFk=
k8s.io/component-helpers v0.26.0/go.mod h1:jHN01qS/Jdj95WCbTe9S2VZ9yxpxXNY488WjF+yW4fo=
k8s.io/cri-api v0.17.3/go.mod h1:X1sbHmuXhwaHs9xxYffLqJogVsnI+f6cPRcgPel7ywM=
Expand All @@ -2623,12 +2615,10 @@ k8s.io/kube-openapi v0.0.0-20200805222855-6aeccd4b50c6/go.mod h1:UuqjUnNftUyPE5H
k8s.io/kube-openapi v0.0.0-20201113171705-d219536bb9fd/go.mod h1:WOJ3KddDSol4tAGcJo0Tvi+dK12EcqSLqcWsryKMpfM=
k8s.io/kube-openapi v0.0.0-20230308215209-15aac26d736a h1:gmovKNur38vgoWfGtP5QOGNOA7ki4n6qNYoFAgMlNvg=
k8s.io/kube-openapi v0.0.0-20230308215209-15aac26d736a/go.mod h1:y5VtZWM9sHHc2ZodIH/6SHzXj+TPU5USoA8lcIeKEKY=
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f h1:2kWPakN3i/k81b0gvD5C5FJ2kxm1WrQFanWchyKuqGg=
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f/go.mod h1:byini6yhqGC14c3ebc/QwanvYwhuMWF6yz2F8uwW8eg=
k8s.io/kubectl v0.26.0 h1:xmrzoKR9CyNdzxBmXV7jW9Ln8WMrwRK6hGbbf69o4T0=
k8s.io/kubectl v0.26.0/go.mod h1:eInP0b+U9XUJWSYeU9XZnTA+cVYuWyl3iYPGtru0qhQ=
k8s.io/kubelet v0.27.3 h1:5WhTV1iiBu9q/rr+gvy65LQ+K/e7dmgcaYjys5ipLqY=
k8s.io/kubelet v0.27.3/go.mod h1:Mz42qgZZgWgPmOJEYaR5evmh+EoSwFzEvPBozA2y9mg=
k8s.io/kubelet v0.26.1 h1:wQyCQYmLW6GN3v7gVTxnc3jAE4zMYDlzdF3FZV4rKas=
k8s.io/kubelet v0.26.1/go.mod h1:gFVZ1Ab4XdjtnYdVRATwGwku7FhTxo6LVEZwYoQaDT8=
k8s.io/kubernetes v1.13.0/go.mod h1:ocZa8+6APFNC2tX1DZASIbocyYT5jHzqFVsY5aoB7Jk=
k8s.io/metrics v0.26.0 h1:U/NzZHKDrIVGL93AUMRkqqXjOah3wGvjSnKmG/5NVCs=
k8s.io/metrics v0.26.0/go.mod h1:cf5MlG4ZgWaEFZrR9+sOImhZ2ICMpIdNurA+D8snIs8=
Expand Down

0 comments on commit 4e93a0c

Please sign in to comment.