Skip to content

Commit 45aa401

Browse files
authored
Merge pull request #56 from RobotSail/RobotSail/issue37
Add Reprovider Settings to Spec
2 parents facd292 + fa13b95 commit 45aa401

File tree

6 files changed

+96
-1
lines changed

6 files changed

+96
-1
lines changed

api/v1alpha1/ipfs_types.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,28 @@ const (
3232
ReconciledReasonError string = "ReconcileError"
3333
)
3434

35+
type ReproviderStrategy string
36+
37+
const (
38+
// ReproviderStrategyAll Announces the CID of every stored block.
39+
ReproviderStrategyAll ReproviderStrategy = "all"
40+
// ReproviderStrategyPinned Only announces the pinned CIDs recursively.
41+
ReproviderStrategyPinned ReproviderStrategy = "pinned"
42+
// ReproviderStrategyRoots Only announces the root block of explicitly pinned CIDs.
43+
ReproviderStrategyRoots ReproviderStrategy = "roots"
44+
)
45+
46+
type ReprovideSettings struct {
47+
// Strategy specifies the reprovider strategy, defaults to 'all'.
48+
// +kubebuilder:validation:Enum={all,pinned,roots}
49+
// +optional
50+
Strategy ReproviderStrategy `json:"strategy,omitempty"`
51+
// Interval sets the time between rounds of reproviding
52+
// local content to the routing system. Defaults to '12h'.
53+
// +optional
54+
Interval string `json:"interval,omitempty"`
55+
}
56+
3557
type followParams struct {
3658
Name string `json:"name"`
3759
Template string `json:"template"`
@@ -50,6 +72,10 @@ type IpfsSpec struct {
5072
Replicas int32 `json:"replicas"`
5173
Networking networkConfig `json:"networking"`
5274
Follows []followParams `json:"follows"`
75+
// Reprovider Describes the settings that each IPFS node
76+
// should use when reproviding content.
77+
// +optional
78+
Reprovider ReprovideSettings `json:"reprovider,omitempty"`
5379
}
5480

5581
type IpfsStatus struct {

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/cluster.ipfs.io_ipfs.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,23 @@ spec:
6363
replicas:
6464
format: int32
6565
type: integer
66+
reprovider:
67+
description: Reprovider Describes the settings that each IPFS node
68+
should use when reproviding content.
69+
properties:
70+
interval:
71+
description: Interval sets the time between rounds of reproviding
72+
local content to the routing system. Defaults to '12h'.
73+
type: string
74+
strategy:
75+
description: Strategy specifies the reprovider strategy, defaults
76+
to 'all'.
77+
enum:
78+
- all
79+
- pinned
80+
- roots
81+
type: string
82+
type: object
6683
url:
6784
type: string
6885
required:

controllers/scripts.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,25 @@ func (r *IpfsReconciler) ConfigMapScripts(
8080
return err
8181
}, ""
8282
}
83+
84+
// reprovider settings
85+
reproviderStrategy := m.Spec.Reprovider.Strategy
86+
if reproviderStrategy == "" {
87+
reproviderStrategy = clusterv1alpha1.ReproviderStrategyAll
88+
}
89+
reproviderInterval := m.Spec.Reprovider.Interval
90+
if reproviderInterval == "" {
91+
reproviderInterval = "12h"
92+
}
93+
8394
// get the config script
8495
configScript, err := scripts.CreateConfigureScript(
8596
maxStorageS,
8697
relayPeers,
8798
relayConfig,
8899
bloomFilterSize,
100+
reproviderInterval,
101+
string(reproviderStrategy),
89102
)
90103

91104
expected := &corev1.ConfigMap{

controllers/scripts/config.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,21 @@ func CreateConfigureScript(
149149
peers []peer.AddrInfo,
150150
relayConfig config.RelayClient,
151151
bloomFilterSize int64,
152+
reproviderInterval string,
153+
reproviderStrategy string,
152154
) (string, error) {
155+
// set settings
153156
configureTmpl, _ := template.New("configureIpfs").Parse(configureIpfs)
154157
config, err := createTemplateConfig(storageMax, peers, relayConfig)
155158
if err != nil {
156159
return "", err
157160
}
158161
config.Swarm.RelayClient = relayConfig
159162
config.Datastore.BloomFilterSize = int(bloomFilterSize)
163+
config.Reprovider.Interval = reproviderInterval
164+
config.Reprovider.Strategy = reproviderStrategy
165+
166+
// convert config settings into json string
160167
configBytes, err := json.Marshal(config)
161168
if err != nil {
162169
return "", err

helm/ipfs-operator/crds/CustomResourceDefinition-ipfs.cluster.ipfs.io.yaml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,23 @@ spec:
6363
replicas:
6464
format: int32
6565
type: integer
66+
reprovider:
67+
description: Reprovider Describes the settings that each IPFS node
68+
should use when reproviding content.
69+
properties:
70+
interval:
71+
description: Interval sets the time between rounds of reproviding
72+
local content to the routing system. Defaults to '12h'.
73+
type: string
74+
strategy:
75+
description: Strategy specifies the reprovider strategy, defaults
76+
to 'all'.
77+
enum:
78+
- all
79+
- pinned
80+
- roots
81+
type: string
82+
type: object
6683
url:
6784
type: string
6885
required:
@@ -72,7 +89,6 @@ spec:
7289
- networking
7390
- public
7491
- replicas
75-
- url
7692
type: object
7793
status:
7894
properties:

0 commit comments

Comments
 (0)