IPFS CLUSTER - Store a file

Hi, i have a question. If i add a file in ipfs-cluster, it is stored on all peers that are in the cluster but if all these peers decide to delete this file because they don’t want it, the file is no longer available? If this is true then how is file persistence ensured?

And then i’ve read that all the peers in a cluster have a global pinset but if a peer can remove the pin of a file then the pinset is no longer global because the pinset of one peer is different from another

Correct. Unless you control the IPFS peers, there is no way to force them to do something.

And then i’ve read that all the peers in a cluster have a global pinset but if a peer can remove the pin of a file then the pinset is no longer global because the pinset of one peer is different from another

There is a global cluster-pinset, and then there is the ipfs-daemon-pinset. The cluster peer maintains the ipfs-daemon-pinset so that it reflects the things allocated to that peer from the global-cluster-pinset. Of course that peer can delete the pins made by the cluster manually.

The global-pinset concept means that even when cluster peers are concurrently updating the same global-pinset, they will all come to eventually have the same list. But that of course, only happens if they want. i.e. peers do not want to have the same list as that of a peer that they do not trust.

so for example if I have file 1 and add it to the cluster, then all peers in the cluster will have file 1 and this will also be in the global pinset. However if everyone decides to remove the pin from their ipfs-daemon-pinset, then that file is no longer available among the cluster peers and therefore it will also be removed from the global-cluster-pinset. Correct?

It will still be on the global pinset as the cluster peer is a different application. The cluster peer will actually try to re-add it to the local-pinset after a bit, once it detects the anomaly.

Buf if no cluster peer has that file how does the cluster peer try to add it back to the local pinset?

If no one is providing that file anymore then the operation of adding/pinning it on the local pinset again will fail.

so the global pinset can also give me a wrong idea of the available files because if everyone removes the pin of a file then that file remains on the global pinset but actually nobody has it

IPFS (and IPFS Cluster) provides no way of knowing that a peer is holding certain content at a given point of time until that content is retrieved in totality and verified. The global-pinset is a list of what peers should be pinning, not a list of what peers are in reality storing. They could lie in 20 different ways.

But when i add something on IPFS Cluster, what happens? what I added is also stored on the other peers in the cluster?

When you pin on the cluster, ipfs daemons in the cluster are asked to put that pin on the local pinset and therefore retrieve the file.

You can also add the content directly to multiple ipfs peers at once using cluster.

For specific details: https://cluster.ipfs.io/documentation/guides/pinning/#the-pinning-process