forked from rook/rook
We have introduced a new goroutine to check the state of the rgw
endpoint. It will run every minute and perform operations on a bucket.
The success or failure will be reported as part of the status field of
the CephObjectStore CR.
A good status will look like:
status:
endpointStatus:
lastChanged: "2020-06-25T13:47:45Z"
lastChecked: "2020-06-25T13:48:46Z"
phase: Connected
A failed status:
status:
endpointStatus:
details: |-
error creating bucket "rook-ceph-internal-s3-bucket-checker": RequestError: send request failed
caused by: Put http://rook-ceph-rgw-my-store.rook-ceph:8080/rook-ceph-internal-s3-bucket-checker: dial tcp 10.108.189.148:8080: connect: connection refused
health: ERROR
This check works for both converged and external modes. Note that the
CephObjectStore CRD has a new field called "externalRgwEndpoints" which
allows you to define a list of IP addresses pointing to rgws.
Closes: https://github.com/rook/rook/issues/5692
Signed-off-by: Sébastien Han <seb@redhat.com>
44 lines
1.4 KiB
Go
44 lines
1.4 KiB
Go
/*
|
|
Copyright 2020 The Rook Authors. All rights reserved.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
package k8sutil
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
v1 "k8s.io/api/core/v1"
|
|
"k8s.io/apimachinery/pkg/api/errors"
|
|
"k8s.io/client-go/kubernetes"
|
|
)
|
|
|
|
// CreateOrUpdateEndpoint creates a service or updates the service declaratively if it already exists.
|
|
func CreateOrUpdateEndpoint(clientset kubernetes.Interface, namespace string, endpointDefinition *v1.Endpoints) (*v1.Endpoints, error) {
|
|
name := endpointDefinition.Name
|
|
logger.Debugf("creating endpoint %q. %v", name, endpointDefinition.Subsets)
|
|
ep, err := clientset.CoreV1().Endpoints(namespace).Create(endpointDefinition)
|
|
if err != nil {
|
|
if !errors.IsAlreadyExists(err) {
|
|
return nil, fmt.Errorf("failed to create endpoint %q. %v", name, err)
|
|
}
|
|
ep, err = clientset.CoreV1().Endpoints(namespace).Update(endpointDefinition)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to update endpoint %q. %v", name, err)
|
|
}
|
|
}
|
|
|
|
return ep, err
|
|
}
|