Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update v2 status #607

Merged
merged 3 commits into from
Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion apis/datadoghq/v2alpha1/datadogagent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,6 @@ type DatadogAgentStatus struct {
// +kubebuilder:subresource:status
// +kubebuilder:unservedversion
// +kubebuilder:resource:path=datadogagents,shortName=dd
// +kubebuilder:printcolumn:name="active",type="string",JSONPath=".status.conditions[?(@.type=='Active')].status"
// +kubebuilder:printcolumn:name="agent",type="string",JSONPath=".status.agent.status"
// +kubebuilder:printcolumn:name="cluster-agent",type="string",JSONPath=".status.clusterAgent.status"
// +kubebuilder:printcolumn:name="cluster-checks-runner",type="string",JSONPath=".status.clusterChecksRunner.status"
Expand Down
3 changes: 0 additions & 3 deletions config/crd/bases/v1/datadoghq.com_datadogagents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12663,9 +12663,6 @@ spec:
subresources:
status: {}
- additionalPrinterColumns:
- jsonPath: .status.conditions[?(@.type=='Active')].status
name: active
type: string
- jsonPath: .status.agent.status
name: agent
type: string
Expand Down
49 changes: 31 additions & 18 deletions config/crd/bases/v1beta1/datadoghq.com_datadogagents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,6 @@ metadata:
creationTimestamp: null
name: datadogagents.datadoghq.com
spec:
additionalPrinterColumns:
- JSONPath: .status.conditions[?(@.type=='Active')].status
name: active
type: string
- JSONPath: .status.agent.status
name: agent
type: string
- JSONPath: .status.clusterAgent.status
name: cluster-agent
type: string
- JSONPath: .status.clusterChecksRunner.status
name: cluster-checks-runner
type: string
- JSONPath: .metadata.creationTimestamp
name: age
type: date
group: datadoghq.com
names:
kind: DatadogAgent
Expand All @@ -36,7 +20,23 @@ spec:
status: {}
version: v1alpha1
versions:
- name: v1alpha1
- additionalPrinterColumns:
- JSONPath: .status.conditions[?(@.type=='Active')].status
name: active
type: string
- JSONPath: .status.agent.status
name: agent
type: string
- JSONPath: .status.clusterAgent.status
name: cluster-agent
type: string
- JSONPath: .status.clusterChecksRunner.status
name: cluster-checks-runner
type: string
- JSONPath: .metadata.creationTimestamp
name: age
type: date
name: v1alpha1
schema:
openAPIV3Schema:
description: DatadogAgent Deployment with Datadog Operator.
Expand Down Expand Up @@ -25566,7 +25566,20 @@ spec:
type: object
served: true
storage: true
- name: v2alpha1
- additionalPrinterColumns:
- JSONPath: .status.agent.status
name: agent
type: string
- JSONPath: .status.clusterAgent.status
name: cluster-agent
type: string
- JSONPath: .status.clusterChecksRunner.status
name: cluster-checks-runner
type: string
- JSONPath: .metadata.creationTimestamp
name: age
type: date
name: v2alpha1
schema:
openAPIV3Schema:
description: DatadogAgent Deployment with the Datadog Operator.
Expand Down
16 changes: 9 additions & 7 deletions controllers/datadogagent/controller_reconcile_v2_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,18 @@ func (r *Reconciler) createOrUpdateDeployment(parentLogger logr.Logger, dda *dat
now := metav1.NewTime(time.Now())
err = kubernetes.UpdateFromObject(context.TODO(), r.client, updateDeployment, currentDeployment.ObjectMeta)
if err != nil {
updateStatusFunc(nil, newStatus, now, metav1.ConditionFalse, "CreateFailed", "Unable to Update Deployment")
updateStatusFunc(nil, newStatus, now, metav1.ConditionFalse, "UpdateSucceeded", "Unable to update Deployment")
celenechang marked this conversation as resolved.
Show resolved Hide resolved
return reconcile.Result{}, err
}
event := buildEventInfo(updateDeployment.Name, updateDeployment.Namespace, deploymentKind, datadog.UpdateEvent)
r.recordEvent(dda, event)
updateStatusFunc(updateDeployment, newStatus, now, metav1.ConditionTrue, "DeploymentUpdated", "Deployment updated")
updateStatusFunc(updateDeployment, newStatus, now, metav1.ConditionTrue, "UpdateSucceeded", "Deployment updated")
celenechang marked this conversation as resolved.
Show resolved Hide resolved
} else {
now := metav1.NewTime(time.Now())

err = r.client.Create(context.TODO(), deployment)
if err != nil {
updateStatusFunc(nil, newStatus, now, metav1.ConditionFalse, "CreateFailed", "Unable to create Deployment")
updateStatusFunc(nil, newStatus, now, metav1.ConditionFalse, "CreateSucceeded", "Unable to create Deployment")
return reconcile.Result{}, err
}
event := buildEventInfo(deployment.Name, deployment.Namespace, deploymentKind, datadog.CreationEvent)
Expand Down Expand Up @@ -182,17 +182,18 @@ func (r *Reconciler) createOrUpdateDaemonset(parentLogger logr.Logger, dda *data
now := metav1.NewTime(time.Now())
err = kubernetes.UpdateFromObject(context.TODO(), r.client, updateDaemonset, currentDaemonset.ObjectMeta)
if err != nil {
updateStatusFunc(updateDaemonset, newStatus, now, metav1.ConditionFalse, "UpdateSucceeded", "Unable to update Daemonset")
return reconcile.Result{}, err
}
event := buildEventInfo(updateDaemonset.Name, updateDaemonset.Namespace, daemonSetKind, datadog.UpdateEvent)
r.recordEvent(dda, event)
updateStatusFunc(updateDaemonset, newStatus, now, metav1.ConditionTrue, "DaemonsetUpdated", "Daemonset updated")
updateStatusFunc(updateDaemonset, newStatus, now, metav1.ConditionTrue, "UpdateSucceeded", "Daemonset updated")
} else {
now := metav1.NewTime(time.Now())

err = r.client.Create(context.TODO(), daemonset)
if err != nil {
updateStatusFunc(nil, newStatus, now, metav1.ConditionFalse, "CreateFailed", "Unable to create Daemonset")
updateStatusFunc(nil, newStatus, now, metav1.ConditionFalse, "CreateSucceeded", "Unable to create Daemonset")
return reconcile.Result{}, err
}
event := buildEventInfo(daemonset.Name, daemonset.Namespace, daemonSetKind, datadog.CreationEvent)
Expand Down Expand Up @@ -271,17 +272,18 @@ func (r *Reconciler) createOrUpdateExtendedDaemonset(parentLogger logr.Logger, d
now := metav1.NewTime(time.Now())
err = kubernetes.UpdateFromObject(context.TODO(), r.client, updateEDS, currentEDS.ObjectMeta)
if err != nil {
updateStatusFunc(updateEDS, newStatus, now, metav1.ConditionFalse, "UpdateSucceeded", "Unable to update ExtendedDaemonSet")
return reconcile.Result{}, err
}
event := buildEventInfo(updateEDS.Name, updateEDS.Namespace, extendedDaemonSetKind, datadog.UpdateEvent)
r.recordEvent(dda, event)
updateStatusFunc(updateEDS, newStatus, now, metav1.ConditionTrue, "ExtendedDaemonSetUpdated", "ExtendedDaemonSet updated")
updateStatusFunc(updateEDS, newStatus, now, metav1.ConditionTrue, "UpdateSucceeded", "ExtendedDaemonSet updated")
} else {
now := metav1.NewTime(time.Now())

err = r.client.Create(context.TODO(), eds)
if err != nil {
updateStatusFunc(nil, newStatus, now, metav1.ConditionFalse, "CreateFailed", "Unable to create ExtendedDaemonSet")
updateStatusFunc(nil, newStatus, now, metav1.ConditionFalse, "CreateSucceeded", "Unable to create ExtendedDaemonSet")
return reconcile.Result{}, err
}
event := buildEventInfo(eds.Name, eds.Namespace, extendedDaemonSetKind, datadog.CreationEvent)
Expand Down