<@U0A71G31CDV> starrocks operator creating error l...
# questions-and-troubleshooting
r
@Rocky starrocks operator creating error like the object has been modified please apply your changes to the latest version and try again. but we didnt change any customresource yet. what reasone can create this error and how can i handle it?
r
The error message "the object has been modified; please apply your changes to the latest version and try again" is a standard Kubernetes Conflict (409) error. It occurs because of Optimistic Concurrency Control: Kubernetes uses a field called
resourceVersion
to ensure that you don't overwrite changes made by someone (or something) else between the time you "read" the object and the time you "write" it. Even if you haven't manually changed the Custom Resource (CR), here is why this is likely happening and how to handle it: 1. Why is this happening? * The Operator is updating the Status: The StarRocks Operator frequently updates the
status
field of the
StarRocksCluster
resource (e.g., reporting that a node is "Running", updating the version, or adding finalizers). If the operator updates the status at the exact moment you are trying to
apply
a change, your local
resourceVersion
becomes stale. * Managed Fields: When using
kubectl apply
, Kubernetes compares your local file with the server-side version. If the server-side version has been updated by the operator (even just a timestamp or a status message), the conflict can trigger. * Metadata in your YAML: If your YAML file contains system-managed fields like
resourceVersion
,
uid
, or
generation
, Kubernetes will strictly check these. If they don't match the current state exactly, it will fail. 2. How to handle it If you are trying to apply a change: * Use
kubectl patch
or `edit`:
Instead of
kubectl apply
, use
kubectl edit starrockscluster <cluster-name>
. This opens the current version from the server, and Kubernetes handles the conflict resolution when you save. Alternatively, use
kubectl patch
for specific field updates. * Refresh your local YAML: If you must use
apply
, fetch the latest version first:
Copy code
bash
    kubectl get starrockscluster <name> -o yaml > latest_cluster.yaml
    # Edit the file to make your changes
    kubectl apply -f latest_cluster.yaml
* Clean your YAML: Ensure your manifest does not contain
resourceVersion
,
uid
,
creationTimestamp
, or
status
. It should only contain
apiVersion
,
kind
,
metadata
(name/namespace/labels), and
spec
. If the error is appearing in the Operator logs: * Transient Issue: This is often transient. The Operator's reconciliation loop will usually catch the error, wait a few seconds, and retry automatically. If the StarRocks cluster state eventually reaches "Running", you can ignore the log message. * Check for Duplicate Operators: Ensure you don't have two instances of the StarRocks Operator running in the same namespace (or watching the same namespace), as they might "fight" over updating the same resource. Summary Checklist 1. Remove
resourceVersion
from your YAML files. 2. Switch to
kubectl patch
for automated scripts or
kubectl edit
for manual changes. 3. If using CI/CD (like ArgoCD or Flux), ensure they are configured to ignore
status
changes and manage the resource using Server-Side Apply. Referencesdeployment/sr_operator.mdfaq/operation_maintenance_faq.mdadministration/management/BE_configuration.mdfaq/Sql_faq.mdloading/Load_to_Primary_Key_tables.mdadministration/management/logs.md
r
@Rocky all cr(more 30+) of starrocks clusters are still recociling infinitly in operator pod log. Starrocksclusterreconciler.(fe,be,cn)Controller try to create update statefullset, k8s service, and so on. and our monitoring dashboard detect there are 2more watch connection in starrocks cr. already checked operator restart and pod replica size to 1.
r
This behavior typically indicates a Controller Conflict (also known as a "split-brain" scenario) or a Reconciliation Loop caused by a mismatch between the desired state and the live state of the resources. The fact that you see 2+ watch connections on the StarRocks Custom Resource (CR) while having only 1 replica is the key indicator. This means another process is actively watching and potentially modifying your clusters. Here are the reasons and how to resolve this: 1. Identify "Ghost" Operators Even if your current deployment has only 1 replica, there is likely another operator instance running somewhere else in the cluster. * Check All Namespaces: Run
kubectl get pods -A -l <http://app.kubernetes.io/name=starrocks-operator|app.kubernetes.io/name=starrocks-operator>
(or use the label your operator uses) to see if there is an instance in a different namespace. * Check for Multiple Deployments: Sometimes a second operator is installed via a different Helm release name or a manual
kubectl apply
. Check
kubectl get deployments -A | grep starrocks
. * Dangling Processes: If you ever ran the operator locally (e.g.,
go run main.go
) for debugging, that process might still be active and connecting to the API server. 2. Why the Infinite Loop? ("Ping-Pong" Effect) If two operators are running: 1. Operator A sees the StarRocksCluster CR and updates a field (like a Finalizer, Label, or Status). 2. Operator B sees the update, thinks its own version is outdated or disagrees with the change, and tries to update it back. 3. Each update increments the
resourceVersion
. When the other operator tries to write its change, it gets the "object has been modified" error. 4. Because both are "reconciling," they keep trying to update the StatefulSet and Service, leading to the infinite loop in your logs. 3. Resource "Drift" (Defaulting Webhooks) If you are 100% sure only one operator is running, the loop might be caused by Mutating Admission Webhooks or K8s Defaulting: * The Operator sends a "Desired" StatefulSet to K8s. * A Webhook (like Istio, Linkerd, or a security policy) modifies the StatefulSet (e.g., adding a sidecar or a security context). * The Operator sees the "Actual" StatefulSet doesn't match its "Desired" version and tries to "fix" it by updating it again. * How to handle: Compare the
spec
in your operator logs with the actual
kubectl get statefulset <name> -o yaml
. Look for fields present in the live object but not in your CR. 4. How to Handle and Fix 1. Terminate all Operators: Scale the operator deployment to 0 replicas.
Copy code
bash
    kubectl scale deployment <operator-name> -n <namespace> --replicas=0
2. Verify Watchers are Gone: Check your monitoring dashboard. The watch connections for the StarRocks CR should drop to 0. If they stay at 1 or more, you have a hidden operator (check for standalone Pods or processes outside K8s). 3. Clean up stale Finalizers (Optional): If a cluster is stuck deleting, you may need to manually remove finalizers from the CR, but usually, scaling the operator back to 1 after all "ghosts" are gone fixes it. 4. Use `watchNamespace`: If you have multiple teams using StarRocks in one K8s cluster, ensure your operator is configured with the
watchNamespace
environment variable so it only manages clusters in its own namespace. 5. Check Leaderelection: Ensure Leaderelection is enabled in your operator configuration (it is by default in recent versions). This prevents two replicas from acting at the same time by using a
Lease
object. Summary Checklist * [ ] Search all namespaces for pods with "starrocks" in the name. * [ ] Check
kubectl get lease -n <operator-namespace>
to see who holds the leader lock. * [ ] Ensure no one is running a local operator connected to the same K8s context. * [ ] Verify there aren't two different versions of the StarRocks CRD or Operator installed (e.g., an old version and a new version). References