Skip to content

Commit

Permalink
[BugFix #1551] change mountTime to *v1.Time (#1610)
Browse files Browse the repository at this point in the history
* fix issue 1551, change mounttime to *v1.Time

Signed-off-by: nizifan <[email protected]>

* Address comments && update crd

Signed-off-by: nizifan <[email protected]>

* update crd

Signed-off-by: nizifan <[email protected]>

* Rebuild&generate crd using controller-gen v0.7.0, and add a nil check

Signed-off-by: nizifan <[email protected]>

Co-authored-by: nizifan <[email protected]>
  • Loading branch information
Nizifan and nizifan authored Apr 7, 2022
1 parent 252f202 commit df23bdf
Show file tree
Hide file tree
Showing 12 changed files with 136 additions and 9 deletions.
4 changes: 2 additions & 2 deletions api/v1alpha1/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ type RuntimeStatus struct {
APIGatewayStatus *APIGatewayStatus `json:"apiGateway,omitempty"`

// MountTime represents time last mount happened
// if Mounttime is early than master starting time, remount will be required
MountTime metav1.Time `json:"mountTime,omitempty"`
// if Mounttime is earlier than master starting time, remount will be required
MountTime *metav1.Time `json:"mountTime,omitempty"`
}

type RuntimePhase string
Expand Down
5 changes: 5 additions & 0 deletions charts/fluid/fluid/crds/data.fluid.io_alluxioruntimes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,11 @@ spec:
masterReason:
description: Reason for Master's condition transition
type: string
mountTime:
description: MountTime represents time last mount happened if Mounttime
is earlier than master starting time, remount will be required
format: date-time
type: string
selector:
description: Selector is used for auto-scaling
type: string
Expand Down
53 changes: 53 additions & 0 deletions charts/fluid/fluid/crds/data.fluid.io_goosefsruntimes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ spec:
apiGateway:
description: The component spec of GooseFS API Gateway
properties:
annotations:
additionalProperties:
type: string
description: 'Annotations is an unstructured key value map stored
with a resource that may be set by external tools to store and
retrieve arbitrary metadata. They are not queryable and should
be preserved when modifying objects. More info: http://kubernetes.io/docs/user-guide/annotations'
type: object
enabled:
description: Enabled or Disabled for the components. For now,
only API Gateway is enabled or disabled.
Expand Down Expand Up @@ -174,6 +182,14 @@ spec:
fuse:
description: The component spec of GooseFS Fuse
properties:
annotations:
additionalProperties:
type: string
description: 'Annotations is an unstructured key value map stored
with a resource that may be set by external tools to store and
retrieve arbitrary metadata. They are not queryable and should
be preserved when modifying objects. More info: http://kubernetes.io/docs/user-guide/annotations'
type: object
args:
description: Arguments that will be passed to GooseFS Fuse
items:
Expand Down Expand Up @@ -332,6 +348,14 @@ spec:
jobMaster:
description: The component spec of GooseFS job master
properties:
annotations:
additionalProperties:
type: string
description: 'Annotations is an unstructured key value map stored
with a resource that may be set by external tools to store and
retrieve arbitrary metadata. They are not queryable and should
be preserved when modifying objects. More info: http://kubernetes.io/docs/user-guide/annotations'
type: object
enabled:
description: Enabled or Disabled for the components. For now,
only API Gateway is enabled or disabled.
Expand Down Expand Up @@ -405,6 +429,14 @@ spec:
jobWorker:
description: The component spec of GooseFS job Worker
properties:
annotations:
additionalProperties:
type: string
description: 'Annotations is an unstructured key value map stored
with a resource that may be set by external tools to store and
retrieve arbitrary metadata. They are not queryable and should
be preserved when modifying objects. More info: http://kubernetes.io/docs/user-guide/annotations'
type: object
enabled:
description: Enabled or Disabled for the components. For now,
only API Gateway is enabled or disabled.
Expand Down Expand Up @@ -483,6 +515,14 @@ spec:
master:
description: The component spec of GooseFS master
properties:
annotations:
additionalProperties:
type: string
description: 'Annotations is an unstructured key value map stored
with a resource that may be set by external tools to store and
retrieve arbitrary metadata. They are not queryable and should
be preserved when modifying objects. More info: http://kubernetes.io/docs/user-guide/annotations'
type: object
enabled:
description: Enabled or Disabled for the components. For now,
only API Gateway is enabled or disabled.
Expand Down Expand Up @@ -649,6 +689,14 @@ spec:
worker:
description: The component spec of GooseFS worker
properties:
annotations:
additionalProperties:
type: string
description: 'Annotations is an unstructured key value map stored
with a resource that may be set by external tools to store and
retrieve arbitrary metadata. They are not queryable and should
be preserved when modifying objects. More info: http://kubernetes.io/docs/user-guide/annotations'
type: object
enabled:
description: Enabled or Disabled for the components. For now,
only API Gateway is enabled or disabled.
Expand Down Expand Up @@ -840,6 +888,11 @@ spec:
masterReason:
description: Reason for Master's condition transition
type: string
mountTime:
description: MountTime represents time last mount happened if Mounttime
is earlier than master starting time, remount will be required
format: date-time
type: string
selector:
description: Selector is used for auto-scaling
type: string
Expand Down
5 changes: 5 additions & 0 deletions charts/fluid/fluid/crds/data.fluid.io_jindoruntimes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,11 @@ spec:
masterReason:
description: Reason for Master's condition transition
type: string
mountTime:
description: MountTime represents time last mount happened if Mounttime
is earlier than master starting time, remount will be required
format: date-time
type: string
selector:
description: Selector is used for auto-scaling
type: string
Expand Down
2 changes: 1 addition & 1 deletion charts/fluid/fluid/crds/data.fluid.io_juicefsruntimes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,7 @@ spec:
type: string
mountTime:
description: MountTime represents time last mount happened if Mounttime
is early than master starting time, remount will be required
is earlier than master starting time, remount will be required
format: date-time
type: string
selector:
Expand Down
5 changes: 5 additions & 0 deletions config/crd/bases/data.fluid.io_alluxioruntimes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,11 @@ spec:
masterReason:
description: Reason for Master's condition transition
type: string
mountTime:
description: MountTime represents time last mount happened if Mounttime
is earlier than master starting time, remount will be required
format: date-time
type: string
selector:
description: Selector is used for auto-scaling
type: string
Expand Down
53 changes: 53 additions & 0 deletions config/crd/bases/data.fluid.io_goosefsruntimes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ spec:
apiGateway:
description: The component spec of GooseFS API Gateway
properties:
annotations:
additionalProperties:
type: string
description: 'Annotations is an unstructured key value map stored
with a resource that may be set by external tools to store and
retrieve arbitrary metadata. They are not queryable and should
be preserved when modifying objects. More info: http://kubernetes.io/docs/user-guide/annotations'
type: object
enabled:
description: Enabled or Disabled for the components. For now,
only API Gateway is enabled or disabled.
Expand Down Expand Up @@ -174,6 +182,14 @@ spec:
fuse:
description: The component spec of GooseFS Fuse
properties:
annotations:
additionalProperties:
type: string
description: 'Annotations is an unstructured key value map stored
with a resource that may be set by external tools to store and
retrieve arbitrary metadata. They are not queryable and should
be preserved when modifying objects. More info: http://kubernetes.io/docs/user-guide/annotations'
type: object
args:
description: Arguments that will be passed to GooseFS Fuse
items:
Expand Down Expand Up @@ -332,6 +348,14 @@ spec:
jobMaster:
description: The component spec of GooseFS job master
properties:
annotations:
additionalProperties:
type: string
description: 'Annotations is an unstructured key value map stored
with a resource that may be set by external tools to store and
retrieve arbitrary metadata. They are not queryable and should
be preserved when modifying objects. More info: http://kubernetes.io/docs/user-guide/annotations'
type: object
enabled:
description: Enabled or Disabled for the components. For now,
only API Gateway is enabled or disabled.
Expand Down Expand Up @@ -405,6 +429,14 @@ spec:
jobWorker:
description: The component spec of GooseFS job Worker
properties:
annotations:
additionalProperties:
type: string
description: 'Annotations is an unstructured key value map stored
with a resource that may be set by external tools to store and
retrieve arbitrary metadata. They are not queryable and should
be preserved when modifying objects. More info: http://kubernetes.io/docs/user-guide/annotations'
type: object
enabled:
description: Enabled or Disabled for the components. For now,
only API Gateway is enabled or disabled.
Expand Down Expand Up @@ -483,6 +515,14 @@ spec:
master:
description: The component spec of GooseFS master
properties:
annotations:
additionalProperties:
type: string
description: 'Annotations is an unstructured key value map stored
with a resource that may be set by external tools to store and
retrieve arbitrary metadata. They are not queryable and should
be preserved when modifying objects. More info: http://kubernetes.io/docs/user-guide/annotations'
type: object
enabled:
description: Enabled or Disabled for the components. For now,
only API Gateway is enabled or disabled.
Expand Down Expand Up @@ -649,6 +689,14 @@ spec:
worker:
description: The component spec of GooseFS worker
properties:
annotations:
additionalProperties:
type: string
description: 'Annotations is an unstructured key value map stored
with a resource that may be set by external tools to store and
retrieve arbitrary metadata. They are not queryable and should
be preserved when modifying objects. More info: http://kubernetes.io/docs/user-guide/annotations'
type: object
enabled:
description: Enabled or Disabled for the components. For now,
only API Gateway is enabled or disabled.
Expand Down Expand Up @@ -840,6 +888,11 @@ spec:
masterReason:
description: Reason for Master's condition transition
type: string
mountTime:
description: MountTime represents time last mount happened if Mounttime
is earlier than master starting time, remount will be required
format: date-time
type: string
selector:
description: Selector is used for auto-scaling
type: string
Expand Down
5 changes: 5 additions & 0 deletions config/crd/bases/data.fluid.io_jindoruntimes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,11 @@ spec:
masterReason:
description: Reason for Master's condition transition
type: string
mountTime:
description: MountTime represents time last mount happened if Mounttime
is earlier than master starting time, remount will be required
format: date-time
type: string
selector:
description: Selector is used for auto-scaling
type: string
Expand Down
2 changes: 1 addition & 1 deletion config/crd/bases/data.fluid.io_juicefsruntimes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,7 @@ spec:
type: string
mountTime:
description: MountTime represents time last mount happened if Mounttime
is early than master starting time, remount will be required
is earlier than master starting time, remount will be required
format: date-time
type: string
selector:
Expand Down
2 changes: 1 addition & 1 deletion pkg/ddc/alluxio/ufs.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func (e *AlluxioEngine) checkIfRemountRequired(ufsToUpdate *utils.UFSToUpdate) {
}

// If mounttime is earlier than master container starttime, remount is necessary
if startedAt != nil && runtime.Status.MountTime.Before(startedAt) {
if startedAt != nil && runtime.Status.MountTime != nil && runtime.Status.MountTime.Before(startedAt) {
e.Log.Info("remount on master restart", "alluxioruntime", e.name)

unmountedPaths, err := e.FindUnmountedUFS()
Expand Down
3 changes: 2 additions & 1 deletion pkg/ddc/alluxio/ufs_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/fluid-cloudnative/fluid/pkg/utils"
"github.com/fluid-cloudnative/fluid/pkg/utils/kubeclient"
"github.com/pkg/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"k8s.io/client-go/util/retry"
)
Expand Down Expand Up @@ -323,7 +324,7 @@ func (e *AlluxioEngine) updateMountTime() {
}

runtimeToUpdate := runtime.DeepCopy()
runtimeToUpdate.Status.MountTime.Time = time.Now()
runtimeToUpdate.Status.MountTime = &metav1.Time{Time: time.Now()}

if !reflect.DeepEqual(runtime.Status, runtimeToUpdate.Status) {
err = e.Client.Status().Update(context.TODO(), runtimeToUpdate)
Expand Down
6 changes: 3 additions & 3 deletions pkg/ddc/alluxio/ufs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ func TestUpdateMountTime(t *testing.T) {
Namespace: "default",
},
Status: datav1alpha1.RuntimeStatus{
MountTime: v1.Time{
MountTime: &v1.Time{
Time: yesterday,
},
},
Expand Down Expand Up @@ -481,7 +481,7 @@ func TestCheckIfRemountRequired(t *testing.T) {
Namespace: "default",
},
Status: datav1alpha1.RuntimeStatus{
MountTime: v1.Time{
MountTime: &v1.Time{
Time: yesterday,
},
},
Expand Down Expand Up @@ -517,7 +517,7 @@ func TestCheckIfRemountRequired(t *testing.T) {
Namespace: "default",
},
Status: datav1alpha1.RuntimeStatus{
MountTime: v1.Time{
MountTime: &v1.Time{
Time: yesterday,
},
},
Expand Down

0 comments on commit df23bdf

Please sign in to comment.